OSDN Git Service

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