OSDN Git Service

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