OSDN Git Service

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