OSDN Git Service

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