OSDN Git Service

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