OSDN Git Service

Fix bugs of UTF-8 to UTF-16 API bridge.
[ffftp/ffftp.git] / filelist.c
1 /*=============================================================================\r
2 *\r
3 *                                                               ファイル一覧\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 // UTF-8対応\r
31 //#define _WIN32_WINNT  0x400\r
32 \r
33 #define STRICT\r
34 // IPv6対応\r
35 #include <winsock2.h>\r
36 #include <windows.h>\r
37 #include <stdio.h>\r
38 #include <stdlib.h>\r
39 #include <string.h>\r
40 #include <ctype.h>\r
41 #include <time.h>\r
42 #include <mbstring.h>\r
43 #include <malloc.h>\r
44 #include <windowsx.h>\r
45 #include <commctrl.h>\r
46 #include <sys/types.h>\r
47 #include <sys/stat.h>\r
48 #include <direct.h>\r
49 \r
50 #include "common.h"\r
51 #include "resource.h"\r
52 \r
53 #include <htmlhelp.h>\r
54 #include "helpid.h"\r
55 \r
56 #include <shlobj.h>\r
57 #include "OleDragDrop.h"\r
58 #include "common.h"\r
59 \r
60 // UTF-8対応\r
61 #undef __MBSWRAPPER_H__\r
62 #include "mbswrapper.h"\r
63 \r
64 #define BUF_SIZE                256\r
65 #define CF_CNT 2\r
66 #define WM_DRAGDROP             (WM_APP + 100)\r
67 #define WM_GETDATA              (WM_APP + 101)\r
68 #define WM_DRAGOVER             (WM_APP + 102)\r
69 \r
70 \r
71 /*===== ファイルリストのリスト用ストラクチャ =====*/\r
72 \r
73 typedef struct {\r
74         FILELIST *Top;                  /* ファイルリストの先頭 */\r
75         int Files;                              /* ファイルの数 */\r
76 } FLISTANCHOR;\r
77 \r
78 /*===== プロトタイプ =====*/\r
79 \r
80 static LRESULT CALLBACK LocalWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
81 static LRESULT CALLBACK RemoteWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
82 static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
83 static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LONGLONG Size, int Attr, int Type, int Link, char *Owner, int InfoExist, int Win);\r
84 static void EraseDispFileList(FLISTANCHOR *Anchor);\r
85 static void DispFileList2View(HWND hWnd, FLISTANCHOR *Anchor);\r
86 static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist);\r
87 // 64ビット対応\r
88 //static BOOL CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
89 static INT_PTR CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
90 static void DispListList(FILELIST *Pos, char *Title);\r
91 static void MakeRemoteTree1(char *Path, char *Cur, FILELIST **Base, int *CancelCheckWork);\r
92 static void MakeRemoteTree2(char *Path, char *Cur, FILELIST **Base, int *CancelCheckWork);\r
93 static void CopyTmpListToFileList(FILELIST **Base, FILELIST *List);\r
94 static int GetListOneLine(char *Buf, int Max, FILE *Fd);\r
95 static int MakeDirPath(char *Str, int ListType, char *Path, char *Dir);\r
96 static void MakeLocalTree(char *Path, FILELIST **Base);\r
97 static void AddFileList(FILELIST *Pkt, FILELIST **Base);\r
98 static int AnalizeFileInfo(char *Str);\r
99 static int CheckUnixType(char *Str, char *Tmp, int Add1, int Add2, int Day);\r
100 static int CheckHHMMformat(char *Str);\r
101 static int CheckYYMMDDformat(char *Str, char Sym, int Dig3);\r
102 static int CheckYYYYMMDDformat(char *Str, char Sym);\r
103 static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size, FILETIME *Time, int *Attr, char *Owner, int *Link, int *InfoExist);\r
104 static int FindField(char *Str, char *Buf, int Num, int ToLast);\r
105 // MLSD対応\r
106 static int FindField2(char *Str, char *Buf, char Separator, int Num, int ToLast);\r
107 static void GetMonth(char *Str, WORD *Month, WORD *Day);\r
108 static int GetYearMonthDay(char *Str, WORD *Year, WORD *Month, WORD *Day);\r
109 static int GetHourAndMinute(char *Str, WORD *Hour, WORD *Minute);\r
110 static int GetVMSdate(char *Str, WORD *Year, WORD *Month, WORD *Day);\r
111 static int CheckSpecialDirName(char *Fname);\r
112 static int AskFilterStr(char *Fname, int Type);\r
113 // 64ビット対応\r
114 //static BOOL CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
115 static INT_PTR CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
116 static int atoi_n(const char *Str, int Len);\r
117 \r
118 /*===== 外部参照 =====*/\r
119 \r
120 extern int SepaWidth;\r
121 extern int RemoteWidth;\r
122 extern int ListHeight;\r
123 extern char FilterStr[FILTER_EXT_LEN+1];\r
124 extern HWND hHelpWin;\r
125 \r
126 /* 設定値 */\r
127 extern int LocalWidth;\r
128 extern int LocalTabWidth[4];\r
129 extern int RemoteTabWidth[6];\r
130 extern char UserMailAdrs[USER_MAIL_LEN+1];\r
131 extern HFONT ListFont;\r
132 extern int ListType;\r
133 extern int FindMode;\r
134 extern int DotFile;\r
135 extern int DispIgnoreHide;\r
136 extern int DispDrives;\r
137 extern int MoveMode;\r
138 \r
139 /*===== ローカルなワーク =====*/\r
140 \r
141 static HWND hWndListLocal = NULL;\r
142 static HWND hWndListRemote = NULL;\r
143 \r
144 static WNDPROC LocalProcPtr;\r
145 static WNDPROC RemoteProcPtr;\r
146 \r
147 static HIMAGELIST ListImg = NULL;\r
148 \r
149 static char FindStr[40+1] = { "*" };            /* 検索文字列 */\r
150 static int IgnoreNew = NO;\r
151 static int IgnoreOld = NO;\r
152 static int IgnoreExist = NO;\r
153 \r
154 static int Dragging = NO;\r
155 \r
156 static int StratusMode;                 /* 0=ファイル, 1=ディレクトリ, 2=リンク */\r
157 \r
158 \r
159 // リモートファイルリスト (2007.9.3 yutaka)\r
160 static FILELIST *remoteFileListBase;\r
161 static FILELIST *remoteFileListBaseNoExpand;\r
162 static char remoteFileDir[FMAX_PATH + 1];\r
163 \r
164 \r
165 /*----- ファイルリストウインドウを作成する ------------------------------------\r
166 *\r
167 *       Parameter\r
168 *               HWND hWnd : 親ウインドウのウインドウハンドル\r
169 *               HINSTANCE hInst : インスタンスハンドル\r
170 *\r
171 *       Return Value\r
172 *               int ステータス\r
173 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
174 *----------------------------------------------------------------------------*/\r
175 \r
176 int MakeListWin(HWND hWnd, HINSTANCE hInst)\r
177 {\r
178         int Sts;\r
179         LV_COLUMN LvCol;\r
180         long Tmp;\r
181 \r
182         /*===== ローカル側のリストビュー =====*/\r
183 \r
184         hWndListLocal = CreateWindowEx(/*WS_EX_STATICEDGE*/WS_EX_CLIENTEDGE,\r
185                         WC_LISTVIEWA, NULL,\r
186                         WS_CHILD | /*WS_BORDER | */LVS_REPORT | LVS_SHOWSELALWAYS,\r
187                         0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight,\r
188                         GetMainHwnd(), (HMENU)1500, hInst, NULL);\r
189 \r
190         if(hWndListLocal != NULL)\r
191         {\r
192                 // 64ビット対応\r
193 //              LocalProcPtr = (WNDPROC)SetWindowLong(hWndListLocal, GWL_WNDPROC, (LONG)LocalWndProc);\r
194                 LocalProcPtr = (WNDPROC)SetWindowLongPtr(hWndListLocal, GWLP_WNDPROC, (LONG_PTR)LocalWndProc);\r
195 \r
196             Tmp = SendMessage(hWndListLocal, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);\r
197             Tmp |= LVS_EX_FULLROWSELECT;\r
198             SendMessage(hWndListLocal, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)Tmp);\r
199 \r
200                 if(ListFont != NULL)\r
201                         SendMessage(hWndListLocal, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
202 \r
203                 ListImg = ImageList_LoadBitmap(hInst, MAKEINTRESOURCE(dirattr_bmp), 16, 9, RGB(255,0,0));\r
204                 SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
205                 ShowWindow(hWndListLocal, SW_SHOW);\r
206 \r
207                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
208                 LvCol.cx = LocalTabWidth[0];\r
209                 LvCol.pszText = MSGJPN038;\r
210                 LvCol.iSubItem = 0;\r
211                 SendMessage(hWndListLocal, LVM_INSERTCOLUMN, 0, (LPARAM)&LvCol);\r
212 \r
213                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
214                 LvCol.cx = LocalTabWidth[1];\r
215                 LvCol.pszText = MSGJPN039;\r
216                 LvCol.iSubItem = 1;\r
217                 SendMessage(hWndListLocal, LVM_INSERTCOLUMN, 1, (LPARAM)&LvCol);\r
218 \r
219                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT;\r
220                 LvCol.fmt = LVCFMT_RIGHT;\r
221                 LvCol.cx = LocalTabWidth[2];\r
222                 LvCol.pszText = MSGJPN040;\r
223                 LvCol.iSubItem = 2;\r
224                 SendMessage(hWndListLocal, LVM_INSERTCOLUMN, 2, (LPARAM)&LvCol);\r
225 \r
226                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
227                 LvCol.cx = LocalTabWidth[3];\r
228                 LvCol.pszText = MSGJPN041;\r
229                 LvCol.iSubItem = 3;\r
230                 SendMessage(hWndListLocal, LVM_INSERTCOLUMN, 3, (LPARAM)&LvCol);\r
231         }\r
232 \r
233         /*===== ホスト側のリストビュー =====*/\r
234 \r
235         hWndListRemote = CreateWindowEx(/*WS_EX_STATICEDGE*/WS_EX_CLIENTEDGE,\r
236                         WC_LISTVIEWA, NULL,\r
237                         WS_CHILD | /*WS_BORDER | */LVS_REPORT | LVS_SHOWSELALWAYS,\r
238                         LocalWidth + SepaWidth, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight,\r
239                         GetMainHwnd(), (HMENU)1500, hInst, NULL);\r
240 \r
241         if(hWndListRemote != NULL)\r
242         {\r
243                 // 64ビット対応\r
244 //              RemoteProcPtr = (WNDPROC)SetWindowLong(hWndListRemote, GWL_WNDPROC, (LONG)RemoteWndProc);\r
245                 RemoteProcPtr = (WNDPROC)SetWindowLongPtr(hWndListRemote, GWLP_WNDPROC, (LONG_PTR)RemoteWndProc);\r
246 \r
247             Tmp = SendMessage(hWndListRemote, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);\r
248             Tmp |= LVS_EX_FULLROWSELECT;\r
249             SendMessage(hWndListRemote, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)Tmp);\r
250 \r
251                 if(ListFont != NULL)\r
252                         SendMessage(hWndListRemote, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
253 \r
254                 SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
255                 ShowWindow(hWndListRemote, SW_SHOW);\r
256 \r
257                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
258                 LvCol.cx = RemoteTabWidth[0];\r
259                 LvCol.pszText = MSGJPN042;\r
260                 LvCol.iSubItem = 0;\r
261                 SendMessage(hWndListRemote, LVM_INSERTCOLUMN, 0, (LPARAM)&LvCol);\r
262 \r
263                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
264                 LvCol.cx = RemoteTabWidth[1];\r
265                 LvCol.pszText = MSGJPN043;\r
266                 LvCol.iSubItem = 1;\r
267                 SendMessage(hWndListRemote, LVM_INSERTCOLUMN, 1, (LPARAM)&LvCol);\r
268 \r
269                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT;\r
270                 LvCol.fmt = LVCFMT_RIGHT;\r
271                 LvCol.cx = RemoteTabWidth[2];\r
272                 LvCol.pszText = MSGJPN044;\r
273                 LvCol.iSubItem = 2;\r
274                 SendMessage(hWndListRemote, LVM_INSERTCOLUMN, 2, (LPARAM)&LvCol);\r
275 \r
276                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
277                 LvCol.cx = RemoteTabWidth[3];\r
278                 LvCol.pszText = MSGJPN045;\r
279                 LvCol.iSubItem = 3;\r
280                 SendMessage(hWndListRemote, LVM_INSERTCOLUMN, 3, (LPARAM)&LvCol);\r
281 \r
282                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
283                 LvCol.cx = RemoteTabWidth[4];\r
284                 LvCol.pszText = MSGJPN046;\r
285                 LvCol.iSubItem = 4;\r
286                 SendMessage(hWndListRemote, LVM_INSERTCOLUMN, 4, (LPARAM)&LvCol);\r
287 \r
288                 LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;\r
289                 LvCol.cx = RemoteTabWidth[5];\r
290                 LvCol.pszText = MSGJPN047;\r
291                 LvCol.iSubItem = 5;\r
292                 SendMessage(hWndListRemote, LVM_INSERTCOLUMN, 5, (LPARAM)&LvCol);\r
293         }\r
294 \r
295         Sts = FFFTP_SUCCESS;\r
296         if((hWndListLocal == NULL) ||\r
297            (hWndListRemote == NULL))\r
298         {\r
299                 Sts = FFFTP_FAIL;\r
300         }\r
301         return(Sts);\r
302 }\r
303 \r
304 \r
305 /*----- ファイルリストウインドウを削除 ----------------------------------------\r
306 *\r
307 *       Parameter\r
308 *               なし\r
309 *\r
310 *       Return Value\r
311 *               なし\r
312 *----------------------------------------------------------------------------*/\r
313 \r
314 void DeleteListWin(void)\r
315 {\r
316 //      if(ListImg != NULL)\r
317 //              ImageList_Destroy(ListImg);\r
318         if(hWndListLocal != NULL)\r
319                 DestroyWindow(hWndListLocal);\r
320         if(hWndListRemote != NULL)\r
321                 DestroyWindow(hWndListRemote);\r
322         return;\r
323 }\r
324 \r
325 \r
326 /*----- ローカル側のファイルリストのウインドウハンドルを返す ------------------\r
327 *\r
328 *       Parameter\r
329 *               なし\r
330 *\r
331 *       Return Value\r
332 *               HWND ウインドウハンドル\r
333 *----------------------------------------------------------------------------*/\r
334 \r
335 HWND GetLocalHwnd(void)\r
336 {\r
337         return(hWndListLocal);\r
338 }\r
339 \r
340 \r
341 /*----- ホスト側のファイルリストのウインドウハンドルを返す --------------------\r
342 *\r
343 *       Parameter\r
344 *               なし\r
345 *\r
346 *       Return Value\r
347 *               HWND ウインドウハンドル\r
348 *----------------------------------------------------------------------------*/\r
349 \r
350 HWND GetRemoteHwnd(void)\r
351 {\r
352         return(hWndListRemote);\r
353 }\r
354 \r
355 \r
356 /*----- ローカル側のファイルリストウインドウのメッセージ処理 ------------------\r
357 *\r
358 *       Parameter\r
359 *               HWND hWnd : ウインドウハンドル\r
360 *               UINT message  : メッセージ番号\r
361 *               WPARAM wParam : メッセージの WPARAM 引数\r
362 *               LPARAM lParam : メッセージの LPARAM 引数\r
363 *\r
364 *       Return Value\r
365 *               メッセージに対応する戻り値\r
366 *----------------------------------------------------------------------------*/\r
367 \r
368 static LRESULT CALLBACK LocalWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
369 {\r
370         return(FileListCommonWndProc(hWnd, message, wParam, lParam));\r
371 }\r
372 \r
373 \r
374 /*----- ホスト側のファイルリストウインドウのメッセージ処理 --------------------\r
375 *\r
376 *       Parameter\r
377 *               HWND hWnd : ウインドウハンドル\r
378 *               UINT message  : メッセージ番号\r
379 *               WPARAM wParam : メッセージの WPARAM 引数\r
380 *               LPARAM lParam : メッセージの LPARAM 引数\r
381 *\r
382 *       Return Value\r
383 *               メッセージに対応する戻り値\r
384 *----------------------------------------------------------------------------*/\r
385 \r
386 static LRESULT CALLBACK RemoteWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
387 {\r
388         return(FileListCommonWndProc(hWnd, message, wParam, lParam));\r
389 }\r
390 \r
391 \r
392 // ダイアログプロシージャ\r
393 static BOOL CALLBACK doOleDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)\r
394 {\r
395 #define TIMER_ID     (100)      // 作成するタイマの識別ID\r
396 #define TIMER_ELAPSE (100)       // WM_TIMERの発生間隔\r
397         MSG message;\r
398 \r
399         switch( msg ){\r
400         case WM_INITDIALOG:  // ダイアログボックスが作成されたとき\r
401                 SetTimer( hDlg, TIMER_ID, 0, NULL);\r
402                 return TRUE;\r
403 \r
404         case WM_TIMER:\r
405                 ShowWindow(hDlg, SW_HIDE);  // ダイアログは隠す\r
406 \r
407                 if (wp != TIMER_ID)\r
408                         break;\r
409 \r
410                 if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) {\r
411                                 TranslateMessage(&message);\r
412                                 DispatchMessage(&message);\r
413 \r
414                 } else {\r
415                         if (AskTransferNow() == NO) {\r
416                                 EndDialog( hDlg, 0 );\r
417                                 return TRUE;\r
418                         }\r
419                 }\r
420 \r
421                 SetTimer( hDlg, TIMER_ID, TIMER_ELAPSE, NULL );\r
422                 return TRUE;\r
423 \r
424         case WM_COMMAND:     // ダイアログボックス内の何かが選択されたとき\r
425                 switch( LOWORD( wp ) ){\r
426 //              case IDOK:       // 「OK」ボタンが選択された\r
427                 case IDCANCEL:   // 「キャンセル」ボタンが選択された\r
428                         // ダイアログボックスを消す\r
429                         EndDialog( hDlg, 0 );\r
430                         break;\r
431                 }\r
432                 return TRUE;\r
433         }\r
434 \r
435         return FALSE;  // DefWindowProc()ではなく、FALSEを返すこと!\r
436 #undef TIMER_ID     \r
437 #undef TIMER_ELAPSE \r
438 }\r
439 \r
440 \r
441 static void doTransferRemoteFile(void)\r
442 {\r
443         FILELIST *FileListBase, *FileListBaseNoExpand, *pf;\r
444         int CancelFlg = NO;\r
445         char LocDir[FMAX_PATH+1];\r
446         char TmpDir[FMAX_PATH+1];\r
447         char buf[32];\r
448         int i;\r
449         DWORD pid;\r
450 \r
451         // すでにリモートから転送済みなら何もしない。(2007.9.3 yutaka)\r
452         if (remoteFileListBase != NULL)\r
453                 return;\r
454 \r
455         FileListBase = NULL;\r
456         MakeSelectedFileList(WIN_REMOTE, YES, NO, &FileListBase, &CancelFlg);\r
457         FileListBaseNoExpand = NULL;\r
458         MakeSelectedFileList(WIN_REMOTE, NO, NO, &FileListBaseNoExpand, &CancelFlg);\r
459 \r
460         // set temporary folder\r
461         AskLocalCurDir(LocDir, FMAX_PATH);\r
462 \r
463         // アプリを多重起動してもコンフリクトしないように、テンポラリフォルダ名にプロセスID\r
464         // を付加する。(2007.9.13 yutaka)\r
465         // 環境依存の不具合対策\r
466 //      GetTempPath(sizeof(TmpDir), TmpDir);\r
467 //      pid = GetCurrentProcessId();\r
468 //      _snprintf_s(buf, sizeof(buf), _TRUNCATE, "ffftp%d", pid);\r
469 //      strncat_s(TmpDir, sizeof(TmpDir), buf, _TRUNCATE);\r
470         GetAppTempPath(TmpDir);\r
471         _mkdir(TmpDir);\r
472         SetYenTail(TmpDir);\r
473         strcat(TmpDir, "transfer");\r
474         _mkdir(TmpDir);\r
475 #if 0\r
476         if (TmpDir[strlen(TmpDir) - 1] == '\\') {\r
477                 TmpDir[strlen(TmpDir) - 1] = '\0';\r
478         }\r
479 #endif\r
480 \r
481         // 既存のファイルを削除する\r
482         for (pf = FileListBase ; pf ; pf = pf->Next) {\r
483                 char fn[FMAX_PATH+1];\r
484 \r
485                 strncpy_s(fn, sizeof(fn), TmpDir, _TRUNCATE);\r
486                 strncat_s(fn, sizeof(fn), "\\", _TRUNCATE);\r
487                 strncat_s(fn, sizeof(fn), pf->File, _TRUNCATE);\r
488 \r
489                 remove(fn);\r
490         }\r
491 \r
492         // ダウンロード先をテンポラリに設定\r
493         SetLocalDirHist(TmpDir);\r
494 \r
495         // FFFTPにダウンロード要求を出し、ダウンロードの完了を待つ。\r
496         PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
497 \r
498         for (i = 0 ; i < 10 ; i++) {\r
499                 MSG msg;\r
500 \r
501                 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {\r
502                         TranslateMessage(&msg);\r
503                         DispatchMessage(&msg);\r
504 \r
505                 } else {\r
506                         // 転送スレッドが動き出したら抜ける。\r
507                         if (AskTransferNow() == YES)\r
508                                 break;\r
509                 }\r
510 \r
511                 Sleep(10);\r
512         }\r
513 \r
514         // OLE D&D中にメインウィンドウをユーザに操作させると、おかしくなるので、\r
515         // 隠しモーダルダイアログを作る。\r
516         // (2007.9.11 yutaka)\r
517         DialogBox(GetFtpInst(), MAKEINTRESOURCE(IDD_OLEDRAG), GetMainHwnd(), (DLGPROC)doOleDlgProc);\r
518 \r
519         // ダウンロード先を元に戻す\r
520         SetLocalDirHist(LocDir);\r
521         SetCurrentDirAsDirHist();\r
522 \r
523         remoteFileListBase = FileListBase;  // あとでフリーすること\r
524         remoteFileListBaseNoExpand = FileListBaseNoExpand;  // あとでフリーすること\r
525         strncpy_s(remoteFileDir, sizeof(remoteFileDir), TmpDir, _TRUNCATE);\r
526 \r
527 #if 0\r
528         // add temporary list\r
529         if (remoteFileListBase != NULL) {\r
530                 FILELIST *pf = remoteFileListBase;\r
531                 char fn[FMAX_PATH + 1];\r
532                 while (pf) {\r
533                         strncpy_s(fn, sizeof(fn), remoteFileDir, _TRUNCATE);\r
534                         strncat_s(fn, sizeof(fn), "\\", _TRUNCATE);\r
535                         strncat_s(fn, sizeof(fn), pf->File, _TRUNCATE);\r
536                         AddTempFileList(fn);\r
537                         pf = pf->Next;\r
538                 }\r
539         }\r
540 #endif\r
541 }\r
542 \r
543 \r
544 int isDirectory(char *fn)\r
545 {\r
546         struct _stat buf;\r
547 \r
548         if (_stat(fn, &buf) == 0) {\r
549                 if (buf.st_mode & _S_IFDIR) { // is directory\r
550                         return 1;\r
551                 }\r
552         }\r
553         return 0;\r
554 }\r
555 \r
556 // テンポラリのファイルおよびフォルダを削除する。\r
557 void doDeleteRemoteFile(void)\r
558 {\r
559         if (remoteFileListBase != NULL) {\r
560 #if 0\r
561                 int dirs = 0;\r
562                 int i, count;\r
563                 FILELIST *pf = remoteFileListBase;\r
564                 char fn[FMAX_PATH + 1];\r
565                 while (pf) {\r
566                         strncpy_s(fn, sizeof(fn), remoteFileDir, _TRUNCATE);\r
567                         strncat_s(fn, sizeof(fn), "\\", _TRUNCATE);\r
568                         strncat_s(fn, sizeof(fn), pf->File, _TRUNCATE);\r
569                         if (isDirectory(fn)) {\r
570                                 dirs++;\r
571                         } else {\r
572                                 remove(fn);\r
573                         }\r
574                         pf = pf->Next;\r
575                 }\r
576 \r
577                 count = 0;\r
578                 for (i = 0 ; i < 1000 ; i++) {\r
579                         pf = remoteFileListBase;\r
580                         while (pf) {\r
581                                 strncpy_s(fn, sizeof(fn), remoteFileDir, _TRUNCATE);\r
582                                 strncat_s(fn, sizeof(fn), "\\", _TRUNCATE);\r
583                                 strncat_s(fn, sizeof(fn), pf->File, _TRUNCATE);\r
584                                 if (isDirectory(fn)) {\r
585                                         if (_rmdir(fn) == 0) { // ディレクトリを消せたらカウントアップ\r
586                                                 count++;\r
587                                                 if (count >= dirs)  // すべて消せたら終わり\r
588                                                         goto skip;\r
589                                         }\r
590                                 }\r
591                                 pf = pf->Next;\r
592                         }\r
593                 }\r
594 skip:\r
595                 _rmdir(remoteFileDir);  // 自分で作ったディレクトリも消す\r
596 #else\r
597                 SHFILEOPSTRUCT FileOp = { NULL, FO_DELETE, remoteFileDir, NULL, \r
598                         FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI, \r
599                         FALSE, NULL, NULL };    \r
600                 SHFileOperation(&FileOp);\r
601 #endif\r
602 \r
603                 DeleteFileList(&remoteFileListBase);\r
604                 remoteFileListBase = NULL;\r
605         }\r
606 \r
607         if (remoteFileListBaseNoExpand != NULL) {\r
608                 DeleteFileList(&remoteFileListBaseNoExpand);\r
609                 remoteFileListBaseNoExpand = NULL;\r
610         }\r
611 }\r
612 \r
613 \r
614 // yutaka\r
615 // cf. http://www.nakka.com/lib/\r
616 /* ドロップファイルの作成 */\r
617 static HDROP APIPRIVATE CreateDropFileMem(char **FileName,int cnt,BOOL fWide)\r
618 {\r
619         HDROP hDrop;\r
620         LPDROPFILES lpDropFile;\r
621         wchar_t wbuf[BUF_SIZE];\r
622         int flen = 0;\r
623         int i;\r
624         \r
625         if(fWide == TRUE){\r
626                 /* ワイドキャラ */\r
627                 for(i = 0;i < cnt;i++){\r
628                         // UTF-8対応\r
629 //                      MultiByteToWideChar(CP_ACP,0,FileName[i],-1,wbuf,BUF_SIZE);\r
630 //                      flen += (wcslen(wbuf) + 1) * sizeof(wchar_t);\r
631                         flen += sizeof(wchar_t) * MtoW(NULL, 0, FileName[i], -1);\r
632                 }\r
633                 flen++;\r
634         }else{\r
635                 /* マルチバイト */\r
636                 for(i = 0;i < cnt;i++){\r
637                         // UTF-8対応\r
638 //                      flen += lstrlen(FileName[i]) + 1;\r
639                         MtoW(wbuf, BUF_SIZE, FileName[i], -1);\r
640                         flen += sizeof(char) * WtoA(NULL, 0, wbuf, -1);\r
641                 }\r
642         }\r
643 \r
644         hDrop = (HDROP)GlobalAlloc(GHND,sizeof(DROPFILES) + flen + 1);\r
645         if (hDrop == NULL){\r
646                 return NULL;\r
647         }\r
648 \r
649         lpDropFile = (LPDROPFILES) GlobalLock(hDrop);\r
650         lpDropFile->pFiles = sizeof(DROPFILES);         /* ファイル名のリストまでのオフセット */\r
651         lpDropFile->pt.x = 0;\r
652         lpDropFile->pt.y = 0;\r
653         lpDropFile->fNC = FALSE;\r
654         lpDropFile->fWide = fWide;                                      /* ワイドキャラの場合は TRUE */\r
655 \r
656         /* 構造体の後ろにファイル名のリストをコピーする。(ファイル名\0ファイル名\0ファイル名\0\0) */\r
657         if(fWide == TRUE){\r
658                 /* ワイドキャラ */\r
659                 wchar_t *buf;\r
660 \r
661                 buf = (wchar_t *)(&lpDropFile[1]);\r
662                 for(i = 0;i < cnt;i++){\r
663                         // UTF-8対応\r
664 //                      MultiByteToWideChar(CP_ACP,0,FileName[i],-1,wbuf,BUF_SIZE);\r
665 //                      wcscpy(buf,wbuf);\r
666 //                      buf += wcslen(wbuf) + 1;\r
667                         buf += MtoW(buf, BUF_SIZE, FileName[i], -1);\r
668                 }\r
669         }else{\r
670                 /* マルチバイト */\r
671                 char *buf;\r
672 \r
673                 buf = (char *)(&lpDropFile[1]);\r
674                 for(i = 0;i < cnt;i++){\r
675                         // UTF-8対応\r
676 //                      lstrcpy(buf,FileName[i]);\r
677 //                      buf += lstrlen(FileName[i]) + 1;\r
678                         MtoW(wbuf, BUF_SIZE, FileName[i], -1);\r
679                         buf += WtoA(buf, BUF_SIZE, wbuf, -1);\r
680                 }\r
681         }\r
682 \r
683         GlobalUnlock(hDrop);\r
684         return(hDrop);\r
685 }\r
686 \r
687 \r
688 // OLE D&Dを開始する \r
689 // (2007.8.30 yutaka)\r
690 static void doDragDrop(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
691 {\r
692         UINT cf[CF_CNT];\r
693         POINT pt;\r
694         int ret;\r
695 \r
696         // テンポラリをきれいにする (2007.9.3 yutaka)\r
697         doDeleteRemoteFile();\r
698 \r
699         /* ドラッグ&ドロップの開始 */\r
700         cf[0] = CF_HDROP;\r
701         cf[1] = CF_HDROP;       /* ファイル */\r
702         if((ret = OLE_IDropSource_Start(hWnd,WM_GETDATA, WM_DRAGOVER, cf,1,DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK)) == DROPEFFECT_MOVE){\r
703         }\r
704 \r
705         // ドロップ先のアプリに WM_LBUTTONUP を飛ばす。\r
706         GetCursorPos(&pt);\r
707         ScreenToClient(hWnd, &pt);\r
708         PostMessage(hWnd,WM_LBUTTONUP,0,MAKELPARAM(pt.x,pt.y));\r
709 }\r
710 \r
711 \r
712 \r
713 /*----- ファイル一覧ウインドウの共通メッセージ処理 ----------------------------\r
714 *\r
715 *       Parameter\r
716 *               HWND hWnd : ウインドウハンドル\r
717 *               UINT message  : メッセージ番号\r
718 *               WPARAM wParam : メッセージの WPARAM 引数\r
719 *               LPARAM lParam : メッセージの LPARAM 引数\r
720 *\r
721 *       Return Value\r
722 *               メッセージに対応する戻り値\r
723 *----------------------------------------------------------------------------*/\r
724 \r
725 static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
726 {\r
727         POINT Point;\r
728         HWND hWndPnt;\r
729         HWND hWndParent;\r
730         static HCURSOR hCsrDrg;\r
731         static HCURSOR hCsrNoDrg;\r
732         static POINT DragPoint;\r
733         static HWND hWndDragStart;\r
734         static int RemoteDropFileIndex = -1;\r
735         int Win;\r
736         HWND hWndDst;\r
737         WNDPROC ProcPtr;\r
738         HWND hWndHistEdit;\r
739 \r
740         Win = WIN_LOCAL;\r
741         hWndDst = hWndListRemote;\r
742         ProcPtr = LocalProcPtr;\r
743         hWndHistEdit = GetLocalHistEditHwnd();\r
744         if(hWnd == hWndListRemote)\r
745         {\r
746                 Win = WIN_REMOTE;\r
747                 hWndDst = hWndListLocal;\r
748                 ProcPtr = RemoteProcPtr;\r
749                 hWndHistEdit = GetRemoteHistEditHwnd();\r
750         }\r
751 \r
752         switch (message)\r
753         {\r
754         case WM_SYSKEYDOWN:\r
755                         if (wParam == 'D') {    // Alt+D\r
756                                 SetFocus(hWndHistEdit);\r
757                                 break;\r
758                         }\r
759                         EraseListViewTips();\r
760                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
761 \r
762         case WM_KEYDOWN:\r
763                         if(wParam == 0x09)\r
764                         {\r
765                                 SetFocus(hWndDst);\r
766                                 break;\r
767                         }\r
768                         EraseListViewTips();\r
769                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
770 \r
771                 case WM_SETFOCUS :\r
772                         SetFocusHwnd(hWnd);\r
773                         MakeButtonsFocus();\r
774                         DispCurrentWindow(Win);\r
775                         DispSelectedSpace();\r
776                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
777 \r
778                 case WM_KILLFOCUS :\r
779                         EraseListViewTips();\r
780                         MakeButtonsFocus();\r
781                         DispCurrentWindow(-1);\r
782                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
783 \r
784                 case WM_DROPFILES :\r
785                         // ドラッグ中は処理しない。ドラッグ後にWM_LBUTTONDOWNが飛んでくるため、そこで処理する。\r
786                         if (Dragging == YES) \r
787                                 return (FALSE);\r
788 \r
789                         if(hWnd == hWndListRemote)\r
790                         {\r
791                                 if(AskConnecting() == YES)\r
792                                         UpLoadDragProc(wParam);\r
793                         }\r
794                         else if(hWnd == hWndListLocal)\r
795                         {\r
796                                 ChangeDirDropFileProc(wParam);\r
797                         }\r
798                         break;\r
799 \r
800                 case WM_LBUTTONDOWN :\r
801                         EraseListViewTips();\r
802                         SetFocus(hWnd);\r
803                         DragPoint.x = LOWORD(lParam);\r
804                         DragPoint.y = HIWORD(lParam);\r
805                         hWndDragStart = hWnd;\r
806                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
807                         break;\r
808 \r
809                 case WM_LBUTTONUP :\r
810                         if(Dragging == YES)\r
811                         {\r
812                                 Dragging = NO;\r
813                                 ReleaseCapture();\r
814                                 hCsrDrg = LoadCursor(NULL, IDC_ARROW);\r
815                                 SetCursor(hCsrDrg);\r
816 \r
817                                 Point.x = (long)(short)LOWORD(lParam);\r
818                                 Point.y = (long)(short)HIWORD(lParam);\r
819                                 ClientToScreen(hWnd, &Point);\r
820                                 hWndPnt = WindowFromPoint(Point);\r
821                                 if(hWndPnt == hWndDst)  // local <-> remote \r
822                                 {\r
823                                         if(hWndPnt == hWndListRemote) {\r
824                                                 PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_UPLOAD, 0), 0);\r
825                                         } else if(hWndPnt == hWndListLocal) {\r
826                                                 PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
827                                         }\r
828                                 } else { // 同一ウィンドウ内の場合 (yutaka)\r
829                                         if (hWndDragStart == hWndListRemote && hWndPnt == hWndListRemote) {\r
830                                                 // remote <-> remoteの場合は、サーバでのファイルの移動を行う。(2007.9.5 yutaka)\r
831                                                 if (RemoteDropFileIndex != -1) {\r
832                                                         ListView_SetItemState(hWnd, RemoteDropFileIndex, 0, LVIS_DROPHILITED);\r
833                                                         MoveRemoteFileProc(RemoteDropFileIndex);\r
834                                                 }\r
835 \r
836                                         }\r
837 \r
838                                 }\r
839                         }\r
840                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
841 \r
842                 case WM_DRAGDROP:  \r
843                         // OLE D&Dを開始する (yutaka)\r
844                         doDragDrop(hWnd, message, wParam, lParam);\r
845                         return (TRUE);\r
846                         break;\r
847  \r
848                 case WM_GETDATA:  // ファイルのパスをD&D先のアプリへ返す (yutaka)\r
849                         switch(wParam)\r
850                         {\r
851                         case CF_HDROP:          /* ファイル */\r
852                                 {\r
853                                         OSVERSIONINFO os_info;\r
854                                         BOOL NTFlag = FALSE;\r
855                                         char **FileNameList;\r
856                                         int filelen;\r
857                                         int i, j, filenum = 0;\r
858  \r
859                                         FILELIST *FileListBase, *FileListBaseNoExpand, *pf;\r
860                                         int CancelFlg = NO;\r
861                                         char LocDir[FMAX_PATH+1];\r
862                                         char *PathDir;\r
863  \r
864                                         // 変数が未初期化のバグ修正\r
865                                         FileListBaseNoExpand = NULL;\r
866                                         // ローカル側で選ばれているファイルをFileListBaseに登録\r
867                                         if (hWndDragStart == hWndListLocal) {\r
868                                                 AskLocalCurDir(LocDir, FMAX_PATH);\r
869                                                 PathDir = LocDir;\r
870  \r
871                                                 FileListBase = NULL;\r
872                                                 // ローカル側からアプリケーションにD&Dできないバグ修正\r
873 //                                              MakeSelectedFileList(WIN_LOCAL, YES, NO, &FileListBase, &CancelFlg);                    \r
874                                                 MakeSelectedFileList(WIN_LOCAL, NO, NO, &FileListBase, &CancelFlg);                     \r
875                                                 FileListBaseNoExpand = FileListBase;\r
876  \r
877                                         } else if (hWndDragStart == hWndListRemote) {\r
878                                                 GetCursorPos(&Point);\r
879                                                 hWndPnt = WindowFromPoint(Point);\r
880                                                 hWndParent = GetParent(hWndPnt);\r
881                                                 if (hWndPnt == hWndListRemote || hWndPnt == hWndListLocal ||\r
882                                                         hWndParent == hWndListRemote || hWndParent == hWndListLocal) {\r
883                                                         FileListBase = NULL;\r
884  \r
885                                                 } else {\r
886                                                         // 選択されているリモートファイルのリストアップ\r
887                                                         // このタイミングでリモートからローカルの一時フォルダへダウンロードする\r
888                                                         // (2007.8.31 yutaka)\r
889                                                         doTransferRemoteFile();\r
890                                                         PathDir = remoteFileDir;\r
891                                                         FileListBase = remoteFileListBase;\r
892                                                         FileListBaseNoExpand = remoteFileListBaseNoExpand;\r
893                                                 }\r
894  \r
895                                         } \r
896  \r
897                                         pf = FileListBaseNoExpand;\r
898                                         for (filenum = 0; pf ; filenum++) {\r
899                                                 pf = pf->Next;\r
900                                         }\r
901                                         // ファイルが未選択の場合は何もしない。(yutaka)\r
902                                         if (filenum <= 0) {\r
903                                                 *((HANDLE *)lParam) = NULL;\r
904                                                 return (FALSE);\r
905                                         }\r
906                                         \r
907                                         /* ファイル名の配列を作成する */\r
908                                         // TODO: GlobalAllocが返すのはメモリポインタではなくハンドルだが実際は同じ値\r
909                                         FileNameList = (char **)GlobalAlloc(GPTR,sizeof(char *) * filenum);\r
910                                         if(FileNameList == NULL){\r
911                                                 abort();\r
912                                         }\r
913                                         pf = FileListBaseNoExpand;\r
914                                         for (j = 0; pf ; j++) {\r
915                                                 filelen = strlen(PathDir) + 1 + strlen(pf->File) + 1;\r
916                                                 FileNameList[j] = (char *)GlobalAlloc(GPTR, filelen);\r
917                                                 strncpy_s(FileNameList[j], filelen, PathDir, _TRUNCATE);\r
918                                                 strncat_s(FileNameList[j], filelen, "\\", _TRUNCATE);\r
919                                                 strncat_s(FileNameList[j], filelen, pf->File, _TRUNCATE);\r
920                                                 pf = pf->Next;\r
921 #if 0\r
922                                                 if (FileListBase->Node == NODE_DIR) { \r
923                                                         // フォルダを掴んだ場合はそれ以降展開しない\r
924                                                         filenum = 1;\r
925                                                         break;\r
926                                                 }\r
927 #endif\r
928                                         }\r
929                                         \r
930                                         os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\r
931                                         GetVersionEx(&os_info);\r
932                                         if(os_info.dwPlatformId == VER_PLATFORM_WIN32_NT){\r
933                                                 NTFlag = TRUE;\r
934                                         }\r
935  \r
936                                         /* ドロップファイルリストの作成 */\r
937                                         /* NTの場合はUNICODEになるようにする */\r
938                                         *((HANDLE *)lParam) = CreateDropFileMem(FileNameList, filenum, NTFlag);\r
939  \r
940                                         /* ファイル名の配列を解放する */\r
941                                         for (i = 0; i < filenum ; i++) {\r
942                                                 GlobalFree(FileNameList[i]);\r
943                                         }\r
944                                         GlobalFree(FileNameList);\r
945  \r
946                                         if (hWndDragStart == hWndListLocal) {\r
947                                                 DeleteFileList(&FileListBase);\r
948                                         } else {\r
949                                                 // あとでファイル削除してフリーする\r
950                                         }\r
951  \r
952                                         return (TRUE);\r
953                                 }\r
954                                 break;\r
955  \r
956                         default:\r
957                                 *((HANDLE *)lParam) = NULL;\r
958                                 break;\r
959                         }\r
960  \r
961                         break;\r
962 \r
963                 case WM_DRAGOVER:\r
964                         {\r
965                                 LVHITTESTINFO hi;\r
966                                 int Node, index;\r
967                                 static int prev_index = -1;\r
968 \r
969                                 // 同一ウィンドウ内でのD&Dはリモート側のみ\r
970                                 if (Win != WIN_REMOTE)\r
971                                         break;\r
972 \r
973                                 if(MoveMode == MOVE_DISABLE)\r
974                                         break;\r
975 \r
976                                 memset(&hi, 0, sizeof(hi));\r
977 \r
978                                 GetCursorPos(&Point);\r
979                                 hWndPnt = WindowFromPoint(Point);\r
980                                 ScreenToClient(hWnd, &Point);\r
981 \r
982                                 hi.pt = Point;\r
983 \r
984                                 // 以前の選択を消す\r
985                                 ListView_SetItemState(hWnd, prev_index, 0, LVIS_DROPHILITED);\r
986                                 RemoteDropFileIndex = -1;\r
987 \r
988                                 if ((hWndPnt == hWndListRemote) && (ListView_HitTest(hWnd, &hi) != -1)) {\r
989                                         if (hi.flags == LVHT_ONITEMLABEL) { // The position is over a list-view item's text.\r
990                                         \r
991                                                 index = hi.iItem;\r
992                                                 prev_index = index;\r
993                                                 Node = GetNodeType(Win, index);\r
994                                                 if (Node == NODE_DIR) {\r
995                                                         ListView_SetItemState(hWnd, index, LVIS_DROPHILITED, LVIS_DROPHILITED);\r
996                                                         RemoteDropFileIndex = index;\r
997                                                 }\r
998                                         }\r
999                                 } \r
1000 \r
1001                         }\r
1002                         break;\r
1003 \r
1004                 case WM_RBUTTONDOWN :\r
1005                         /* ここでファイルを選ぶ */\r
1006                         CallWindowProc(ProcPtr, hWnd, message, wParam, lParam);\r
1007 \r
1008                         EraseListViewTips();\r
1009                         SetFocus(hWnd);\r
1010                         if(hWnd == hWndListRemote)\r
1011                                 RemoteRbuttonMenu(0);\r
1012                         else if(hWnd == hWndListLocal)\r
1013                                 LocalRbuttonMenu(0);\r
1014                         break;\r
1015 \r
1016                 case WM_LBUTTONDBLCLK :\r
1017                         DoubleClickProc(Win, NO, -1);\r
1018                         break;\r
1019 \r
1020                 case WM_MOUSEMOVE :\r
1021                         if(wParam == MK_LBUTTON)\r
1022                         {\r
1023                                 if((Dragging == NO) && \r
1024                                    (hWnd == hWndDragStart) &&\r
1025                                    (AskConnecting() == YES) &&\r
1026                                    (SendMessage(hWnd, LVM_GETSELECTEDCOUNT, 0, 0) > 0) &&\r
1027                                    ((abs((short)LOWORD(lParam) - DragPoint.x) > 5) ||\r
1028                                         (abs((short)HIWORD(lParam) - DragPoint.y) > 5)))\r
1029                                 {\r
1030                                         SetCapture(hWnd);\r
1031                                         Dragging = YES;\r
1032                                         hCsrDrg = LoadCursor(GetFtpInst(), MAKEINTRESOURCE(drag_csr));\r
1033                                         hCsrNoDrg = LoadCursor(GetFtpInst(), MAKEINTRESOURCE(nodrop_csr));\r
1034                                         SetCursor(hCsrDrg);\r
1035                                 }\r
1036                                 else if(Dragging == YES)\r
1037                                 {\r
1038                                         Point.x = (long)(short)LOWORD(lParam);\r
1039                                         Point.y = (long)(short)HIWORD(lParam);\r
1040                                         ClientToScreen(hWnd, &Point);\r
1041                                         hWndPnt = WindowFromPoint(Point);\r
1042                                         if((hWndPnt == hWndListRemote) || (hWndPnt == hWndListLocal))\r
1043                                                 SetCursor(hCsrDrg);\r
1044                                         else {\r
1045                                                 // マウスポインタの×表示をやめる (yutaka)\r
1046 #if 0\r
1047                                                 SetCursor(hCsrNoDrg);\r
1048 #endif\r
1049                                         }\r
1050 \r
1051                                         // OLE D&Dの開始を指示する\r
1052                                         PostMessage(hWnd, WM_DRAGDROP, MAKEWPARAM(wParam, lParam), 0);\r
1053 \r
1054                                 }\r
1055                                 else\r
1056                                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
1057                         }\r
1058                         else\r
1059                         {\r
1060                                 CheckTipsDisplay(hWnd, lParam);\r
1061                                 return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
1062                         }\r
1063                         break;\r
1064 \r
1065                 case WM_MOUSEWHEEL :\r
1066                         if(Dragging == NO)\r
1067                         {\r
1068                 short zDelta = (short)HIWORD(wParam);\r
1069 \r
1070                                 EraseListViewTips();\r
1071                                 Point.x = (short)LOWORD(lParam);\r
1072                                 Point.y = (short)HIWORD(lParam);\r
1073                                 hWndPnt = WindowFromPoint(Point);\r
1074 \r
1075                                 if((wParam & MAKEWPARAM(MK_SHIFT, 0)) && \r
1076                                    ((hWndPnt == hWndListRemote) ||\r
1077                                         (hWndPnt == hWndListLocal) || \r
1078                                         (hWndPnt == GetTaskWnd())))\r
1079                                 {\r
1080                                         PostMessage(hWndPnt, WM_VSCROLL, zDelta > 0 ? MAKEWPARAM(SB_PAGEUP, 0) : MAKEWPARAM(SB_PAGEDOWN, 0), 0);\r
1081 //                                      PostMessage(hWndPnt, WM_VSCROLL, MAKEWPARAM(SB_ENDSCROLL, 0), 0);\r
1082                                 }\r
1083                                 else if(hWndPnt == hWnd)\r
1084                                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
1085                                 else if((hWndPnt == hWndDst) || (hWndPnt == GetTaskWnd()))\r
1086                                         PostMessage(hWndPnt, message, wParam, lParam);\r
1087                         }\r
1088                         break;\r
1089 \r
1090                 default :\r
1091                         return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
1092         }\r
1093     return(0L);\r
1094 }\r
1095 \r
1096 \r
1097 /*----- ファイルリストのタブ幅を取得する --------------------------------------\r
1098 *\r
1099 *       Parameter\r
1100 *               なし\r
1101 *\r
1102 *       Return Value\r
1103 *               なし\r
1104 *----------------------------------------------------------------------------*/\r
1105 \r
1106 void GetListTabWidth(void)\r
1107 {\r
1108         LV_COLUMN LvCol;\r
1109         int i;\r
1110 \r
1111         for(i = 0; i <= 3; i++)\r
1112         {\r
1113                 LvCol.mask = LVCF_WIDTH;\r
1114                 if(SendMessage(hWndListLocal, LVM_GETCOLUMN, i, (LPARAM)&LvCol) == TRUE)\r
1115                         LocalTabWidth[i] = LvCol.cx;\r
1116         }\r
1117 \r
1118         for(i = 0; i <= 5; i++)\r
1119         {\r
1120                 LvCol.mask = LVCF_WIDTH;\r
1121                 if(SendMessage(hWndListRemote, LVM_GETCOLUMN, i, (LPARAM)&LvCol) == TRUE)\r
1122                         RemoteTabWidth[i] = LvCol.cx;\r
1123         }\r
1124         return;\r
1125 }\r
1126 \r
1127 \r
1128 /*----- ファイル一覧方法にしたがってリストビューを設定する --------------------\r
1129 *\r
1130 *       Parameter\r
1131 *               なし\r
1132 *\r
1133 *       Return Value\r
1134 *               なし\r
1135 *----------------------------------------------------------------------------*/\r
1136 \r
1137 void SetListViewType(void)\r
1138 {\r
1139         // 64ビット対応\r
1140 //      long lStyle;\r
1141         LONG_PTR lStyle;\r
1142 \r
1143         switch(ListType)\r
1144         {\r
1145                 case LVS_LIST :\r
1146                         // 64ビット対応\r
1147 //                      lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE);\r
1148                         lStyle = GetWindowLongPtr(GetLocalHwnd(), GWL_STYLE);\r
1149                         lStyle &= ~(LVS_REPORT | LVS_LIST);\r
1150                         lStyle |= LVS_LIST;\r
1151                         // 64ビット対応\r
1152 //                      SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle);\r
1153                         SetWindowLongPtr(GetLocalHwnd(), GWL_STYLE, lStyle);\r
1154 \r
1155                         // 64ビット対応\r
1156 //                      lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE);\r
1157                         lStyle = GetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE);\r
1158                         lStyle &= ~(LVS_REPORT | LVS_LIST);\r
1159                         lStyle |= LVS_LIST;\r
1160                         // 64ビット対応\r
1161 //                      SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
1162                         SetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
1163                         break;\r
1164 \r
1165                 default :\r
1166                         // 64ビット対応\r
1167 //                      lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE);\r
1168                         lStyle = GetWindowLongPtr(GetLocalHwnd(), GWL_STYLE);\r
1169                         lStyle &= ~(LVS_REPORT | LVS_LIST);\r
1170                         lStyle |= LVS_REPORT;\r
1171                         // 64ビット対応\r
1172 //                      SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle);\r
1173                         SetWindowLongPtr(GetLocalHwnd(), GWL_STYLE, lStyle);\r
1174 \r
1175                         // 64ビット対応\r
1176 //                      lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE);\r
1177                         lStyle = GetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE);\r
1178                         lStyle &= ~(LVS_REPORT | LVS_LIST);\r
1179                         lStyle |= LVS_REPORT;\r
1180                         // 64ビット対応\r
1181 //                      SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
1182                         SetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
1183                         break;\r
1184         }\r
1185         return;\r
1186 }\r
1187 \r
1188 \r
1189 /*----- ホスト側のファイル一覧ウインドウにファイル名をセット ------------------\r
1190 *\r
1191 *       Parameter\r
1192 *               int Mode : キャッシュモード (CACHE_xxx)\r
1193 *\r
1194 *       Return Value\r
1195 *               なし\r
1196 *----------------------------------------------------------------------------*/\r
1197 \r
1198 void GetRemoteDirForWnd(int Mode, int *CancelCheckWork)\r
1199 {\r
1200         FILE *fd;\r
1201         LONGLONG Size;\r
1202         char Str[FMAX_PATH+1];\r
1203         char Buf[FMAX_PATH+1];\r
1204         FILETIME Time;\r
1205         int Attr;\r
1206         int Type;\r
1207         int ListType;\r
1208         int Num;\r
1209         FLISTANCHOR Anchor;\r
1210         char Owner[OWNER_NAME_LEN+1];\r
1211         int Link;\r
1212         int InfoExist;\r
1213 \r
1214 //#pragma aaa\r
1215 //DoPrintf("===== GetRemoteDirForWnd");\r
1216 \r
1217         Anchor.Top = NULL;\r
1218         Anchor.Files = 0;\r
1219 \r
1220         if(AskConnecting() == YES)\r
1221         {\r
1222 //              SetCursor(LoadCursor(NULL, IDC_WAIT));\r
1223                 DisableUserOpe();\r
1224 \r
1225                 AskRemoteCurDir(Buf, FMAX_PATH);\r
1226                 SetRemoteDirHist(Buf);\r
1227 \r
1228                 Type = FTP_COMPLETE;\r
1229                 if(Mode != CACHE_LASTREAD)\r
1230                 {\r
1231 \r
1232                         if((Num = AskCached(Buf)) == -1)\r
1233                         {\r
1234                                 Num = AskFreeCache();\r
1235                                 Mode = CACHE_REFRESH;\r
1236                         }\r
1237 \r
1238                         if(Mode == CACHE_REFRESH)\r
1239                         {\r
1240                                 if((Type = DoDirListCmdSkt("", "", Num, CancelCheckWork)) == FTP_COMPLETE)\r
1241                                         SetCache(Num, Buf);\r
1242                                 else\r
1243                                         ClearCache(Num);\r
1244                         }\r
1245                 }\r
1246                 else\r
1247                         Num = AskCurrentFileListNum();\r
1248 \r
1249                 if(Type == FTP_COMPLETE)\r
1250                 {\r
1251                         SetCurrentFileListNum(Num);\r
1252                         MakeCacheFileName(Num, Buf);\r
1253                         if((fd = fopen(Buf, "rb"))!=NULL)\r
1254                         {\r
1255                                 ListType = LIST_UNKNOWN;\r
1256 \r
1257                                 while(GetListOneLine(Str, FMAX_PATH, fd) == FFFTP_SUCCESS)\r
1258                                 {\r
1259                                         if((ListType = AnalizeFileInfo(Str)) != LIST_UNKNOWN)\r
1260                                         {\r
1261                                                 if((Type = ResolvFileInfo(Str, ListType, Buf, &Size, &Time, &Attr, Owner, &Link, &InfoExist)) != NODE_NONE)\r
1262                                                 {\r
1263                                                         if(AskFilterStr(Buf, Type) == YES)\r
1264                                                         {\r
1265                                                                 if((DotFile == YES) || (Buf[0] != '.'))\r
1266                                                                 {\r
1267                                                                         AddDispFileList(&Anchor, Buf, &Time, Size, Attr, Type, Link, Owner, InfoExist, WIN_REMOTE);\r
1268                                                                 }\r
1269                                                         }\r
1270                                                 }\r
1271                                         }\r
1272                                 }\r
1273                                 fclose(fd);\r
1274 \r
1275                                 DispFileList2View(GetRemoteHwnd(), &Anchor);\r
1276                                 EraseDispFileList(&Anchor);\r
1277 \r
1278                                 // 先頭のアイテムを選択\r
1279                                 ListView_SetItemState(GetRemoteHwnd(), 0, LVIS_FOCUSED, LVIS_FOCUSED);\r
1280                         }\r
1281                         else\r
1282                         {\r
1283                                 SetTaskMsg(MSGJPN048);\r
1284                                 SendMessage(GetRemoteHwnd(), LVM_DELETEALLITEMS, 0, 0);\r
1285                         }\r
1286                 }\r
1287                 else\r
1288                 {\r
1289 #if defined(HAVE_OPENVMS)\r
1290                         /* OpenVMSの場合空ディレクトリ移動の時に出るので、メッセージだけ出さない\r
1291                          * ようにする(VIEWはクリアして良い) */\r
1292                         if (AskHostType() != HTYPE_VMS)\r
1293 #endif\r
1294                         SetTaskMsg(MSGJPN049);\r
1295                         SendMessage(GetRemoteHwnd(), LVM_DELETEALLITEMS, 0, 0);\r
1296                 }\r
1297 \r
1298 //              SetCursor(LoadCursor(NULL, IDC_ARROW));\r
1299                 EnableUserOpe();\r
1300 \r
1301         }\r
1302 \r
1303 //#pragma aaa\r
1304 //DoPrintf("===== GetRemoteDirForWnd Done");\r
1305 \r
1306         return;\r
1307 }\r
1308 \r
1309 \r
1310 /*----- ローカル側のファイル一覧ウインドウにファイル名をセット ----------------\r
1311 *\r
1312 *       Parameter\r
1313 *               なし\r
1314 *\r
1315 *       Return Value\r
1316 *               なし\r
1317 *----------------------------------------------------------------------------*/\r
1318 \r
1319 void GetLocalDirForWnd(void)\r
1320 {\r
1321         HANDLE fHnd;\r
1322         WIN32_FIND_DATA Find;\r
1323         char Scan[FMAX_PATH+1];\r
1324         char *Pos;\r
1325         char Buf[10];\r
1326         FILETIME Time;\r
1327         FLISTANCHOR Anchor;\r
1328         DWORD NoDrives;\r
1329         int Tmp;\r
1330 \r
1331         Anchor.Top = NULL;\r
1332         Anchor.Files = 0;\r
1333 \r
1334         DoLocalPWD(Scan);\r
1335         SetLocalDirHist(Scan);\r
1336         DispLocalFreeSpace(Scan);\r
1337 \r
1338         /* ディレクトリ/ファイル */\r
1339 \r
1340         SetYenTail(Scan);\r
1341         strcat(Scan, "*");\r
1342         if((fHnd = FindFirstFileAttr(Scan, &Find, DispIgnoreHide)) != INVALID_HANDLE_VALUE)\r
1343         {\r
1344                 do\r
1345                 {\r
1346                         if((strcmp(Find.cFileName, ".") != 0) &&\r
1347                            (strcmp(Find.cFileName, "..") != 0))\r
1348                         {\r
1349                                 if((DotFile == YES) || (Find.cFileName[0] != '.'))\r
1350                                 {\r
1351                                         if(Find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)\r
1352                                                 AddDispFileList(&Anchor, Find.cFileName, &Find.ftLastWriteTime, MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow), 0, NODE_DIR, NO, "", FINFO_ALL, WIN_LOCAL);\r
1353                                         else\r
1354                                         {\r
1355                                                 if(AskFilterStr(Find.cFileName, NODE_FILE) == YES)\r
1356                                                 {\r
1357                                                         AddDispFileList(&Anchor, Find.cFileName, &Find.ftLastWriteTime, MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow), 0, NODE_FILE, NO, "", FINFO_ALL, WIN_LOCAL);\r
1358                                                 }\r
1359                                         }\r
1360                                 }\r
1361                         }\r
1362                 }\r
1363                 while(FindNextFileAttr(fHnd, &Find, DispIgnoreHide) == TRUE);\r
1364                 FindClose(fHnd);\r
1365         }\r
1366 \r
1367         /* ドライブ */\r
1368         if(DispDrives)\r
1369         {\r
1370                 GetLogicalDriveStrings(FMAX_PATH, Scan);\r
1371                 NoDrives = LoadHideDriveListRegistory();\r
1372 \r
1373                 Pos = Scan;\r
1374                 while(*Pos != NUL)\r
1375                 {\r
1376                         Tmp = toupper(*Pos) - 'A';\r
1377                         if((NoDrives & (0x00000001 << Tmp)) == 0)\r
1378                         {\r
1379                                 sprintf(Buf, "%s", Pos);\r
1380                                 memset(&Time, 0, sizeof(FILETIME));\r
1381                                 AddDispFileList(&Anchor, Buf, &Time, 0, 0, NODE_DRIVE, NO, "", FINFO_ALL, WIN_LOCAL);\r
1382                         }\r
1383                         Pos = strchr(Pos, NUL) + 1;\r
1384                 }\r
1385         }\r
1386 \r
1387         DispFileList2View(GetLocalHwnd(), &Anchor);\r
1388         EraseDispFileList(&Anchor);\r
1389 \r
1390         // 先頭のアイテムを選択\r
1391         ListView_SetItemState(GetLocalHwnd(), 0, LVIS_FOCUSED, LVIS_FOCUSED);\r
1392 \r
1393         return;\r
1394 }\r
1395 \r
1396 \r
1397 /*----- ファイル情報をファイル一覧用リストに登録する --------------------------\r
1398 *\r
1399 *       Parameter\r
1400 *               FLISTANCHOR *Anchor : ファイルリストの先頭\r
1401 *               char *Name : ファイル名\r
1402 *               FILETIME *Time : 日付\r
1403 *               LONGLONG Size : サイズ\r
1404 *               int Attr : 属性\r
1405 *               int Type : タイプ (NODE_xxxx)\r
1406 *               int Link : リンクかどうか (YES/NO)\r
1407 *               char *Owner : オーナ名\r
1408 *               int InfoExist : 情報があるかどうか (FINFO_xxx)\r
1409 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
1410 *\r
1411 *       Return Value\r
1412 *               なし\r
1413 *----------------------------------------------------------------------------*/\r
1414 \r
1415 static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LONGLONG Size, int Attr, int Type, int Link, char *Owner, int InfoExist, int Win)\r
1416 {\r
1417         int i;\r
1418         FILELIST *Pos;\r
1419         FILELIST *Prev;\r
1420         FILELIST *New;\r
1421         int FileSort;\r
1422         int DirSort;\r
1423         int Sort;\r
1424         LONGLONG Cmp;\r
1425 \r
1426         FileSort = AskSortType(ITEM_LFILE);\r
1427         DirSort = AskSortType(ITEM_LDIR);\r
1428         if(Win == WIN_REMOTE)\r
1429         {\r
1430                 FileSort = AskSortType(ITEM_RFILE);\r
1431                 DirSort = AskSortType(ITEM_RDIR);\r
1432         }\r
1433 \r
1434         Pos = Anchor->Top;\r
1435         for(i = 0; i < Anchor->Files; i++)\r
1436         {\r
1437                 if((Type == NODE_DIR) && (Pos->Node == NODE_FILE))\r
1438                         break;\r
1439                 if((Type == NODE_FILE) && (Pos->Node == NODE_DRIVE))\r
1440                         break;\r
1441 \r
1442                 if(Type == Pos->Node)\r
1443                 {\r
1444                         if(Type == NODE_DIR)\r
1445                                 Sort = DirSort;\r
1446                         else\r
1447                                 Sort = FileSort;\r
1448 \r
1449                         if((Sort & SORT_GET_ORD) == SORT_ASCENT)\r
1450                         {\r
1451                                 if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
1452                                         ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
1453                                    (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
1454                                         ((Cmp = Size - Pos->Size) < 0)) ||\r
1455                                    (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
1456                                         ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
1457                                 {\r
1458                                         break;\r
1459                                 }\r
1460 \r
1461                                 if(((Sort & SORT_MASK_ORD) == SORT_NAME) || (Cmp == 0))\r
1462                                 {\r
1463                                         if(_mbsicmp(Name, Pos->File) < 0)\r
1464                                                 break;\r
1465                                 }\r
1466                         }\r
1467                         else\r
1468                         {\r
1469                                 if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
1470                                         ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) > 0)) ||\r
1471                                    (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
1472                                         ((Cmp = Size - Pos->Size) > 0)) ||\r
1473                                    (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
1474                                         ((Cmp = CompareFileTime(Time, &Pos->Time)) > 0)))\r
1475                                 {\r
1476                                         break;\r
1477                                 }\r
1478 \r
1479                                 if(((Sort & SORT_MASK_ORD) == SORT_NAME) || (Cmp == 0))\r
1480                                 {\r
1481                                         if(_mbsicmp(Name, Pos->File) > 0)\r
1482                                                 break;\r
1483                                 }\r
1484                         }\r
1485                 }\r
1486                 Prev = Pos;\r
1487                 Pos = Pos->Next;\r
1488         }\r
1489 \r
1490         if((New = malloc(sizeof(FILELIST))) != NULL)\r
1491         {\r
1492                 strcpy(New->File, Name);\r
1493                 New->Node = Type;\r
1494                 New->Link = Link;\r
1495                 New->Size = Size;\r
1496                 New->Attr = Attr;\r
1497                 New->Time = *Time;\r
1498                 strcpy(New->Owner, Owner);\r
1499                 New->InfoExist = InfoExist;\r
1500 \r
1501                 if(Pos == Anchor->Top)\r
1502                 {\r
1503                         New->Next = Anchor->Top;\r
1504                         Anchor->Top = New;\r
1505                 }\r
1506                 else\r
1507                 {\r
1508                         New->Next = Prev->Next;\r
1509                         Prev->Next = New;\r
1510                 }\r
1511                 Anchor->Files += 1;\r
1512         }\r
1513         return;\r
1514 }\r
1515 \r
1516 \r
1517 /*----- ファイル一覧用リストをクリアする --------------------------------------\r
1518 *\r
1519 *       Parameter\r
1520 *               FLISTANCHOR *Anchor : ファイルリストの先頭\r
1521 *\r
1522 *       Return Value\r
1523 *               なし\r
1524 *----------------------------------------------------------------------------*/\r
1525 \r
1526 static void EraseDispFileList(FLISTANCHOR *Anchor)\r
1527 {\r
1528         FILELIST *Pos;\r
1529         FILELIST *Next;\r
1530         int i;\r
1531 \r
1532         Pos = Anchor->Top;\r
1533         for(i = 0; i < Anchor->Files; i++)\r
1534         {\r
1535                 Next = Pos->Next;\r
1536                 free(Pos);\r
1537                 Pos = Next;\r
1538         }\r
1539         Anchor->Files = 0;\r
1540         Anchor->Top = NULL;\r
1541         return;\r
1542 }\r
1543 \r
1544 \r
1545 /*----- ファイル一覧用リストの内容をファイル一覧ウインドウにセット ------------\r
1546 *\r
1547 *       Parameter\r
1548 *               HWND hWnd : ウインドウハンドル\r
1549 *               FLISTANCHOR *Anchor : ファイルリストの先頭\r
1550 *\r
1551 *       Return Value\r
1552 *               なし\r
1553 *----------------------------------------------------------------------------*/\r
1554 \r
1555 static void DispFileList2View(HWND hWnd, FLISTANCHOR *Anchor)\r
1556 {\r
1557         int i;\r
1558         FILELIST *Pos;\r
1559 \r
1560         SendMessage(hWnd, WM_SETREDRAW, (WPARAM)FALSE, 0);\r
1561         SendMessage(hWnd, LVM_DELETEALLITEMS, 0, 0);\r
1562 \r
1563         Pos = Anchor->Top;\r
1564         for(i = 0; i < Anchor->Files; i++)\r
1565         {\r
1566                 AddListView(hWnd, -1, Pos->File, Pos->Node, Pos->Size, &Pos->Time, Pos->Attr, Pos->Owner, Pos->Link, Pos->InfoExist);\r
1567                 Pos = Pos->Next;\r
1568         }\r
1569 \r
1570         SendMessage(hWnd, WM_SETREDRAW, (WPARAM)TRUE, 0);\r
1571         UpdateWindow(hWnd);\r
1572 \r
1573         DispSelectedSpace();\r
1574         return;\r
1575 }\r
1576 \r
1577 \r
1578 /*----- ファイル一覧ウインドウ(リストビュー)に追加 --------------------------\r
1579 *\r
1580 *       Parameter\r
1581 *               HWND hWnd : ウインドウハンドル\r
1582 *               int Pos : 挿入位置\r
1583 *               char *Name : 名前\r
1584 *               int Type : タイプ (NIDE_xxxx)\r
1585 *               LONGLONG Size : サイズ\r
1586 *               FILETIME *Time : 日付\r
1587 *               int Attr : 属性\r
1588 *               char Owner : オーナ名\r
1589 *               int Link : リンクかどうか\r
1590 *               int InfoExist : 情報があるかどうか (FINFO_xxx)\r
1591 *\r
1592 *       Return Value\r
1593 *               なし\r
1594 *----------------------------------------------------------------------------*/\r
1595 \r
1596 static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist)\r
1597 {\r
1598         LV_ITEM LvItem;\r
1599         char Tmp[20];\r
1600 \r
1601         if(Pos == -1)\r
1602                 Pos = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0);\r
1603 \r
1604         /* アイコン/ファイル名 */\r
1605         LvItem.mask = LVIF_TEXT | LVIF_IMAGE;\r
1606         LvItem.iItem = Pos;\r
1607         LvItem.iSubItem = 0;\r
1608         LvItem.pszText = Name;\r
1609         if((Type == NODE_FILE) && (AskTransferTypeAssoc(Name, TYPE_X) == TYPE_I))\r
1610                 Type = 3;\r
1611         if(Link == NO)\r
1612                 LvItem.iImage = Type;\r
1613         else\r
1614                 LvItem.iImage = 4;\r
1615         LvItem.iItem = SendMessage(hWnd, LVM_INSERTITEM, 0, (LPARAM)&LvItem);\r
1616 \r
1617         /* 日付/時刻 */\r
1618         FileTime2TimeString(Time, Tmp, DISPFORM_LEGACY, InfoExist);\r
1619         LvItem.mask = LVIF_TEXT;\r
1620         LvItem.iItem = Pos;\r
1621         LvItem.iSubItem = 1;\r
1622         LvItem.pszText = Tmp;\r
1623         LvItem.iItem = SendMessage(hWnd, LVM_SETITEM, 0, (LPARAM)&LvItem);\r
1624 \r
1625         /* サイズ */\r
1626         if(Type == NODE_DIR)\r
1627                 strcpy(Tmp, "<DIR>");\r
1628         else if(Type == NODE_DRIVE)\r
1629                 strcpy(Tmp, "<DRIVE>");\r
1630         else if(Size >= 0)\r
1631                 MakeNumString(Size, Tmp, TRUE);\r
1632         else\r
1633                 strcpy(Tmp, "");\r
1634         LvItem.mask = LVIF_TEXT;\r
1635         LvItem.iItem = Pos;\r
1636         LvItem.iSubItem = 2;\r
1637         LvItem.pszText = Tmp;\r
1638         LvItem.iItem = SendMessage(hWnd, LVM_SETITEM, 0, (LPARAM)&LvItem);\r
1639 \r
1640         /* 拡張子 */\r
1641         LvItem.mask = LVIF_TEXT;\r
1642         LvItem.iItem = Pos;\r
1643         LvItem.iSubItem = 3;\r
1644         LvItem.pszText = GetFileExt(Name);\r
1645         LvItem.iItem = SendMessage(hWnd, LVM_SETITEM, 0, (LPARAM)&LvItem);\r
1646 \r
1647         if(hWnd == GetRemoteHwnd())\r
1648         {\r
1649                 /* 属性 */\r
1650                 strcpy(Tmp, "");\r
1651                 if(InfoExist & FINFO_ATTR)\r
1652                         AttrValue2String(Attr, Tmp);\r
1653                 LvItem.mask = LVIF_TEXT;\r
1654                 LvItem.iItem = Pos;\r
1655                 LvItem.iSubItem = 4;\r
1656                 LvItem.pszText = Tmp;\r
1657                 LvItem.iItem = SendMessage(hWnd, LVM_SETITEM, 0, (LPARAM)&LvItem);\r
1658 \r
1659                 /* オーナ名 */\r
1660                 LvItem.mask = LVIF_TEXT;\r
1661                 LvItem.iItem = Pos;\r
1662                 LvItem.iSubItem = 5;\r
1663                 LvItem.pszText = Owner;\r
1664                 LvItem.iItem = SendMessage(hWnd, LVM_SETITEM, 0, (LPARAM)&LvItem);\r
1665         }\r
1666         return;\r
1667 }\r
1668 \r
1669 \r
1670 /*----- ファイル名一覧ウインドウをソートし直す --------------------------------\r
1671 *\r
1672 *       Parameter\r
1673 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
1674 *\r
1675 *       Return Value\r
1676 *               なし\r
1677 *----------------------------------------------------------------------------*/\r
1678 \r
1679 void ReSortDispList(int Win, int *CancelCheckWork)\r
1680 {\r
1681         if(Win == WIN_REMOTE)\r
1682                 GetRemoteDirForWnd(CACHE_LASTREAD, CancelCheckWork);\r
1683         else\r
1684                 GetLocalDirForWnd();\r
1685         return;\r
1686 }\r
1687 \r
1688 \r
1689 /*----- ファイル一覧ウインドウのファイルを選択する ----------------------------\r
1690 *\r
1691 *       Parameter\r
1692 *               HWND hWnd : ウインドウハンドル\r
1693 *               int Type : 選択方法 (SELECT_xxx)\r
1694 *\r
1695 *       Return Value\r
1696 *               なし\r
1697 *----------------------------------------------------------------------------*/\r
1698 \r
1699 void SelectFileInList(HWND hWnd, int Type)\r
1700 {\r
1701         int Win;\r
1702         int WinDst;\r
1703         int i;\r
1704         int Num;\r
1705         char RegExp[FMAX_PATH+1];\r
1706         char Name[FMAX_PATH+1];\r
1707         LV_ITEM LvItem;\r
1708         int CsrPos;\r
1709         FILETIME Time1;\r
1710         FILETIME Time2;\r
1711         int Find;\r
1712 \r
1713         Win = WIN_LOCAL;\r
1714         WinDst = WIN_REMOTE;\r
1715         if(hWnd == GetRemoteHwnd())\r
1716         {\r
1717                 Win = WIN_REMOTE;\r
1718                 WinDst = WIN_LOCAL;\r
1719         }\r
1720 \r
1721         Num = GetItemCount(Win);\r
1722         switch(Type)\r
1723         {\r
1724                 case SELECT_ALL :\r
1725                         LvItem.state = 0;\r
1726                         if(GetSelectedCount(Win) <= 1)\r
1727                                 LvItem.state = LVIS_SELECTED;\r
1728                         for(i = 0; i < Num; i++)\r
1729                         {\r
1730                                 if(GetNodeType(Win, i) != NODE_DRIVE)\r
1731                                 {\r
1732                                         LvItem.mask = LVIF_STATE;\r
1733                                         LvItem.iItem = i;\r
1734                                         LvItem.stateMask = LVIS_SELECTED;\r
1735                                         LvItem.iSubItem = 0;\r
1736                                         SendMessage(hWnd, LVM_SETITEMSTATE, i, (LPARAM)&LvItem);\r
1737                                 }\r
1738                         }\r
1739                         break;\r
1740 \r
1741                 case SELECT_REGEXP :\r
1742                         if(((Win == WIN_LOCAL) &&\r
1743                                 (DialogBox(GetFtpInst(), MAKEINTRESOURCE(sel_local_dlg), hWnd, SelectDialogCallBack) == YES)) ||\r
1744                            ((Win == WIN_REMOTE) &&\r
1745                                 (DialogBox(GetFtpInst(), MAKEINTRESOURCE(sel_remote_dlg), hWnd, SelectDialogCallBack) == YES)))\r
1746                         {\r
1747                                 strcpy(RegExp, FindStr);\r
1748 //                              if(FindMode == 0)\r
1749 //                                      WildCard2RegExp(RegExp);\r
1750 \r
1751                                 _mbslwr(RegExp);\r
1752                                 if((FindMode == 0) || (JreCompileStr(RegExp) == TRUE))\r
1753                                 {\r
1754                                         CsrPos = -1;\r
1755                                         for(i = 0; i < Num; i++)\r
1756                                         {\r
1757                                                 GetNodeName(Win, i, Name, FMAX_PATH);\r
1758                                                 Find = FindNameNode(WinDst, Name);\r
1759 \r
1760                                                 _mbslwr(Name);\r
1761                                                 LvItem.state = 0;\r
1762                                                 if(GetNodeType(Win, i) != NODE_DRIVE)\r
1763                                                 {\r
1764                                                         if(((FindMode == 0) && (CheckFname(Name, RegExp) == FFFTP_SUCCESS)) ||\r
1765                                                            ((FindMode != 0) && (JreGetStrMatchInfo(Name, 0) != NULL)))\r
1766                                                         {\r
1767                                                                 LvItem.state = LVIS_SELECTED;\r
1768 \r
1769                                                                 if(Find >= 0)\r
1770                                                                 {\r
1771                                                                         if(IgnoreExist == YES)\r
1772                                                                                 LvItem.state = 0;\r
1773 \r
1774                                                                         if((LvItem.state != 0) && (IgnoreNew == YES))\r
1775                                                                         {\r
1776                                                                                 GetNodeTime(Win, i, &Time1);\r
1777                                                                                 GetNodeTime(WinDst, Find, &Time2);\r
1778                                                                                 if(CompareFileTime(&Time1, &Time2) > 0)\r
1779                                                                                         LvItem.state = 0;\r
1780                                                                         }\r
1781 \r
1782                                                                         if((LvItem.state != 0) && (IgnoreOld == YES))\r
1783                                                                         {\r
1784                                                                                 GetNodeTime(Win, i, &Time1);\r
1785                                                                                 GetNodeTime(WinDst, Find, &Time2);\r
1786                                                                                 if(CompareFileTime(&Time1, &Time2) < 0)\r
1787                                                                                         LvItem.state = 0;\r
1788                                                                         }\r
1789                                                                 }\r
1790                                                         }\r
1791                                                 }\r
1792 \r
1793                                                 if((LvItem.state != 0) && (CsrPos == -1))\r
1794                                                         CsrPos = i;\r
1795 \r
1796                                                 LvItem.mask = LVIF_STATE;\r
1797                                                 LvItem.iItem = i;\r
1798                                                 LvItem.stateMask = LVIS_SELECTED;\r
1799                                                 LvItem.iSubItem = 0;\r
1800                                                 SendMessage(hWnd, LVM_SETITEMSTATE, i, (LPARAM)&LvItem);\r
1801                                         }\r
1802                                         if(CsrPos != -1)\r
1803                                         {\r
1804                                                 LvItem.mask = LVIF_STATE;\r
1805                                                 LvItem.iItem = CsrPos;\r
1806                                                 LvItem.state = LVIS_FOCUSED;\r
1807                                                 LvItem.stateMask = LVIS_FOCUSED;\r
1808                                                 LvItem.iSubItem = 0;\r
1809                                                 SendMessage(hWnd, LVM_SETITEMSTATE, CsrPos, (LPARAM)&LvItem);\r
1810                                                 SendMessage(hWnd, LVM_ENSUREVISIBLE, CsrPos, (LPARAM)TRUE);\r
1811                                         }\r
1812                                 }\r
1813                         }\r
1814                         break;\r
1815         }\r
1816         return;\r
1817 }\r
1818 \r
1819 \r
1820 /*----- 選択ダイアログのコールバック ------------------------------------------\r
1821 *\r
1822 *       Parameter\r
1823 *               HWND hDlg : ウインドウハンドル\r
1824 *               UINT message : メッセージ番号\r
1825 *               WPARAM wParam : メッセージの WPARAM 引数\r
1826 *               LPARAM lParam : メッセージの LPARAM 引数\r
1827 *\r
1828 *       Return Value\r
1829 *               BOOL TRUE/FALSE\r
1830 *----------------------------------------------------------------------------*/\r
1831 \r
1832 // 64ビット対応\r
1833 //static BOOL CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1834 static INT_PTR CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1835 {\r
1836         switch (iMessage)\r
1837         {\r
1838                 case WM_INITDIALOG :\r
1839                         SendDlgItemMessage(hDlg, SEL_FNAME, EM_LIMITTEXT, 40, 0);\r
1840                         SendDlgItemMessage(hDlg, SEL_FNAME, WM_SETTEXT, 0, (LPARAM)FindStr);\r
1841                         SendDlgItemMessage(hDlg, SEL_REGEXP, BM_SETCHECK, FindMode, 0);\r
1842                         SendDlgItemMessage(hDlg, SEL_NOOLD, BM_SETCHECK, IgnoreOld, 0);\r
1843                         SendDlgItemMessage(hDlg, SEL_NONEW, BM_SETCHECK, IgnoreNew, 0);\r
1844                         SendDlgItemMessage(hDlg, SEL_NOEXIST, BM_SETCHECK, IgnoreExist, 0);\r
1845                         return(TRUE);\r
1846 \r
1847                 case WM_COMMAND :\r
1848                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1849                         {\r
1850                                 case IDOK :\r
1851                                         SendDlgItemMessage(hDlg, SEL_FNAME, WM_GETTEXT, 40+1, (LPARAM)FindStr);\r
1852                                         FindMode = SendDlgItemMessage(hDlg, SEL_REGEXP, BM_GETCHECK, 0, 0);\r
1853                                         IgnoreOld = SendDlgItemMessage(hDlg, SEL_NOOLD, BM_GETCHECK, 0, 0);\r
1854                                         IgnoreNew = SendDlgItemMessage(hDlg, SEL_NONEW, BM_GETCHECK, 0, 0);\r
1855                                         IgnoreExist = SendDlgItemMessage(hDlg, SEL_NOEXIST, BM_GETCHECK, 0, 0);\r
1856                                         EndDialog(hDlg, YES);\r
1857                                         break;\r
1858 \r
1859                                 case IDCANCEL :\r
1860                                         EndDialog(hDlg, NO);\r
1861                                         break;\r
1862 \r
1863                                 case IDHELP :\r
1864                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000061);\r
1865                                         break;\r
1866                         }\r
1867             return(TRUE);\r
1868         }\r
1869         return(FALSE);\r
1870 }\r
1871 \r
1872 \r
1873 /*----- ファイル一覧ウインドウのファイルを検索する ----------------------------\r
1874 *\r
1875 *       Parameter\r
1876 *               HWND hWnd : ウインドウハンドル\r
1877 *               int Type : 検索方法 (FIND_xxx)\r
1878 *\r
1879 *       Return Value\r
1880 *               なし\r
1881 *----------------------------------------------------------------------------*/\r
1882 \r
1883 void FindFileInList(HWND hWnd, int Type)\r
1884 {\r
1885         int Win;\r
1886         int i;\r
1887         int Num;\r
1888         static char RegExp[FMAX_PATH+1] = { "" };\r
1889         char Name[FMAX_PATH+1];\r
1890         LV_ITEM LvItem;\r
1891         char *Title;\r
1892 \r
1893         Win = WIN_LOCAL;\r
1894         Title = MSGJPN050;\r
1895         if(hWnd == GetRemoteHwnd())\r
1896         {\r
1897                 Win = WIN_REMOTE;\r
1898                 Title = MSGJPN051;\r
1899         }\r
1900 \r
1901         Num = GetItemCount(Win);\r
1902         switch(Type)\r
1903         {\r
1904                 case FIND_FIRST :\r
1905                         if(InputDialogBox(find_dlg, hWnd, Title, FindStr, 40+1, &FindMode, IDH_HELP_TOPIC_0000001) == YES)\r
1906                         {\r
1907                                 strcpy(RegExp, FindStr);\r
1908 //                              if(FindMode == 0)\r
1909 //                                      WildCard2RegExp(RegExp);\r
1910 \r
1911                                 _mbslwr(RegExp);\r
1912                                 if((FindMode == 0) || (JreCompileStr(RegExp) == TRUE))\r
1913                                 {\r
1914                                         for(i = GetCurrentItem(Win)+1; i < Num; i++)\r
1915                                         {\r
1916                                                 GetNodeName(Win, i, Name, FMAX_PATH);\r
1917                                                 _mbslwr(Name);\r
1918 \r
1919                                                 LvItem.state = 0;\r
1920                                                 if(((FindMode == 0) && (CheckFname(Name, RegExp) == FFFTP_SUCCESS)) ||\r
1921                                                    ((FindMode != 0) && (JreGetStrMatchInfo(Name, 0) != NULL)))\r
1922                                                 {\r
1923                                                         LvItem.mask = LVIF_STATE;\r
1924                                                         LvItem.iItem = i;\r
1925                                                         LvItem.state = LVIS_FOCUSED;\r
1926                                                         LvItem.stateMask = LVIS_FOCUSED;\r
1927                                                         LvItem.iSubItem = 0;\r
1928                                                         SendMessage(hWnd, LVM_SETITEMSTATE, i, (LPARAM)&LvItem);\r
1929                                                         SendMessage(hWnd, LVM_ENSUREVISIBLE, i, (LPARAM)TRUE);\r
1930                                                         break;\r
1931                                                 }\r
1932                                         }\r
1933                                 }\r
1934                         }\r
1935                         break;\r
1936 \r
1937                 case FIND_NEXT :\r
1938                         for(i = GetCurrentItem(Win)+1; i < Num; i++)\r
1939                         {\r
1940                                 GetNodeName(Win, i, Name, FMAX_PATH);\r
1941                                 _mbslwr(Name);\r
1942 \r
1943                                 LvItem.state = 0;\r
1944                                 if(((FindMode == 0) && (CheckFname(Name, RegExp) == FFFTP_SUCCESS)) ||\r
1945                                    ((FindMode != 0) && (JreGetStrMatchInfo(Name, 0) != NULL)))\r
1946                                 {\r
1947                                         LvItem.mask = LVIF_STATE;\r
1948                                         LvItem.iItem = i;\r
1949                                         LvItem.state = LVIS_FOCUSED;\r
1950                                         LvItem.stateMask = LVIS_FOCUSED;\r
1951                                         LvItem.iSubItem = 0;\r
1952                                         SendMessage(hWnd, LVM_SETITEMSTATE, i, (LPARAM)&LvItem);\r
1953                                         SendMessage(hWnd, LVM_ENSUREVISIBLE, i, (LPARAM)TRUE);\r
1954                                         break;\r
1955                                 }\r
1956                         }\r
1957                         break;\r
1958         }\r
1959         return;\r
1960 }\r
1961 \r
1962 \r
1963 #if 0\r
1964 /*----- ワイルドカードを正規表現に変換する ------------------------------------\r
1965 *\r
1966 *       Parameter\r
1967 *               char *Str : 文字列\r
1968 *\r
1969 *       Return Value\r
1970 *               なし\r
1971 *----------------------------------------------------------------------------*/\r
1972 \r
1973 void WildCard2RegExp(char *Str)\r
1974 {\r
1975         char Tmp[FMAX_PATH+1];\r
1976         char *Org;\r
1977         char *Pos;\r
1978         UINT Ch;\r
1979 \r
1980         Org = Str;\r
1981         Pos = Tmp;\r
1982 \r
1983         *Pos++ = '^';\r
1984         *Pos++ = '(';\r
1985         while(*Str != NUL)\r
1986         {\r
1987                 if(Pos >= Tmp + FMAX_PATH - 3)\r
1988                         break;\r
1989 \r
1990                 Ch = _mbsnextc(Str);\r
1991                 Str = _mbsinc(Str);\r
1992 \r
1993                 if(Ch <= 0x7F)\r
1994                 {\r
1995                         if(strchr("[]()^$.+", Ch) != NULL)\r
1996                         {\r
1997                                 *Pos++ = '\\';\r
1998                                 *Pos++ = Ch;\r
1999                         }\r
2000                         else if(Ch == '*')\r
2001                         {\r
2002                                 *Pos++ = '.';\r
2003                                 *Pos++ = '*';\r
2004                         }\r
2005                         else if(Ch == '?')\r
2006                                 *Pos++ = '.';\r
2007                         else if(Ch == '|')\r
2008                         {\r
2009                                 *Pos++ = '|';\r
2010                         }\r
2011                         else\r
2012                                 *Pos++ = Ch;\r
2013                 }\r
2014                 else\r
2015                 {\r
2016                         _mbsnset(Pos, Ch, 1);\r
2017                         Pos = _mbsinc(Pos);\r
2018                 }\r
2019         }\r
2020         *Pos++ = ')';\r
2021         *Pos++ = '$';\r
2022         *Pos = NUL;\r
2023         strcpy(Org, Tmp);\r
2024 \r
2025         return;\r
2026 }\r
2027 #endif\r
2028 \r
2029 \r
2030 /*----- カーソル位置のアイテム番号を返す --------------------------------------\r
2031 *\r
2032 *       Parameter\r
2033 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
2034 *\r
2035 *       Return Value\r
2036 *               int アイテム番号\r
2037 *----------------------------------------------------------------------------*/\r
2038 \r
2039 int GetCurrentItem(int Win)\r
2040 {\r
2041         HWND hWnd;\r
2042         int Ret;\r
2043 \r
2044         hWnd = GetLocalHwnd();\r
2045         if(Win == WIN_REMOTE)\r
2046                 hWnd = GetRemoteHwnd();\r
2047 \r
2048         if((Ret = SendMessage(hWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_ALL | LVNI_FOCUSED, 0))) == -1)\r
2049                 Ret = 0;\r
2050 \r
2051         return(Ret);\r
2052 }\r
2053 \r
2054 \r
2055 /*----- アイテム数を返す ------------------------------------------------------\r
2056 *\r
2057 *       Parameter\r
2058 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
2059 *\r
2060 *       Return Value\r
2061 *               int アイテム数\r
2062 *----------------------------------------------------------------------------*/\r
2063 \r
2064 int GetItemCount(int Win)\r
2065 {\r
2066         HWND hWnd;\r
2067 \r
2068         hWnd = GetLocalHwnd();\r
2069         if(Win == WIN_REMOTE)\r
2070                 hWnd = GetRemoteHwnd();\r
2071 \r
2072         return(SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0));\r
2073 }\r
2074 \r
2075 \r
2076 /*----- 選択されているアイテム数を返す ----------------------------------------\r
2077 *\r
2078 *       Parameter\r
2079 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
2080 *\r
2081 *       Return Value\r
2082 *               int 選択されているアイテム数\r
2083 *----------------------------------------------------------------------------*/\r
2084 \r
2085 int GetSelectedCount(int Win)\r
2086 {\r
2087         HWND hWnd;\r
2088 \r
2089         hWnd = GetLocalHwnd();\r
2090         if(Win == WIN_REMOTE)\r
2091                 hWnd = GetRemoteHwnd();\r
2092 \r
2093         return(SendMessage(hWnd, LVM_GETSELECTEDCOUNT, 0, 0));\r
2094 }\r
2095 \r
2096 \r
2097 /*----- 選択されている最初のアイテム番号を返す --------------------------------\r
2098 *\r
2099 *       Parameter\r
2100 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
2101 *               int All : 選ばれていないものを含める\r
2102 *\r
2103 *       Return Value\r
2104 *               int アイテム番号\r
2105 *                       -1 = 選択されていない\r
2106 *----------------------------------------------------------------------------*/\r
2107 \r
2108 int GetFirstSelected(int Win, int All)\r
2109 {\r
2110         HWND hWnd;\r
2111         int Ope;\r
2112 \r
2113         hWnd = GetLocalHwnd();\r
2114         if(Win == WIN_REMOTE)\r
2115                 hWnd = GetRemoteHwnd();\r
2116 \r
2117         Ope = LVNI_SELECTED;\r
2118         if(All == YES)\r
2119                 Ope = LVNI_ALL;\r
2120 \r
2121         return(SendMessage(hWnd, LVM_GETNEXTITEM, (WPARAM)-1, (LPARAM)MAKELPARAM(Ope, 0)));\r
2122 }\r
2123 \r
2124 \r
2125 /*----- 選択されている次のアイテム番号を返す ----------------------------------\r
2126 *\r
2127 *       Parameter\r
2128 *               int Win : ウィンドウ番号 (WIN_xxxx)\r
2129 *               int Pos : 今のアイテム番号\r
2130 *               int All : 選ばれていないものも含める\r
2131 *\r
2132 *       Return Value\r
2133 *               int アイテム番号\r
2134 *                       -1 = 選択されていない\r
2135 *----------------------------------------------------------------------------*/\r
2136 \r
2137 int GetNextSelected(int Win, int Pos, int All)\r
2138 {\r
2139         HWND hWnd;\r
2140         int Ope;\r
2141 \r
2142         hWnd = GetLocalHwnd();\r
2143         if(Win == WIN_REMOTE)\r
2144                 hWnd = GetRemoteHwnd();\r
2145 \r
2146         Ope = LVNI_SELECTED;\r
2147         if(All == YES)\r
2148                 Ope = LVNI_ALL;\r
2149 \r
2150         return(SendMessage(hWnd, LVM_GETNEXTITEM, (WPARAM)Pos, (LPARAM)MAKELPARAM(Ope, 0)));\r
2151 }\r
2152 \r
2153 \r
2154 /*----- 指定された名前のアイテムを探す ----------------------------------------\r
2155 *\r
2156 *       Parameter\r
2157 *               int Win : ウインドウ番号 (WIN_xxx)\r
2158 *               char *Name : 名前\r
2159 *\r
2160 *       Return Value\r
2161 *               int アイテム番号\r
2162 *                       -1=見つからなかった\r
2163 *----------------------------------------------------------------------------*/\r
2164 \r
2165 int FindNameNode(int Win, char *Name)\r
2166 {\r
2167         LV_FINDINFO FindInfo;\r
2168         HWND hWnd;\r
2169 \r
2170         hWnd = GetLocalHwnd();\r
2171         if(Win == WIN_REMOTE)\r
2172                 hWnd = GetRemoteHwnd();\r
2173 \r
2174         FindInfo.flags = LVFI_STRING;\r
2175         FindInfo.psz = Name;\r
2176         return(SendMessage(hWnd, LVM_FINDITEM, -1, (LPARAM)&FindInfo));\r
2177 }\r
2178 \r
2179 \r
2180 /*----- 指定位置のアイテムの名前を返す ----------------------------------------\r
2181 *\r
2182 *       Parameter\r
2183 *               int Win : ウインドウ番号 (WIN_xxx)\r
2184 *               int Pos : 位置\r
2185 *               char *Buf : 名前を返すバッファ\r
2186 *               int Max : バッファのサイズ\r
2187 *\r
2188 *       Return Value\r
2189 *               なし\r
2190 *----------------------------------------------------------------------------*/\r
2191 \r
2192 void GetNodeName(int Win, int Pos, char *Buf, int Max)\r
2193 {\r
2194         HWND hWnd;\r
2195         LV_ITEM LvItem;\r
2196 \r
2197         hWnd = GetLocalHwnd();\r
2198         if(Win == WIN_REMOTE)\r
2199                 hWnd = GetRemoteHwnd();\r
2200 \r
2201         LvItem.mask = LVIF_TEXT;\r
2202         LvItem.iItem = Pos;\r
2203         LvItem.iSubItem = 0;\r
2204         LvItem.pszText = Buf;\r
2205         LvItem.cchTextMax = Max;\r
2206         SendMessage(hWnd, LVM_GETITEM, 0, (LPARAM)&LvItem);\r
2207         return;\r
2208 }\r
2209 \r
2210 \r
2211 /*----- 指定位置のアイテムの日付を返す ----------------------------------------\r
2212 *\r
2213 *       Parameter\r
2214 *               int Win : ウインドウ番号 (WIN_xxx)\r
2215 *               int Pos : 位置\r
2216 *               FILETIME *Buf : 日付を返すバッファ\r
2217 *\r
2218 *       Return Value\r
2219 *               int ステータス\r
2220 *                       YES/NO=日付情報がなかった\r
2221 *----------------------------------------------------------------------------*/\r
2222 \r
2223 int GetNodeTime(int Win, int Pos, FILETIME *Buf)\r
2224 {\r
2225         HWND hWnd;\r
2226         LV_ITEM LvItem;\r
2227         char Tmp[20];\r
2228         int Ret;\r
2229 \r
2230         hWnd = GetLocalHwnd();\r
2231         if(Win == WIN_REMOTE)\r
2232                 hWnd = GetRemoteHwnd();\r
2233 \r
2234         LvItem.mask = LVIF_TEXT;\r
2235         LvItem.iItem = Pos;\r
2236         LvItem.iSubItem = 1;\r
2237         LvItem.pszText = Tmp;\r
2238         LvItem.cchTextMax = 20;\r
2239         SendMessage(hWnd, LVM_GETITEM, 0, (LPARAM)&LvItem);\r
2240         Ret = TimeString2FileTime(Tmp, Buf);\r
2241         return(Ret);\r
2242 }\r
2243 \r
2244 \r
2245 /*----- 指定位置のアイテムのサイズを返す --------------------------------------\r
2246 *\r
2247 *       Parameter\r
2248 *               int Win : ウインドウ番号 (WIN_xxx)\r
2249 *               int Pos : 位置\r
2250 *               int *Buf : サイズを返すワーク\r
2251 *\r
2252 *       Return Value\r
2253 *               int ステータス\r
2254 *                       YES/NO=サイズ情報がなかった\r
2255 *----------------------------------------------------------------------------*/\r
2256 \r
2257 int GetNodeSize(int Win, int Pos, LONGLONG *Buf)\r
2258 {\r
2259         HWND hWnd;\r
2260         LV_ITEM LvItem;\r
2261         char Tmp[40];\r
2262         int Ret;\r
2263 \r
2264         hWnd = GetLocalHwnd();\r
2265         if(Win == WIN_REMOTE)\r
2266                 hWnd = GetRemoteHwnd();\r
2267 \r
2268         LvItem.mask = LVIF_TEXT;\r
2269         LvItem.iItem = Pos;\r
2270         LvItem.iSubItem = 2;\r
2271         LvItem.pszText = Tmp;\r
2272         LvItem.cchTextMax = 20;\r
2273         SendMessage(hWnd, LVM_GETITEM, 0, (LPARAM)&LvItem);\r
2274         *Buf = -1;\r
2275         Ret = NO;\r
2276         if(strlen(Tmp) > 0)\r
2277         {\r
2278                 RemoveComma(Tmp);\r
2279                 *Buf = _atoi64(Tmp);\r
2280                 Ret = YES;\r
2281         }\r
2282         return(Ret);\r
2283 }\r
2284 \r
2285 \r
2286 /*----- 指定位置のアイテムの属性を返す ----------------------------------------\r
2287 *\r
2288 *       Parameter\r
2289 *               int Win : ウインドウ番号 (WIN_xxx)\r
2290 *               int Pos : 位置\r
2291 *               int *Buf : 属性を返すワーク\r
2292 *\r
2293 *       Return Value\r
2294 *               int ステータス\r
2295 *                       YES/NO=サイズ情報がなかった\r
2296 *----------------------------------------------------------------------------*/\r
2297 \r
2298 int GetNodeAttr(int Win, int Pos, int *Buf)\r
2299 {\r
2300         LV_ITEM LvItem;\r
2301         char Tmp[20];\r
2302         int Ret;\r
2303 \r
2304         *Buf = 0;\r
2305         Ret = NO;\r
2306         if(Win == WIN_REMOTE)\r
2307         {\r
2308                 LvItem.mask = LVIF_TEXT;\r
2309                 LvItem.iItem = Pos;\r
2310                 LvItem.iSubItem = 4;\r
2311                 LvItem.pszText = Tmp;\r
2312                 LvItem.cchTextMax = 20;\r
2313                 SendMessage(GetRemoteHwnd(), LVM_GETITEM, 0, (LPARAM)&LvItem);\r
2314                 if(strlen(Tmp) > 0)\r
2315                 {\r
2316                         *Buf = AttrString2Value(Tmp);\r
2317                         Ret = YES;\r
2318                 }\r
2319         }\r
2320         return(Ret);\r
2321 }\r
2322 \r
2323 \r
2324 /*----- 指定位置のアイテムのタイプを返す --------------------------------------\r
2325 *\r
2326 *       Parameter\r
2327 *               int Win : ウインドウ番号 (WIN_xxx)\r
2328 *               int Pos : 位置\r
2329 *\r
2330 *       Return Value\r
2331 *               int タイプ (NODE_xxx)\r
2332 *----------------------------------------------------------------------------*/\r
2333 \r
2334 int GetNodeType(int Win, int Pos)\r
2335 {\r
2336         char Tmp[20];\r
2337         LV_ITEM LvItem;\r
2338         int Ret;\r
2339         HWND hWnd;\r
2340 \r
2341         hWnd = GetLocalHwnd();\r
2342         if(Win == WIN_REMOTE)\r
2343                 hWnd = GetRemoteHwnd();\r
2344 \r
2345         LvItem.mask = LVIF_TEXT;\r
2346         LvItem.iItem = Pos;\r
2347         LvItem.iSubItem = 2;\r
2348         LvItem.pszText = Tmp;\r
2349         LvItem.cchTextMax = 20;\r
2350         SendMessage(hWnd, LVM_GETITEM, 0, (LPARAM)&LvItem);\r
2351 \r
2352         if(strcmp(Tmp, "<DIR>") == 0)\r
2353                 Ret = NODE_DIR;\r
2354         else if(strcmp(Tmp, "<DRIVE>") == 0)\r
2355                 Ret = NODE_DRIVE;\r
2356         else\r
2357                 Ret = NODE_FILE;\r
2358 \r
2359         return(Ret);\r
2360 }\r
2361 \r
2362 \r
2363 /*----- 指定位置のアイテムのオーナ名を返す ------------------------------------\r
2364 *\r
2365 *       Parameter\r
2366 *               int Win : ウインドウ番号 (WIN_xxx)\r
2367 *               int Pos : 位置\r
2368 *               char *Buf : オーナ名を返すバッファ\r
2369 *               int Max : バッファのサイズ\r
2370 *\r
2371 *       Return Value\r
2372 *               なし\r
2373 *----------------------------------------------------------------------------*/\r
2374 \r
2375 void GetNodeOwner(int Win, int Pos, char *Buf, int Max)\r
2376 {\r
2377         LV_ITEM LvItem;\r
2378 \r
2379         strcpy(Buf, "");\r
2380         if(Win == WIN_REMOTE)\r
2381         {\r
2382                 LvItem.mask = LVIF_TEXT;\r
2383                 LvItem.iItem = Pos;\r
2384                 LvItem.iSubItem = 5;\r
2385                 LvItem.pszText = Buf;\r
2386                 LvItem.cchTextMax = Max;\r
2387                 SendMessage(GetRemoteHwnd(), LVM_GETITEM, 0, (LPARAM)&LvItem);\r
2388         }\r
2389         return;\r
2390 }\r
2391 \r
2392 \r
2393 /*----- ホスト側のファイル一覧ウインドウをクリア ------------------------------\r
2394 *\r
2395 *       Parameter\r
2396 *               なし\r
2397 *\r
2398 *       Return Value\r
2399 *               なし\r
2400 *----------------------------------------------------------------------------*/\r
2401 \r
2402 void EraseRemoteDirForWnd(void)\r
2403 {\r
2404         SendMessage(GetRemoteHwnd(), LVM_DELETEALLITEMS, 0, 0);\r
2405         SendMessage(GetRemoteHistHwnd(), CB_RESETCONTENT, 0, 0);\r
2406         return;\r
2407 }\r
2408 \r
2409 \r
2410 /*----- 選択されているファイルの総サイズを返す --------------------------------\r
2411 *\r
2412 *       Parameter\r
2413 *               int Win : ウインドウ番号 (WIN_xxx)\r
2414 *\r
2415 *       Return Value\r
2416 *               double サイズ\r
2417 *----------------------------------------------------------------------------*/\r
2418 \r
2419 double GetSelectedTotalSize(int Win)\r
2420 {\r
2421         double Ret;\r
2422         LONGLONG Size;\r
2423         int Pos;\r
2424 \r
2425         Ret = 0;\r
2426         if(GetSelectedCount(Win) > 0)\r
2427         {\r
2428                 Pos = GetFirstSelected(Win, NO);\r
2429                 while(Pos != -1)\r
2430                 {\r
2431                         GetNodeSize(Win, Pos, &Size);\r
2432                         if(Size >= 0)\r
2433                                 Ret += Size;\r
2434                         Pos = GetNextSelected(Win, Pos, NO);\r
2435                 }\r
2436         }\r
2437         return(Ret);\r
2438 }\r
2439 \r
2440 \r
2441 \r
2442 /*===================================================================\r
2443 \r
2444 ===================================================================*/\r
2445 \r
2446 \r
2447 \r
2448 /*----- ファイル一覧で選ばれているファイルをリストに登録する ------------------\r
2449 *\r
2450 *       Parameter\r
2451 *               int Win : ウインドウ番号 (WIN_xxx)\r
2452 *               int Expand : サブディレクトリを展開する (YES/NO)\r
2453 *               int All : 選ばれていないものもすべて登録する (YES/NO)\r
2454 *               FILELIST **Base : ファイルリストの先頭\r
2455 *\r
2456 *       Return Value\r
2457 *               なし\r
2458 *----------------------------------------------------------------------------*/\r
2459 \r
2460 void MakeSelectedFileList(int Win, int Expand, int All, FILELIST **Base, int *CancelCheckWork)\r
2461 {\r
2462         int Pos;\r
2463         char Name[FMAX_PATH+1];\r
2464         char Cur[FMAX_PATH+1];\r
2465         FILELIST Pkt;\r
2466         int Node;\r
2467         DWORD Attr;\r
2468         int Ignore;\r
2469 \r
2470         if((All == YES) || (GetSelectedCount(Win) > 0))\r
2471         {\r
2472                 /*===== カレントディレクトリのファイル =====*/\r
2473 \r
2474                 Pos = GetFirstSelected(Win, All);\r
2475                 while(Pos != -1)\r
2476                 {\r
2477                         Node = GetNodeType(Win, Pos);\r
2478                         if((Node == NODE_FILE) ||\r
2479                            ((Expand == NO) && (Node == NODE_DIR)))\r
2480                         {\r
2481                                 Pkt.InfoExist = 0;\r
2482                                 GetNodeName(Win, Pos, Pkt.File, FMAX_PATH);\r
2483                                 if(GetNodeSize(Win, Pos, &Pkt.Size) == YES)\r
2484                                         Pkt.InfoExist |= FINFO_SIZE;\r
2485                                 if(GetNodeAttr(Win, Pos, &Pkt.Attr) == YES)\r
2486                                         Pkt.InfoExist |= FINFO_ATTR;\r
2487                                 if(GetNodeTime(Win, Pos, &Pkt.Time) == YES)\r
2488                                         Pkt.InfoExist |= (FINFO_TIME | FINFO_DATE);\r
2489                                 Pkt.Node = Node;\r
2490 \r
2491                                 Ignore = NO;\r
2492                                 if((DispIgnoreHide == YES) && (Win == WIN_LOCAL))\r
2493                                 {\r
2494                                         AskLocalCurDir(Cur, FMAX_PATH);\r
2495                                         SetYenTail(Cur);\r
2496                                         strcat(Cur, Pkt.File);\r
2497                                         Attr = GetFileAttributes(Cur);\r
2498                                         if((Attr != 0xFFFFFFFF) && (Attr & FILE_ATTRIBUTE_HIDDEN))\r
2499                                                 Ignore = YES;\r
2500                                 }\r
2501 \r
2502                                 if(Ignore == NO)\r
2503                                         AddFileList(&Pkt, Base);\r
2504                         }\r
2505                         Pos = GetNextSelected(Win, Pos, All);\r
2506                 }\r
2507 \r
2508                 if(Expand == YES)\r
2509                 {\r
2510                         /*===== ディレクトリツリー =====*/\r
2511 \r
2512                         Pos = GetFirstSelected(Win, All);\r
2513                         while(Pos != -1)\r
2514                         {\r
2515                                 if(GetNodeType(Win, Pos) == NODE_DIR)\r
2516                                 {\r
2517                                         GetNodeName(Win, Pos, Name, FMAX_PATH);\r
2518                                         strcpy(Pkt.File, Name);\r
2519                                         ReplaceAll(Pkt.File, '\\', '/');\r
2520 //8/26\r
2521 \r
2522                                         Ignore = NO;\r
2523                                         if((DispIgnoreHide == YES) && (Win == WIN_LOCAL))\r
2524                                         {\r
2525                                                 AskLocalCurDir(Cur, FMAX_PATH);\r
2526                                                 SetYenTail(Cur);\r
2527                                                 strcat(Cur, Pkt.File);\r
2528                                                 ReplaceAll(Cur, '/', '\\');\r
2529                                                 Attr = GetFileAttributes(Cur);\r
2530                                                 if((Attr != 0xFFFFFFFF) && (Attr & FILE_ATTRIBUTE_HIDDEN))\r
2531                                                         Ignore = YES;\r
2532                                         }\r
2533 \r
2534                                         if(Ignore == NO)\r
2535                                         {\r
2536                                                 Pkt.Node = NODE_DIR;\r
2537                                                 Pkt.Attr = 0;\r
2538                                                 Pkt.Size = 0;\r
2539                                                 memset(&Pkt.Time, 0, sizeof(FILETIME));\r
2540                                                 AddFileList(&Pkt, Base);\r
2541 \r
2542                                                 if(Win == WIN_LOCAL)\r
2543                                                         MakeLocalTree(Name, Base);\r
2544                                                 else\r
2545                                                 {\r
2546                                                         AskRemoteCurDir(Cur, FMAX_PATH);\r
2547 \r
2548                                                         if((AskListCmdMode() == NO) &&\r
2549                                                            (AskUseNLST_R() == YES))\r
2550                                                                 MakeRemoteTree1(Name, Cur, Base, CancelCheckWork);\r
2551                                                         else\r
2552                                                                 MakeRemoteTree2(Name, Cur, Base, CancelCheckWork);\r
2553 \r
2554 //DispListList(*Base, "LIST");\r
2555 \r
2556                                                 }\r
2557                                         }\r
2558                                 }\r
2559                                 Pos = GetNextSelected(Win, Pos, All);\r
2560                         }\r
2561                 }\r
2562         }\r
2563         return;\r
2564 }\r
2565 \r
2566 \r
2567 /* デバッグ用 */\r
2568 /* ファイルリストの内容を表示 */\r
2569 static void DispListList(FILELIST *Pos, char *Title)\r
2570 {\r
2571         DoPrintf("############ %s ############", Title);\r
2572         while(Pos != NULL)\r
2573         {\r
2574                 DoPrintf("%d %s", Pos->Node, Pos->File);\r
2575                 Pos = Pos->Next;\r
2576         }\r
2577         DoPrintf("############ END ############");\r
2578         return;\r
2579 }\r
2580 \r
2581 \r
2582 /*----- Drag&Dropされたファイルをリストに登録する -----------------------------\r
2583 *\r
2584 *       Parameter\r
2585 *               WPARAM wParam : ドロップされたファイルの情報\r
2586 *               char *Cur : カレントディレクトリを返すバッファ\r
2587 *               FILELIST **Base : ファイルリストの先頭\r
2588 *\r
2589 *       Return Value\r
2590 *               なし\r
2591 *----------------------------------------------------------------------------*/\r
2592 \r
2593 void MakeDroppedFileList(WPARAM wParam, char *Cur, FILELIST **Base)\r
2594 {\r
2595         int Max;\r
2596         int i;\r
2597         char Name[FMAX_PATH+1];\r
2598         char Tmp[FMAX_PATH+1];\r
2599         FILELIST Pkt;\r
2600         HANDLE fHnd;\r
2601         WIN32_FIND_DATA Find;\r
2602 \r
2603         Max = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, NULL, 0);\r
2604 \r
2605         DragQueryFile((HDROP)wParam, 0, Cur, FMAX_PATH);\r
2606         GetUpperDir(Cur);\r
2607 \r
2608         for(i = 0; i < Max; i++)\r
2609         {\r
2610                 DragQueryFile((HDROP)wParam, i, Name, FMAX_PATH);\r
2611 \r
2612                 if((GetFileAttributes(Name) & FILE_ATTRIBUTE_DIRECTORY) == 0)\r
2613                 {\r
2614                         Pkt.Node = NODE_FILE;\r
2615                         strcpy(Pkt.File, GetFileName(Name));\r
2616 \r
2617                         memset(&Pkt.Time, 0, sizeof(FILETIME));\r
2618                         if((fHnd = FindFirstFile(Name, &Find)) != INVALID_HANDLE_VALUE)\r
2619                         {\r
2620                                 FindClose(fHnd);\r
2621                                 Pkt.Time = Find.ftLastWriteTime;\r
2622                         }\r
2623                         AddFileList(&Pkt, Base);\r
2624                 }\r
2625         }\r
2626 \r
2627         GetCurrentDirectory(FMAX_PATH, Tmp);\r
2628         SetCurrentDirectory(Cur);\r
2629         for(i = 0; i < Max; i++)\r
2630         {\r
2631                 DragQueryFile((HDROP)wParam, i, Name, FMAX_PATH);\r
2632 \r
2633                 if(GetFileAttributes(Name) & FILE_ATTRIBUTE_DIRECTORY)\r
2634                 {\r
2635                         Pkt.Node = NODE_DIR;\r
2636                         strcpy(Pkt.File, GetFileName(Name));\r
2637                         AddFileList(&Pkt, Base);\r
2638 \r
2639                         MakeLocalTree(Pkt.File, Base);\r
2640                 }\r
2641         }\r
2642         SetCurrentDirectory(Tmp);\r
2643 \r
2644         DragFinish((HDROP)wParam);\r
2645 \r
2646         return;\r
2647 }\r
2648 \r
2649 \r
2650 /*----- Drag&Dropされたファイルがあるフォルダを取得する -----------------------\r
2651 *\r
2652 *       Parameter\r
2653 *               WPARAM wParam : ドロップされたファイルの情報\r
2654 *               char *Cur : カレントディレクトリを返すバッファ\r
2655 *\r
2656 *       Return Value\r
2657 *               なし\r
2658 *----------------------------------------------------------------------------*/\r
2659 \r
2660 void MakeDroppedDir(WPARAM wParam, char *Cur)\r
2661 {\r
2662         int Max;\r
2663 \r
2664         Max = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, NULL, 0);\r
2665         DragQueryFile((HDROP)wParam, 0, Cur, FMAX_PATH);\r
2666         GetUpperDir(Cur);\r
2667         DragFinish((HDROP)wParam);\r
2668 \r
2669         return;\r
2670 }\r
2671 \r
2672 \r
2673 /*----- ホスト側のサブディレクトリ以下のファイルをリストに登録する(1)-------\r
2674 *\r
2675 *       Parameter\r
2676 *               char *Path : パス名\r
2677 *               char *Cur : カレントディレクトリ\r
2678 *               FILELIST **Base : ファイルリストの先頭\r
2679 *\r
2680 *       Return Value\r
2681 *               なし\r
2682 *\r
2683 *       Note\r
2684 *               NLST -alLR を使う\r
2685 *----------------------------------------------------------------------------*/\r
2686 \r
2687 static void MakeRemoteTree1(char *Path, char *Cur, FILELIST **Base, int *CancelCheckWork)\r
2688 {\r
2689         int Sts;\r
2690 \r
2691         if(DoCWD(Path, NO, NO, NO) == FTP_COMPLETE)\r
2692         {\r
2693                 /* サブフォルダも含めたリストを取得 */\r
2694                 Sts = DoDirListCmdSkt("R", "", 999, CancelCheckWork);   /* NLST -alLR*/\r
2695                 DoCWD(Cur, NO, NO, NO);\r
2696 \r
2697                 if(Sts == FTP_COMPLETE)\r
2698                         AddRemoteTreeToFileList(999, Path, RDIR_NLST, Base);\r
2699         }\r
2700         return;\r
2701 }\r
2702 \r
2703 \r
2704 /*----- ホスト側のサブディレクトリ以下のファイルをリストに登録する(2)-------\r
2705 *\r
2706 *       Parameter\r
2707 *               char *Path : パス名\r
2708 *               char *Cur : カレントディレクトリ\r
2709 *               FILELIST **Base : ファイルリストの先頭\r
2710 *\r
2711 *       Return Value\r
2712 *               なし\r
2713 *\r
2714 *       Note\r
2715 *               各フォルダに移動してリストを取得\r
2716 *----------------------------------------------------------------------------*/\r
2717 \r
2718 static void MakeRemoteTree2(char *Path, char *Cur, FILELIST **Base, int *CancelCheckWork)\r
2719 {\r
2720         int Sts;\r
2721         FILELIST *CurList;\r
2722         FILELIST *Pos;\r
2723         FILELIST Pkt;\r
2724 \r
2725         /* VAX VMS は CWD xxx/yyy という指定ができないので */\r
2726         /* CWD xxx, Cwd yyy と複数に分ける                                       */\r
2727         if(AskHostType() != HTYPE_VMS)\r
2728                 Sts = DoCWD(Path, NO, NO, NO);\r
2729         else\r
2730         {\r
2731 #if defined(HAVE_OPENVMS)\r
2732                 /* OpenVMSの場合、ディレクトリ移動時は"HOGE.DIR;1"を"HOGE"にする */\r
2733                 ReformVMSDirName(Path, TRUE);\r
2734 #endif\r
2735                 Sts = DoCWDStepByStep(Path, Cur);\r
2736         }\r
2737 \r
2738         if(Sts == FTP_COMPLETE)\r
2739         {\r
2740                 Sts = DoDirListCmdSkt("", "", 999, CancelCheckWork);            /* NLST -alL*/\r
2741                 DoCWD(Cur, NO, NO, NO);\r
2742 \r
2743                 if(Sts == FTP_COMPLETE)\r
2744                 {\r
2745                         CurList = NULL;\r
2746                         AddRemoteTreeToFileList(999, Path, RDIR_CWD, &CurList);\r
2747                         CopyTmpListToFileList(Base, CurList);\r
2748 \r
2749                         Pos = CurList;\r
2750                         while(Pos != NULL)\r
2751                         {\r
2752                                 if(Pos->Node == NODE_DIR)\r
2753                                 {\r
2754                                         /* まずディレクトリ名をセット */\r
2755                                         strcpy(Pkt.File, Pos->File);\r
2756                                         Pkt.Node = NODE_DIR;\r
2757                                         Pkt.Size = 0;\r
2758                                         Pkt.Attr = 0;\r
2759                                         memset(&Pkt.Time, 0, sizeof(FILETIME));\r
2760                                         AddFileList(&Pkt, Base);\r
2761 \r
2762                                         /* そのディレクトリの中を検索 */\r
2763                                         MakeRemoteTree2(Pos->File, Cur, Base, CancelCheckWork);\r
2764                                 }\r
2765                                 Pos = Pos->Next;\r
2766                         }\r
2767                         DeleteFileList(&CurList);\r
2768                 }\r
2769         }\r
2770         return;\r
2771 }\r
2772 \r
2773 \r
2774 /*----- ファイルリストの内容を別のファイルリストにコピー ----------------------\r
2775 *\r
2776 *       Parameter\r
2777 *               FILELIST **Base : コピー先\r
2778 *               FILELIST *List : コピー元\r
2779 *\r
2780 *       Return Value\r
2781 *               なし\r
2782 *\r
2783 *       Note\r
2784 *               コピーするのはファイルの情報だけ\r
2785 *               ディレクトリの情報はコピーしない\r
2786 *----------------------------------------------------------------------------*/\r
2787 \r
2788 static void CopyTmpListToFileList(FILELIST **Base, FILELIST *List)\r
2789 {\r
2790         while(List != NULL)\r
2791         {\r
2792                 if(List->Node == NODE_FILE)\r
2793                         AddFileList(List, Base);\r
2794 \r
2795                 List = List->Next;\r
2796         }\r
2797         return;\r
2798 }\r
2799 \r
2800 \r
2801 /*----- ホスト側のファイル情報をファイルリストに登録 --------------------------\r
2802 *\r
2803 *       Parameter\r
2804 *               int Num : テンポラリファイルのファイル名番号 (_ffftp.???)\r
2805 *               char *Path : パス名\r
2806 *               int IncDir : 再帰検索の方法 (RDIR_xxx)\r
2807 *               FILELIST **Base : ファイルリストの先頭\r
2808 *\r
2809 *       Return Value\r
2810 *               なし\r
2811 *----------------------------------------------------------------------------*/\r
2812 \r
2813 void AddRemoteTreeToFileList(int Num, char *Path, int IncDir, FILELIST **Base)\r
2814 {\r
2815         char Str[FMAX_PATH+1];\r
2816         char Dir[FMAX_PATH+1];\r
2817         char Name[FMAX_PATH+1];\r
2818         LONGLONG Size;\r
2819         FILETIME Time;\r
2820         int Attr;\r
2821         FILELIST Pkt;\r
2822         FILE *fd;\r
2823         int Node;\r
2824         int ListType;\r
2825         char Owner[OWNER_NAME_LEN+1];\r
2826         int Link;\r
2827         int InfoExist;\r
2828 \r
2829         MakeCacheFileName(Num, Str);\r
2830         if((fd = fopen(Str, "rb")) != NULL)\r
2831         {\r
2832                 strcpy(Dir, Path);\r
2833 \r
2834                 ListType = LIST_UNKNOWN;\r
2835 \r
2836                 while(GetListOneLine(Str, FMAX_PATH, fd) == FFFTP_SUCCESS)\r
2837                 {\r
2838                         if((ListType = AnalizeFileInfo(Str)) == LIST_UNKNOWN)\r
2839                         {\r
2840                                 if(MakeDirPath(Str, ListType, Path, Dir) == FFFTP_SUCCESS)\r
2841                                 {\r
2842                                         if(IncDir == RDIR_NLST)\r
2843                                         {\r
2844                                                 strcpy(Pkt.File, Dir);\r
2845                                                 Pkt.Node = NODE_DIR;\r
2846                                                 Pkt.Size = 0;\r
2847                                                 Pkt.Attr = 0;\r
2848                                                 memset(&Pkt.Time, 0, sizeof(FILETIME));\r
2849                                                 AddFileList(&Pkt, Base);\r
2850                                         }\r
2851                                 }\r
2852                         }\r
2853                         else\r
2854                         {\r
2855                                 Node = ResolvFileInfo(Str, ListType, Name, &Size, &Time, &Attr, Owner, &Link, &InfoExist);\r
2856 \r
2857                                 if(AskFilterStr(Name, Node) == YES)\r
2858                                 {\r
2859                                         if((Node == NODE_FILE) ||\r
2860                                            ((IncDir == RDIR_CWD) && (Node == NODE_DIR)))\r
2861                                         {\r
2862                                                 strcpy(Pkt.File, Dir);\r
2863                                                 if(strlen(Pkt.File) > 0)\r
2864                                                         SetSlashTail(Pkt.File);\r
2865                                                 strcat(Pkt.File, Name);\r
2866                                                 Pkt.Node = Node;\r
2867                                                 Pkt.Link = Link;\r
2868                                                 Pkt.Size = Size;\r
2869                                                 Pkt.Attr = Attr;\r
2870                                                 Pkt.Time = Time;\r
2871                                                 Pkt.InfoExist = InfoExist;\r
2872                                                 AddFileList(&Pkt, Base);\r
2873                                         }\r
2874                                 }\r
2875                         }\r
2876                 }\r
2877                 fclose(fd);\r
2878         }\r
2879         return;\r
2880 }\r
2881 \r
2882 \r
2883 /*----- ファイル一覧情報の1行を取得 ------------------------------------------\r
2884 *\r
2885 *       Parameter\r
2886 *               char *Buf : 1行の情報をセットするバッファ\r
2887 *               int Max : 最大文字数\r
2888 *               FILE *Fd : ストリーム\r
2889 *\r
2890 *       Return Value\r
2891 *               int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
2892 *\r
2893 *       Note\r
2894 *               VAX VMS以外の時は fgets(Buf, Max, Fd) と同じ\r
2895 *               Vax VMSの時は、複数行のファイル情報を1行にまとめる\r
2896 *----------------------------------------------------------------------------*/\r
2897 \r
2898 static int GetListOneLine(char *Buf, int Max, FILE *Fd)\r
2899 {\r
2900         char Tmp[FMAX_PATH+1];\r
2901         int Sts;\r
2902 \r
2903         Sts = FFFTP_FAIL;\r
2904         while((Sts == FFFTP_FAIL) && (fgets(Buf, Max, Fd) != NULL))\r
2905         {\r
2906                 Sts = FFFTP_SUCCESS;\r
2907                 RemoveReturnCode(Buf);\r
2908                 ReplaceAll(Buf, '\x08', ' ');\r
2909 \r
2910                 /* VAX VMSではファイル情報が複数行にわかれている     */\r
2911                 /* それを1行にまとめる                                                               */\r
2912                 if(AskHostType() == HTYPE_VMS)\r
2913                 {\r
2914                         if(strchr(Buf, ';') == NULL)    /* ファイル名以外の行 */\r
2915                                 Sts = FFFTP_FAIL;\r
2916                         else\r
2917                         {\r
2918                                 Max -= strlen(Buf);\r
2919                                 while(strchr(Buf, ')') == NULL)\r
2920                                 {\r
2921                                         if(fgets(Tmp, FMAX_PATH, Fd) != NULL)\r
2922                                         {\r
2923                                                 RemoveReturnCode(Tmp);\r
2924                                                 ReplaceAll(Buf, '\x08', ' ');\r
2925                                                 if((int)strlen(Tmp) > Max)\r
2926                                                         Tmp[Max] = NUL;\r
2927                                                 Max -= strlen(Tmp);\r
2928                                                 strcat(Buf, Tmp);\r
2929                                         }\r
2930                                         else\r
2931                                                 break;\r
2932                                 }\r
2933                         }\r
2934                 }\r
2935         }\r
2936 \r
2937 //      DoPrintf("List : %s", Buf);\r
2938 \r
2939         return(Sts);\r
2940 }\r
2941 \r
2942 \r
2943 /*----- サブディレクトリ情報の解析 --------------------------------------------\r
2944 *\r
2945 *       Parameter\r
2946 *               char *Str : ファイル情報(1行)\r
2947 *               int ListType : リストのタイプ\r
2948 *               char *Path : 先頭からのパス名\r
2949 *               char *Dir : ディレクトリ名\r
2950 *\r
2951 *       Return Value\r
2952 *               int ステータス\r
2953 *                       FFFTP_SUCCESS/FFFTP_FAIL=ディレクトリ情報でない\r
2954 *----------------------------------------------------------------------------*/\r
2955 \r
2956 static int MakeDirPath(char *Str, int ListType, char *Path, char *Dir)\r
2957 {\r
2958         int Sts;\r
2959 \r
2960         Sts = FFFTP_FAIL;\r
2961         switch(ListType)\r
2962         {\r
2963                 case LIST_ACOS :\r
2964                 case LIST_ACOS_4 :\r
2965                         break;\r
2966 \r
2967                 default:\r
2968                         if(*(Str + strlen(Str) - 1) == ':')             /* 最後が : ならサブディレクトリ */\r
2969                         {\r
2970                                 if(strcmp(Str, ".:") != 0)\r
2971                                 {\r
2972                                         if((strncmp(Str, "./", 2) == 0) ||\r
2973                                            (strncmp(Str, ".\\", 2) == 0))\r
2974                                         {\r
2975                                                 Str += 2;\r
2976                                         }\r
2977 \r
2978                                         if(strlen(Str) > 1)\r
2979                                         {\r
2980                                                 strcpy(Dir, Path);\r
2981                                                 SetSlashTail(Dir);\r
2982                                                 strcat(Dir, Str);\r
2983                                                 *(Dir + strlen(Dir) - 1) = NUL;\r
2984 \r
2985                                                 ChangeFnameRemote2Local(Dir, FMAX_PATH);\r
2986 \r
2987                                                 ReplaceAll(Dir, '\\', '/');\r
2988                                         }\r
2989                                 }\r
2990                                 Sts = FFFTP_SUCCESS;\r
2991                         }\r
2992                         break;\r
2993         }\r
2994         return(Sts);\r
2995 }\r
2996 \r
2997 \r
2998 /*----- ローカル側のサブディレクトリ以下のファイルをリストに登録する ----------\r
2999 *\r
3000 *       Parameter\r
3001 *               char *Path : パス名\r
3002 *               FILELIST **Base : ファイルリストの先頭\r
3003 *\r
3004 *       Return Value\r
3005 *               なし\r
3006 *----------------------------------------------------------------------------*/\r
3007 \r
3008 static void MakeLocalTree(char *Path, FILELIST **Base)\r
3009 {\r
3010         char Src[FMAX_PATH+1];\r
3011         HANDLE fHnd;\r
3012         WIN32_FIND_DATA FindBuf;\r
3013         FILELIST Pkt;\r
3014         SYSTEMTIME TmpStime;\r
3015 \r
3016         strcpy(Src, Path);\r
3017         SetYenTail(Src);\r
3018         strcat(Src, "*");\r
3019         ReplaceAll(Src, '/', '\\');\r
3020 \r
3021         if((fHnd = FindFirstFileAttr(Src, &FindBuf, DispIgnoreHide)) != INVALID_HANDLE_VALUE)\r
3022         {\r
3023                 do\r
3024                 {\r
3025                         if((FindBuf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)\r
3026                         {\r
3027                                 if(AskFilterStr(FindBuf.cFileName, NODE_FILE) == YES)\r
3028                                 {\r
3029                                         strcpy(Pkt.File, Path);\r
3030                                         SetSlashTail(Pkt.File);\r
3031                                         strcat(Pkt.File, FindBuf.cFileName);\r
3032                                         ReplaceAll(Pkt.File, '\\', '/');\r
3033                                         Pkt.Node = NODE_FILE;\r
3034                                         Pkt.Size = MakeLongLong(FindBuf.nFileSizeHigh, FindBuf.nFileSizeLow);\r
3035                                         Pkt.Attr = 0;\r
3036                                         Pkt.Time = FindBuf.ftLastWriteTime;\r
3037                                         FileTimeToSystemTime(&Pkt.Time, &TmpStime);\r
3038                                         TmpStime.wSecond = 0;\r
3039                                         TmpStime.wMilliseconds = 0;\r
3040                                         SystemTimeToFileTime(&TmpStime, &Pkt.Time);\r
3041                                         AddFileList(&Pkt, Base);\r
3042                                 }\r
3043                         }\r
3044                 }\r
3045                 while(FindNextFileAttr(fHnd, &FindBuf, DispIgnoreHide) == TRUE);\r
3046                 FindClose(fHnd);\r
3047         }\r
3048 \r
3049         if((fHnd = FindFirstFileAttr(Src, &FindBuf, DispIgnoreHide)) != INVALID_HANDLE_VALUE)\r
3050         {\r
3051                 do\r
3052                 {\r
3053                         if((FindBuf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&\r
3054                            (strcmp(FindBuf.cFileName, ".") != 0) &&\r
3055                            (strcmp(FindBuf.cFileName, "..") != 0))\r
3056                         {\r
3057                                 strcpy(Src, Path);\r
3058                                 SetYenTail(Src);\r
3059                                 strcat(Src, FindBuf.cFileName);\r
3060                                 strcpy(Pkt.File, Src);\r
3061                                 ReplaceAll(Pkt.File, '\\', '/');\r
3062                                 Pkt.Node = NODE_DIR;\r
3063                                 Pkt.Size = 0;\r
3064                                 Pkt.Attr = 0;\r
3065                                 memset(&Pkt.Time, 0, sizeof(FILETIME));\r
3066                                 AddFileList(&Pkt, Base);\r
3067 \r
3068                                 MakeLocalTree(Src, Base);\r
3069                         }\r
3070                 }\r
3071                 while(FindNextFileAttr(fHnd, &FindBuf, DispIgnoreHide) == TRUE);\r
3072                 FindClose(fHnd);\r
3073         }\r
3074         return;\r
3075 }\r
3076 \r
3077 \r
3078 /*----- ファイルリストに情報を登録する ----------------------------------------\r
3079 *\r
3080 *       Parameter\r
3081 *               FILELIST *Pkt : 登録するファイル情報\r
3082 *               FILELIST **Base : ファイルリストの先頭\r
3083 *\r
3084 *       Return Value\r
3085 *               なし\r
3086 *----------------------------------------------------------------------------*/\r
3087 \r
3088 static void AddFileList(FILELIST *Pkt, FILELIST **Base)\r
3089 {\r
3090         FILELIST *Pos;\r
3091         FILELIST *Prev;\r
3092 \r
3093         DoPrintf("FileList : NODE=%d : %s", Pkt->Node, Pkt->File);\r
3094 \r
3095         /* リストの重複を取り除く */\r
3096         Pos = *Base;\r
3097         while(Pos != NULL)\r
3098         {\r
3099                 if(strcmp(Pkt->File, Pos->File) == 0)\r
3100                 {\r
3101                         DoPrintf(" --> Duplicate!!");\r
3102                         break;\r
3103                 }\r
3104                 Prev = Pos;\r
3105                 Pos = Pos->Next;\r
3106         }\r
3107 \r
3108         if(Pos == NULL)         /* 重複していないので登録する */\r
3109         {\r
3110                 if((Pos = malloc(sizeof(FILELIST))) != NULL)\r
3111                 {\r
3112                         memcpy(Pos, Pkt, sizeof(FILELIST));\r
3113                         Pos->Next = NULL;\r
3114 \r
3115                         if(*Base == NULL)\r
3116                                 *Base = Pos;\r
3117                         else\r
3118                                 Prev->Next = Pos;\r
3119                 }\r
3120         }\r
3121         return;\r
3122 }\r
3123 \r
3124 \r
3125 /*----- ファイルリストをクリアする --------------------------------------------\r
3126 *\r
3127 *       Parameter\r
3128 *               FILELIST **Base : ファイルリストの先頭\r
3129 *\r
3130 *       Return Value\r
3131 *               なし\r
3132 *----------------------------------------------------------------------------*/\r
3133 \r
3134 void DeleteFileList(FILELIST **Base)\r
3135 {\r
3136         FILELIST *New;\r
3137         FILELIST *Next;\r
3138 \r
3139         New = *Base;\r
3140         while(New != NULL)\r
3141         {\r
3142                 Next = New->Next;\r
3143                 free(New);\r
3144                 New = Next;\r
3145         }\r
3146         *Base = NULL;\r
3147         return;\r
3148 }\r
3149 \r
3150 \r
3151 /*----- ファイルリストに指定のファイルがあるかチェック ------------------------\r
3152 *\r
3153 *       Parameter\r
3154 *               char *Fname : ファイル名\r
3155 *               FILELIST *Base : ファイルリストの先頭\r
3156 *               int Caps : 大文字/小文字の区別モード (COMP_xxx)\r
3157 *\r
3158 *       Return Value\r
3159 *               FILELIST *見つかったファイルリストのデータ\r
3160 *                       NULL=見つからない\r
3161 *----------------------------------------------------------------------------*/\r
3162 \r
3163 FILELIST *SearchFileList(char *Fname, FILELIST *Base, int Caps)\r
3164 {\r
3165         char Tmp[FMAX_PATH+1];\r
3166 \r
3167         while(Base != NULL)\r
3168         {\r
3169                 if(Caps == COMP_STRICT)\r
3170                 {\r
3171                         if(_mbscmp(Fname, Base->File) == 0)\r
3172                                 break;\r
3173                 }\r
3174                 else\r
3175                 {\r
3176                         if(_mbsicmp(Fname, Base->File) == 0)\r
3177                         {\r
3178                                 if(Caps == COMP_IGNORE)\r
3179                                         break;\r
3180                                 else\r
3181                                 {\r
3182                                         strcpy(Tmp, Base->File);\r
3183                                         _mbslwr(Tmp);\r
3184                                         if(_mbscmp(Tmp, Base->File) == 0)\r
3185                                                 break;\r
3186                                 }\r
3187                         }\r
3188                 }\r
3189                 Base = Base->Next;\r
3190         }\r
3191         return(Base);\r
3192 }\r
3193 \r
3194 \r
3195 /*----- ファイル情報からリストタイプを求める ----------------------------------\r
3196 *\r
3197 *       Parameter\r
3198 *               char *Str : ファイル情報(1行)\r
3199 *\r
3200 *       Return Value\r
3201 *               int リストタイプ (LIST_xxx)\r
3202 *----------------------------------------------------------------------------*/\r
3203 \r
3204 static int AnalizeFileInfo(char *Str)\r
3205 {\r
3206         int Ret;\r
3207         char Tmp[FMAX_PATH+1];\r
3208         int Add1;\r
3209         int TmpInt;\r
3210         int Flag1;\r
3211         WORD Month;\r
3212         WORD Day;\r
3213 \r
3214 //DoPrintf("LIST : %s", Str);\r
3215 \r
3216         Ret = LIST_UNKNOWN;\r
3217         Flag1 = AskHostType();\r
3218         if(Flag1 == HTYPE_ACOS)\r
3219                 Ret = LIST_ACOS;\r
3220         else if(Flag1 == HTYPE_ACOS_4)\r
3221                 Ret = LIST_ACOS_4;\r
3222         else if(Flag1 == HTYPE_VMS)\r
3223                 Ret = LIST_VMS;\r
3224         else if(Flag1 == HTYPE_IRMX)\r
3225                 Ret = LIST_IRMX;\r
3226         else if(Flag1 == HTYPE_STRATUS)\r
3227                 Ret = LIST_STRATUS;\r
3228         else if(Flag1 == HTYPE_AGILENT)\r
3229                 Ret = LIST_AGILENT;\r
3230         else if(Flag1 == HTYPE_SHIBASOKU)\r
3231                 Ret = LIST_SHIBASOKU;\r
3232         else\r
3233         {\r
3234                 /* 以下のフォーマットをチェック */\r
3235                 /* LIST_UNIX_10, LIST_UNIX_20, LIST_UNIX_12, LIST_UNIX_22, LIST_UNIX_50, LIST_UNIX_60 */\r
3236                 /* MELCOM80 */\r
3237 \r
3238                 if(FindField(Str, Tmp, 0, NO) == FFFTP_SUCCESS)\r
3239                 {\r
3240                         /* MELCOM80は "d rwxrwxrwx" のようにスペースが空いている */\r
3241                         Flag1 = NO;\r
3242                         if((strlen(Tmp) == 1) && (strchr("-dDlL", Tmp[0]) != NULL))\r
3243                         {\r
3244                                 if(FindField(Str, Tmp, 1, NO) == FFFTP_SUCCESS)\r
3245                                 {\r
3246                                         if((strlen(Tmp) == 9) ||\r
3247                                            ((strlen(Tmp) > 9) && (IsDigit(Tmp[9]) != 0)))\r
3248                                         {\r
3249                                                 memmove(Str+1, Str+2, strlen(Str+2)+1);\r
3250                                                 FindField(Str, Tmp, 0, NO);\r
3251                                                 Flag1 = YES;\r
3252                                         }\r
3253                                 }\r
3254                         }\r
3255 \r
3256                         if(strlen(Tmp) >= 10)\r
3257                         {\r
3258                                 Add1 = 0;\r
3259                                 if((strlen(Tmp) > 10) && (IsDigit(Tmp[10]) != 0))\r
3260                                 {\r
3261                                         /* こういう時 */\r
3262                                         /*   drwxr-xr-x1234  owner group  1024  Nov 6 14:21 Linux/    */\r
3263                                         Add1 = -1;\r
3264                                 }\r
3265 \r
3266 ////////////\r
3267 // LIST_UNIX_60 support\r
3268                                 if(FindField(Str, Tmp, 7+Add1, NO) == FFFTP_SUCCESS)\r
3269                                 {\r
3270                                         GetMonth(Tmp, &Month, &Day);\r
3271                                         if(Month != 0)\r
3272                                         {\r
3273                                                 Ret = CheckUnixType(Str, Tmp, Add1, 2, Day);\r
3274                                         }\r
3275                                 }\r
3276 ///////////\r
3277 \r
3278 ////////////\r
3279 // LIST_UNIX_12 support\r
3280                                 if((Ret == LIST_UNKNOWN) &&\r
3281                                    (FindField(Str, Tmp, 6+Add1, NO) == FFFTP_SUCCESS))\r
3282                                 {\r
3283                                         GetMonth(Tmp, &Month, &Day);\r
3284                                         if(Month != 0)\r
3285                                         {\r
3286                                                 Ret = CheckUnixType(Str, Tmp, Add1, 0, Day);\r
3287                                         }\r
3288                                 }\r
3289 //////////////////\r
3290 \r
3291 ////////////\r
3292 // LIST_UNIX_70 support\r
3293                                 if((Ret == LIST_UNKNOWN) &&\r
3294                                    (FindField(Str, Tmp, 6+Add1, NO) == FFFTP_SUCCESS))\r
3295                                 {\r
3296                                         GetMonth(Tmp, &Month, &Day);\r
3297                                         if(Month != 0)\r
3298                                         {\r
3299                                                 Ret = CheckUnixType(Str, Tmp, Add1, 1, Day);\r
3300                                         }\r
3301                                 }\r
3302 ///////////\r
3303 \r
3304                                 if((Ret == LIST_UNKNOWN) &&\r
3305                                    (FindField(Str, Tmp, 5+Add1, NO) == FFFTP_SUCCESS))\r
3306                                 {\r
3307                                         GetMonth(Tmp, &Month, &Day);\r
3308                                         if(Month != 0)\r
3309                                         {\r
3310                                                 Ret = CheckUnixType(Str, Tmp, Add1, 0, Day);\r
3311                                         }\r
3312                                 }\r
3313 \r
3314                                 if((Ret == LIST_UNKNOWN) &&\r
3315                                    (FindField(Str, Tmp, 4+Add1, NO) == FFFTP_SUCCESS))\r
3316                                 {\r
3317                                         GetMonth(Tmp, &Month, &Day);\r
3318                                         if(Month != 0)\r
3319                                         {\r
3320                                                 Ret = CheckUnixType(Str, Tmp, Add1, -1, Day);\r
3321                                         }\r
3322                                 }\r
3323 \r
3324                                 if((Ret == LIST_UNKNOWN) &&\r
3325                                    (FindField(Str, Tmp, 3+Add1, NO) == FFFTP_SUCCESS))\r