OSDN Git Service

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