OSDN Git Service

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