OSDN Git Service

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