OSDN Git Service

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