OSDN Git Service

Fix conditions of sending commands for keep alive.
[ffftp/ffftp.git] / ftpproc.c
1 /*=============================================================================\r
2 *\r
3 *                                                               FTPコマンド操作\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  STRICT\r
31 // IPv6対応\r
32 #include <winsock2.h>\r
33 #include <windows.h>\r
34 #include <stdio.h>\r
35 #include <stdlib.h>\r
36 #include <string.h>\r
37 #include <mbstring.h>\r
38 #include <windowsx.h>\r
39 #include <commctrl.h>\r
40 \r
41 #include "common.h"\r
42 #include "resource.h"\r
43 \r
44 #include <htmlhelp.h>\r
45 #include "helpid.h"\r
46 \r
47 // UTF-8対応\r
48 #undef __MBSWRAPPER_H__\r
49 #include "mbswrapper.h"\r
50 \r
51 \r
52 /*===== プロトタイプ =====*/\r
53 \r
54 static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList);\r
55 // 64ビット対応\r
56 //static BOOL CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
57 static INT_PTR CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
58 \r
59 static void DispMirrorFiles(FILELIST *Local, FILELIST *Remote);\r
60 static void MirrorDeleteAllLocalDir(FILELIST *Local, TRANSPACKET *Pkt, TRANSPACKET **Base);\r
61 static int CheckLocalFile(TRANSPACKET *Pkt);\r
62 // 64ビット対応\r
63 //static BOOL CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
64 static INT_PTR CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
65 static void RemoveAfterSemicolon(char *Path);\r
66 static void MirrorDeleteAllDir(FILELIST *Remote, TRANSPACKET *Pkt, TRANSPACKET **Base);\r
67 // 64ビット対応\r
68 //static BOOL CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
69 //static BOOL CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
70 static INT_PTR CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
71 static INT_PTR CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
72 static void CountMirrorFiles(HWND hDlg, TRANSPACKET *Pkt);\r
73 static int AskMirrorNoTrn(char *Fname, int Mode);\r
74 static int AskUploadFileAttr(char *Fname);\r
75 // 64ビット対応\r
76 //static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
77 static INT_PTR CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
78 #if defined(HAVE_TANDEM)\r
79 static INT_PTR CALLBACK UpDownAsWithExtDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
80 #endif\r
81 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir);\r
82 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir);\r
83 // 64ビット対応\r
84 //static BOOL CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
85 //static BOOL CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
86 static INT_PTR CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
87 static INT_PTR CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
88 static void SetAttrToDialog(HWND hWnd, int Attr);\r
89 static int GetAttrFromDialog(HWND hDlg);\r
90 static LRESULT CALLBACK SizeNotifyDlgWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
91 static LRESULT CALLBACK SizeDlgWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
92 static int RenameUnuseableName(char *Fname);\r
93 \r
94 /*===== 外部参照 ====*/\r
95 \r
96 extern HWND hHelpWin;\r
97 \r
98 /* 設定値 */\r
99 extern int FnameCnv;\r
100 extern int RecvMode;\r
101 extern int SendMode;\r
102 extern int MoveMode;\r
103 extern char MirrorNoTrn[MIRROR_LEN+1];\r
104 extern char MirrorNoDel[MIRROR_LEN+1];\r
105 extern int MirrorFnameCnv;\r
106 extern char DefAttrList[DEFATTRLIST_LEN+1];\r
107 extern SIZE MirrorDlgSize;\r
108 extern int VaxSemicolon;\r
109 extern int DebugConsole;\r
110 extern int CancelFlg;\r
111 // ディレクトリ自動作成\r
112 extern int MakeAllDir;\r
113 \r
114 /*===== ローカルなワーク =====*/\r
115 \r
116 static char TmpString[FMAX_PATH+80];            /* テンポラリ */\r
117 #if defined(HAVE_TANDEM)\r
118 static char TmpFileCode[5];             /* テンポラリ */\r
119 #endif\r
120 static int CurWin;                                              /* ウインドウ番号 */\r
121 \r
122 int UpExistMode = EXIST_OVW;            /* アップロードで同じ名前のファイルがある時の扱い方 EXIST_xxx */\r
123 int ExistMode = EXIST_OVW;              /* 同じ名前のファイルがある時の扱い方 EXIST_xxx */\r
124 static int ExistNotify;         /* 確認ダイアログを出すかどうか YES/NO */\r
125 \r
126 static double FileSize;         /* ファイル総容量 */\r
127 \r
128 \r
129 \r
130 /*----- ファイル一覧で指定されたファイルをダウンロードする --------------------\r
131 *\r
132 *       Parameter\r
133 *               int ChName : 名前を変えるかどうか (YES/NO)\r
134 *               int ForceFile : ディレクトリをファイル見なすかどうか (YES/NO)\r
135 *               int All : 全てが選ばれている物として扱うかどうか (YES/NO)\r
136 *\r
137 *       Return Value\r
138 *               なし\r
139 *----------------------------------------------------------------------------*/\r
140 \r
141 // ディレクトリ自動作成\r
142 // ローカル側のパスから必要なフォルダを作成\r
143 int MakeDirFromLocalPath(char* LocalFile, char* Old)\r
144 {\r
145         TRANSPACKET Pkt;\r
146         char* pDelimiter;\r
147         char* pNext;\r
148         char* Cat;\r
149         int Len;\r
150         int Make;\r
151         pDelimiter = LocalFile;\r
152         Make = NO;\r
153         while(pNext = strchr(pDelimiter, '\\'))\r
154         {\r
155                 Len = pNext - LocalFile;\r
156                 strncpy(Pkt.LocalFile, LocalFile, Len);\r
157                 Pkt.LocalFile[Len] = '\0';\r
158                 if(strncmp(LocalFile, Old, Len + 1) != 0)\r
159                 {\r
160                         Cat = Pkt.LocalFile + (pDelimiter - LocalFile);\r
161                         if(FnameCnv == FNAME_LOWER)\r
162                                 _mbslwr(Cat);\r
163                         else if(FnameCnv == FNAME_UPPER)\r
164                                 _mbsupr(Cat);\r
165                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
166 \r
167                         strcpy(Pkt.Cmd, "MKD ");\r
168                         strcpy(Pkt.RemoteFile, "");\r
169                         AddTransFileList(&Pkt);\r
170 \r
171                         Make = YES;\r
172                 }\r
173                 pDelimiter = pNext + 1;\r
174         }\r
175         return Make;\r
176 }\r
177 \r
178 void DownloadProc(int ChName, int ForceFile, int All)\r
179 {\r
180         FILELIST *FileListBase;\r
181         FILELIST *Pos;\r
182         TRANSPACKET Pkt;\r
183         // ディレクトリ自動作成\r
184         char Tmp[FMAX_PATH+1];\r
185 \r
186         // 同時接続対応\r
187         CancelFlg = NO;\r
188 \r
189         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
190         {\r
191                 DisableUserOpe();\r
192 \r
193                 ExistNotify = YES;\r
194 //              KeepTransferDialog(YES);\r
195 \r
196                 FileListBase = NULL;\r
197                 MakeSelectedFileList(WIN_REMOTE, (ForceFile == YES ? NO : YES), All, &FileListBase, &CancelFlg);\r
198 \r
199                 if(AskNoFullPathMode() == YES)\r
200                 {\r
201                         strcpy(Pkt.Cmd, "SETCUR");\r
202                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
203                         AddTransFileList(&Pkt);\r
204                 }\r
205 \r
206                 Pos = FileListBase;\r
207                 while(Pos != NULL)\r
208                 {\r
209                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
210                         SetYenTail(Pkt.LocalFile);\r
211                         strcpy(TmpString, Pos->File);\r
212                         if((ChName == NO) || ((ForceFile == NO) && (Pos->Node == NODE_DIR)))\r
213                         {\r
214                                 if(FnameCnv == FNAME_LOWER)\r
215                                         _mbslwr(TmpString);\r
216                                 else if(FnameCnv == FNAME_UPPER)\r
217                                         _mbsupr(TmpString);\r
218                                 RemoveAfterSemicolon(TmpString);\r
219                                 if(RenameUnuseableName(TmpString) == FFFTP_FAIL)\r
220                                         break;\r
221                         }\r
222                         else\r
223                         {\r
224                                 CurWin = WIN_REMOTE;\r
225                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_dlg), GetMainHwnd(), UpDownAsDialogCallBack) == YES)\r
226                                 {\r
227                                         if(RenameUnuseableName(TmpString) == FFFTP_FAIL)\r
228                                                 break;\r
229                                 }\r
230                                 else\r
231                                         break;\r
232                         }\r
233                         strcat(Pkt.LocalFile, TmpString);\r
234                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
235 \r
236                         if((ForceFile == NO) && (Pos->Node == NODE_DIR))\r
237                         {\r
238                                 strcpy(Pkt.Cmd, "MKD ");\r
239                                 strcpy(Pkt.RemoteFile, "");\r
240                                 AddTransFileList(&Pkt);\r
241                         }\r
242                         else if((Pos->Node == NODE_FILE) ||\r
243                                         ((ForceFile == YES) && (Pos->Node == NODE_DIR)))\r
244                         {\r
245                                 if(AskHostType() == HTYPE_ACOS)\r
246                                 {\r
247                                         strcpy(Pkt.RemoteFile, "'");\r
248                                         strcat(Pkt.RemoteFile, AskHostLsName());\r
249                                         strcat(Pkt.RemoteFile, "(");\r
250                                         strcat(Pkt.RemoteFile, Pos->File);\r
251                                         strcat(Pkt.RemoteFile, ")");\r
252                                         strcat(Pkt.RemoteFile, "'");\r
253                                 }\r
254                                 else if(AskHostType() == HTYPE_ACOS_4)\r
255                                 {\r
256                                         strcpy(Pkt.RemoteFile, Pos->File);\r
257                                 }\r
258                                 else\r
259                                 {\r
260                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
261                                         SetSlashTail(Pkt.RemoteFile);\r
262                                         strcat(Pkt.RemoteFile, Pos->File);\r
263                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
264                                 }\r
265 \r
266                                 strcpy(Pkt.Cmd, "RETR ");\r
267 #if defined(HAVE_TANDEM)\r
268                                 if(AskHostType() == HTYPE_TANDEM) {\r
269                                         if(AskTransferType() != TYPE_X) {\r
270                                                 Pkt.Type = AskTransferType();\r
271                                         } else {\r
272                                                 Pkt.Attr = Pos->Attr;\r
273                                                 if (Pkt.Attr == 101)\r
274                                                         Pkt.Type = TYPE_A;\r
275                                                 else\r
276                                                         Pkt.Type = TYPE_I;\r
277                                         }\r
278                                 } else\r
279 #endif\r
280                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
281                                 Pkt.Size = Pos->Size;\r
282                                 Pkt.Time = Pos->Time;\r
283                                 Pkt.KanjiCode = AskHostKanjiCode();\r
284                                 // UTF-8対応\r
285                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
286                                 Pkt.KanaCnv = AskHostKanaCnv();\r
287 \r
288                                 // ディレクトリ自動作成\r
289                                 strcpy(Tmp, Pkt.LocalFile);\r
290                                 Pkt.Mode = CheckLocalFile(&Pkt);        /* Pkt.ExistSize がセットされる */\r
291                                 if(Pkt.Mode == EXIST_ABORT)\r
292                                         break;\r
293                                 else if(Pkt.Mode != EXIST_IGNORE)\r
294                                 // ディレクトリ自動作成\r
295 //                                      AddTransFileList(&Pkt);\r
296                                 {\r
297                                         if(MakeAllDir == YES)\r
298                                                 MakeDirFromLocalPath(Pkt.LocalFile, Tmp);\r
299                                         AddTransFileList(&Pkt);\r
300                                 }\r
301                         }\r
302                         Pos = Pos->Next;\r
303                 }\r
304 \r
305                 if(AskNoFullPathMode() == YES)\r
306                 {\r
307                         strcpy(Pkt.Cmd, "BACKCUR");\r
308                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
309                         AddTransFileList(&Pkt);\r
310                 }\r
311                 DeleteFileList(&FileListBase);\r
312 \r
313                 // 同時接続対応\r
314 //              strcpy(Pkt.Cmd, "GOQUIT");\r
315 //              AddTransFileList(&Pkt);\r
316 \r
317                 // バグ対策\r
318                 AddNullTransFileList();\r
319 \r
320                 GoForwardTransWindow();\r
321 //              KeepTransferDialog(NO);\r
322 \r
323                 EnableUserOpe();\r
324         }\r
325         return;\r
326 }\r
327 \r
328 \r
329 /*----- 指定されたファイルを一つダウンロードする ------------------------------\r
330 *\r
331 *       Parameter\r
332 *               char *Fname : ファイル名\r
333 *\r
334 *       Return Value\r
335 *               なし\r
336 *----------------------------------------------------------------------------*/\r
337 \r
338 void DirectDownloadProc(char *Fname)\r
339 {\r
340         TRANSPACKET Pkt;\r
341         // ディレクトリ自動作成\r
342         char Tmp[FMAX_PATH+1];\r
343 \r
344         // 同時接続対応\r
345         CancelFlg = NO;\r
346 \r
347         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
348         {\r
349                 DisableUserOpe();\r
350 \r
351                 ExistNotify = YES;\r
352 //              KeepTransferDialog(YES);\r
353 \r
354                 if(AskNoFullPathMode() == YES)\r
355                 {\r
356                         strcpy(Pkt.Cmd, "SETCUR");\r
357                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
358                         AddTransFileList(&Pkt);\r
359                 }\r
360 \r
361                 if(strlen(Fname) > 0)\r
362                 {\r
363                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
364                         SetYenTail(Pkt.LocalFile);\r
365                         strcpy(TmpString, Fname);\r
366                         if(FnameCnv == FNAME_LOWER)\r
367                                 _mbslwr(TmpString);\r
368                         else if(FnameCnv == FNAME_UPPER)\r
369                                 _mbsupr(TmpString);\r
370                         RemoveAfterSemicolon(TmpString);\r
371 \r
372                         if(RenameUnuseableName(TmpString) == FFFTP_SUCCESS)\r
373                         {\r
374                                 strcat(Pkt.LocalFile, TmpString);\r
375                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
376 \r
377                                 if(AskHostType() == HTYPE_ACOS)\r
378                                 {\r
379                                         strcpy(Pkt.RemoteFile, "'");\r
380                                         strcat(Pkt.RemoteFile, AskHostLsName());\r
381                                         strcat(Pkt.RemoteFile, "(");\r
382                                         strcat(Pkt.RemoteFile, Fname);\r
383                                         strcat(Pkt.RemoteFile, ")");\r
384                                         strcat(Pkt.RemoteFile, "'");\r
385                                 }\r
386                                 else if(AskHostType() == HTYPE_ACOS_4)\r
387                                 {\r
388                                         strcpy(Pkt.RemoteFile, Fname);\r
389                                 }\r
390                                 else\r
391                                 {\r
392                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
393                                         SetSlashTail(Pkt.RemoteFile);\r
394                                         strcat(Pkt.RemoteFile, Fname);\r
395                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
396                                 }\r
397 \r
398                                 strcpy(Pkt.Cmd, "RETR-S ");\r
399                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
400 \r
401                                 /* サイズと日付は転送側スレッドで取得し、セットする */\r
402 \r
403                                 Pkt.KanjiCode = AskHostKanjiCode();\r
404                                 // UTF-8対応\r
405                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
406                                 Pkt.KanaCnv = AskHostKanaCnv();\r
407 \r
408                                 // ディレクトリ自動作成\r
409                                 strcpy(Tmp, Pkt.LocalFile);\r
410                                 Pkt.Mode = CheckLocalFile(&Pkt);        /* Pkt.ExistSize がセットされる */\r
411                                 if((Pkt.Mode != EXIST_ABORT) && (Pkt.Mode != EXIST_IGNORE))\r
412                                 // ディレクトリ自動作成\r
413 //                                      AddTransFileList(&Pkt);\r
414                                 {\r
415                                         if(MakeAllDir == YES)\r
416                                                 MakeDirFromLocalPath(Pkt.LocalFile, Tmp);\r
417                                         AddTransFileList(&Pkt);\r
418                                 }\r
419                         }\r
420                 }\r
421 \r
422                 if(AskNoFullPathMode() == YES)\r
423                 {\r
424                         strcpy(Pkt.Cmd, "BACKCUR");\r
425                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
426                         AddTransFileList(&Pkt);\r
427                 }\r
428 \r
429                 // 同時接続対応\r
430 //              strcpy(Pkt.Cmd, "GOQUIT");\r
431 //              AddTransFileList(&Pkt);\r
432 \r
433                 // バグ対策\r
434                 AddNullTransFileList();\r
435 \r
436                 GoForwardTransWindow();\r
437 //              KeepTransferDialog(NO);\r
438 \r
439                 EnableUserOpe();\r
440         }\r
441         return;\r
442 }\r
443 \r
444 \r
445 /*----- 入力されたファイル名のファイルを一つダウンロードする ------------------\r
446 *\r
447 *       Parameter\r
448 *               なし\r
449 *\r
450 *       Return Value\r
451 *               なし\r
452 *----------------------------------------------------------------------------*/\r
453 \r
454 void InputDownloadProc(void)\r
455 {\r
456         char Path[FMAX_PATH+1];\r
457         int Tmp;\r
458 \r
459 //      DisableUserOpe();\r
460 \r
461         strcpy(Path, "");\r
462         if(InputDialogBox(downname_dlg, GetMainHwnd(), NULL, Path, FMAX_PATH, &Tmp, IDH_HELP_TOPIC_0000001) == YES)\r
463         {\r
464                 DirectDownloadProc(Path);\r
465         }\r
466 \r
467 //      EnableUserOpe();\r
468 \r
469         return;\r
470 }\r
471 \r
472 \r
473 /*----- ミラーリングダウンロードを行う ----------------------------------------\r
474 *\r
475 *       Parameter\r
476 *               int Notify : 確認を行うかどうか (YES/NO)\r
477 *\r
478 *       Return Value\r
479 *               なし\r
480 *----------------------------------------------------------------------------*/\r
481 \r
482 void MirrorDownloadProc(int Notify)\r
483 {\r
484         FILELIST *LocalListBase;\r
485         FILELIST *RemoteListBase;\r
486         FILELIST *LocalPos;\r
487         FILELIST *RemotePos;\r
488         TRANSPACKET Pkt;\r
489         TRANSPACKET *Base;\r
490         char Name[FMAX_PATH+1];\r
491         char *Cat;\r
492         int Level;\r
493         int Mode;\r
494 \r
495         // 同時接続対応\r
496         CancelFlg = NO;\r
497 \r
498         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
499         {\r
500                 DisableUserOpe();\r
501 \r
502                 Base = NULL;\r
503 \r
504                 if(Notify == YES)\r
505                         Notify = DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_down_dlg), GetMainHwnd(), MirrorNotifyCallBack, 0);\r
506                 else\r
507                         Notify = YES;\r
508 \r
509                 if((Notify == YES) || (Notify == YES_LIST))\r
510                 {\r
511                         /*===== ファイルリスト取得 =====*/\r
512 \r
513                         LocalListBase = NULL;\r
514                         MakeSelectedFileList(WIN_LOCAL, YES, YES, &LocalListBase, &CancelFlg);\r
515                         RemoteListBase = NULL;\r
516                         MakeSelectedFileList(WIN_REMOTE, YES, YES, &RemoteListBase, &CancelFlg);\r
517 \r
518                         RemotePos = RemoteListBase;\r
519                         while(RemotePos != NULL)\r
520                         {\r
521                                 RemotePos->Attr = YES;          /* RemotePos->Attrは転送するかどうかのフラグに使用 (YES/NO) */\r
522                                 RemotePos = RemotePos->Next;\r
523                         }\r
524 \r
525                         LocalPos = LocalListBase;\r
526                         while(LocalPos != NULL)\r
527                         {\r
528                                 if(AskMirrorNoTrn(LocalPos->File, 1) == NO)\r
529                                 {\r
530                                         LocalPos->Attr = YES;\r
531                                         LocalPos = LocalPos->Next;\r
532                                 }\r
533                                 else\r
534                                 {\r
535                                         LocalPos->Attr = NO;    /* LocalPos->Attrは削除するかどうかのフラグに使用 (YES/NO) */\r
536 \r
537                                         if(LocalPos->Node == NODE_DIR)\r
538                                         {\r
539                                                 Level = AskDirLevel(LocalPos->File);\r
540                                                 LocalPos = LocalPos->Next;\r
541                                                 while(LocalPos != NULL)\r
542                                                 {\r
543                                                         if((LocalPos->Node == NODE_DIR) &&\r
544                                                            (AskDirLevel(LocalPos->File) <= Level))\r
545                                                         {\r
546                                                                 break;\r
547                                                         }\r
548                                                         LocalPos->Attr = NO;\r
549                                                         LocalPos = LocalPos->Next;\r
550                                                 }\r
551                                         }\r
552                                         else\r
553                                                 LocalPos = LocalPos->Next;\r
554                                 }\r
555                         }\r
556 \r
557                         /*===== ファイルリスト比較 =====*/\r
558 \r
559                         RemotePos = RemoteListBase;\r
560                         while(RemotePos != NULL)\r
561                         {\r
562                                 if(AskMirrorNoTrn(RemotePos->File, 0) == NO)\r
563                                 {\r
564                                         strcpy(Name, RemotePos->File);\r
565 //                                      ReplaceAll(Name, '/', '\\');\r
566 \r
567                                         if(MirrorFnameCnv == YES)\r
568                                                 Mode = COMP_LOWERMATCH;\r
569                                         else\r
570                                                 Mode = COMP_STRICT;\r
571 \r
572                                         if((LocalPos = SearchFileList(Name, LocalListBase, Mode)) != NULL)\r
573                                         {\r
574                                                 if((RemotePos->Node == NODE_DIR) && (LocalPos->Node == NODE_DIR))\r
575                                                 {\r
576                                                         LocalPos->Attr = NO;\r
577                                                         RemotePos->Attr = NO;\r
578                                                 }\r
579                                                 else if((RemotePos->Node == NODE_FILE) && (LocalPos->Node == NODE_FILE))\r
580                                                 {\r
581                                                         LocalPos->Attr = NO;\r
582                                                         if(CompareFileTime(&RemotePos->Time, &LocalPos->Time) <= 0)\r
583                                                                 RemotePos->Attr = NO;\r
584                                                 }\r
585                                         }\r
586                                         RemotePos = RemotePos->Next;\r
587                                 }\r
588                                 else\r
589                                 {\r
590                                         if(RemotePos->Node == NODE_FILE)\r
591                                         {\r
592                                                 RemotePos->Attr = NO;\r
593                                                 RemotePos = RemotePos->Next;\r
594                                         }\r
595                                         else\r
596                                         {\r
597                                                 RemotePos->Attr = NO;\r
598                                                 Level = AskDirLevel(RemotePos->File);\r
599                                                 RemotePos = RemotePos->Next;\r
600                                                 while(RemotePos != NULL)\r
601                                                 {\r
602                                                         if((RemotePos->Node == NODE_DIR) &&\r
603                                                            (AskDirLevel(RemotePos->File) <= Level))\r
604                                                         {\r
605                                                                 break;\r
606                                                         }\r
607                                                         RemotePos->Attr = NO;\r
608                                                         RemotePos = RemotePos->Next;\r
609                                                 }\r
610                                         }\r
611                                 }\r
612                         }\r
613 \r
614                         DispMirrorFiles(LocalListBase, RemoteListBase);\r
615 \r
616                         /*===== 削除/アップロード =====*/\r
617 \r
618                         LocalPos = LocalListBase;\r
619                         while(LocalPos != NULL)\r
620                         {\r
621                                 if((LocalPos->Attr == YES) && (LocalPos->Node == NODE_FILE))\r
622                                 {\r
623                                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
624                                         SetYenTail(Pkt.LocalFile);\r
625                                         strcat(Pkt.LocalFile, LocalPos->File);\r
626                                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
627                                         strcpy(Pkt.RemoteFile, "");\r
628                                         strcpy(Pkt.Cmd, "L-DELE ");\r
629                                         AddTmpTransFileList(&Pkt, &Base);\r
630                                 }\r
631                                 LocalPos = LocalPos->Next;\r
632                         }\r
633                         MirrorDeleteAllLocalDir(LocalListBase, &Pkt, &Base);\r
634 \r
635 \r
636                         RemotePos = RemoteListBase;\r
637                         while(RemotePos != NULL)\r
638                         {\r
639                                 if(RemotePos->Attr == YES)\r
640                                 {\r
641                                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
642                                         SetYenTail(Pkt.LocalFile);\r
643                                         Cat = strchr(Pkt.LocalFile, NUL);\r
644                                         strcat(Pkt.LocalFile, RemotePos->File);\r
645 \r
646                                         if(MirrorFnameCnv == YES)\r
647                                                 _mbslwr(Cat);\r
648 \r
649                                         RemoveAfterSemicolon(Cat);\r
650                                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
651 \r
652                                         if(RemotePos->Node == NODE_DIR)\r
653                                         {\r
654                                                 strcpy(Pkt.RemoteFile, "");\r
655                                                 strcpy(Pkt.Cmd, "L-MKD ");\r
656                                                 AddTmpTransFileList(&Pkt, &Base);\r
657                                         }\r
658                                         else if(RemotePos->Node == NODE_FILE)\r
659                                         {\r
660                                                 AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
661                                                 SetSlashTail(Pkt.RemoteFile);\r
662                                                 strcat(Pkt.RemoteFile, RemotePos->File);\r
663                                                 ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
664 \r
665                                                 strcpy(Pkt.Cmd, "RETR ");\r
666                                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
667                                                 Pkt.Size = RemotePos->Size;\r
668                                                 Pkt.Time = RemotePos->Time;\r
669 //                                              Pkt.Attr = 0;\r
670                                                 Pkt.KanjiCode = AskHostKanjiCode();\r
671                                                 // UTF-8対応\r
672                                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
673                                                 Pkt.KanaCnv = AskHostKanaCnv();\r
674                                                 Pkt.Mode = EXIST_OVW;\r
675                                                 AddTmpTransFileList(&Pkt, &Base);\r
676                                         }\r
677                                 }\r
678                                 RemotePos = RemotePos->Next;\r
679                         }\r
680 \r
681                         if((Notify == YES) ||\r
682                            (DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirrordown_notify_dlg), GetMainHwnd(), MirrorDispListCallBack, (LPARAM)&Base) == YES))\r
683                         {\r
684                                 if(AskNoFullPathMode() == YES)\r
685                                 {\r
686                                         strcpy(Pkt.Cmd, "SETCUR");\r
687                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
688                                         AddTransFileList(&Pkt);\r
689                                 }\r
690                                 AppendTransFileList(Base);\r
691 \r
692                                 if(AskNoFullPathMode() == YES)\r
693                                 {\r
694                                         strcpy(Pkt.Cmd, "BACKCUR");\r
695                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
696                                         AddTransFileList(&Pkt);\r
697                                 }\r
698 \r
699                                 // 同時接続対応\r
700 //                              strcpy(Pkt.Cmd, "GOQUIT");\r
701 //                              AddTransFileList(&Pkt);\r
702                         }\r
703                         else\r
704                                 EraseTmpTransFileList(&Base);\r
705 \r
706                         // バグ対策\r
707                         AddNullTransFileList();\r
708 \r
709                         DeleteFileList(&LocalListBase);\r
710                         DeleteFileList(&RemoteListBase);\r
711 \r
712                         GoForwardTransWindow();\r
713                 }\r
714 \r
715                 EnableUserOpe();\r
716         }\r
717         return;\r
718 }\r
719 \r
720 \r
721 /*----- ミラーリングのファイル一覧を表示 --------------------------------------\r
722 *\r
723 *       Parameter\r
724 *               FILELIST *Local : ローカル側\r
725 *               FILELIST *Remote : リモート側\r
726 *\r
727 *       Return Value\r
728 *               なし\r
729 *----------------------------------------------------------------------------*/\r
730 \r
731 static void DispMirrorFiles(FILELIST *Local, FILELIST *Remote)\r
732 {\r
733         char Date[80];\r
734         SYSTEMTIME sTime;\r
735         FILETIME fTime;\r
736 \r
737         if(DebugConsole == YES)\r
738         {\r
739                 DoPrintf("---- MIRROR FILE LIST ----");\r
740                 while(Local != NULL)\r
741                 {\r
742                         FileTimeToLocalFileTime(&Local->Time, &fTime);\r
743                         FileTimeToSystemTime(&fTime, &sTime);\r
744                         sprintf(Date, "%04d/%02d/%02d %02d:%02d:%02d.%04d", \r
745                                 sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond, sTime.wMilliseconds);\r
746                         DoPrintf("LOCAL  : %s %s [%s] %s", Local->Attr==1?"YES":"NO ", Local->Node==NODE_DIR?"DIR ":"FILE", Date, Local->File);\r
747                         Local = Local->Next;\r
748                 }\r
749                 while(Remote != NULL)\r
750                 {\r
751                         FileTimeToLocalFileTime(&Remote->Time, &fTime);\r
752                         FileTimeToSystemTime(&fTime, &sTime);\r
753                         sprintf(Date, "%04d/%02d/%02d %02d:%02d:%02d.%04d", \r
754                                 sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond, sTime.wMilliseconds);\r
755                         DoPrintf("REMOTE : %s %s [%s] %s", Remote->Attr==1?"YES":"NO ", Remote->Node==NODE_DIR?"DIR ":"FILE", Date, Remote->File);\r
756                         Remote = Remote->Next;\r
757                 }\r
758                 DoPrintf("---- END ----");\r
759         }\r
760         return;\r
761 }\r
762 \r
763 \r
764 /*----- ミラーリング時のローカル側のフォルダ削除 ------------------------------\r
765 *\r
766 *       Parameter\r
767 *               FILELIST *Local : ファイルリスト\r
768 *               TRANSPACKET *Pkt : \r
769 *               TRANSPACKET **Base : \r
770 *\r
771 *       Return Value\r
772 *               なし\r
773 *----------------------------------------------------------------------------*/\r
774 \r
775 static void MirrorDeleteAllLocalDir(FILELIST *Local, TRANSPACKET *Pkt, TRANSPACKET **Base)\r
776 {\r
777         while(Local != NULL)\r
778         {\r
779                 if(Local->Node == NODE_DIR)\r
780                 {\r
781                         MirrorDeleteAllLocalDir(Local->Next, Pkt, Base);\r
782 \r
783                         if(Local->Attr == YES)\r
784                         {\r
785                                 AskLocalCurDir(Pkt->LocalFile, FMAX_PATH);\r
786                                 SetYenTail(Pkt->LocalFile);\r
787                                 strcat(Pkt->LocalFile, Local->File);\r
788                                 ReplaceAll(Pkt->LocalFile, '/', '\\');\r
789                                 strcpy(Pkt->RemoteFile, "");\r
790                                 strcpy(Pkt->Cmd, "L-RMD ");\r
791                                 AddTmpTransFileList(Pkt, Base);\r
792                         }\r
793                         break;\r
794                 }\r
795                 Local = Local->Next;\r
796         }\r
797         return;\r
798 }\r
799 \r
800 \r
801 /*----- ファイル名のセミコロン以降を取り除く ----------------------------------\r
802 *\r
803 *       Parameter\r
804 *               char *Path : ファイル名\r
805 *\r
806 *       Return Value\r
807 *               なし\r
808 *\r
809 *       Note\r
810 *               Pathの内容が書き換えられる\r
811 *               オプション設定によって処理を切替える\r
812 *----------------------------------------------------------------------------*/\r
813 \r
814 static void RemoveAfterSemicolon(char *Path)\r
815 {\r
816         char *Pos;\r
817 \r
818         if(VaxSemicolon == YES)\r
819         {\r
820                 if((Pos = strchr(Path, ';')) != NULL)\r
821                         *Pos = NUL;\r
822         }\r
823         return;\r
824 }\r
825 \r
826 \r
827 /*----- ローカルに同じ名前のファイルがないかチェック --------------------------\r
828 *\r
829 *       Parameter\r
830 *               TRANSPACKET *Pkt : 転送ファイル情報\r
831 *\r
832 *       Return Value\r
833 *               int 処理方法\r
834 *                       EXIST_OVW/EXIST_RESUME/EXIST_IGNORE\r
835 *\r
836 *       Note\r
837 *               Pkt.ExistSize, ExistMode、ExistNotify が変更される\r
838 *----------------------------------------------------------------------------*/\r
839 \r
840 static int CheckLocalFile(TRANSPACKET *Pkt)\r
841 {\r
842         HANDLE fHnd;\r
843         WIN32_FIND_DATA Find;\r
844         int Ret;\r
845 \r
846         Ret = EXIST_OVW;\r
847         Pkt->ExistSize = 0;\r
848         if(RecvMode != TRANS_OVW)\r
849         {\r
850                 if((fHnd = FindFirstFile(Pkt->LocalFile, &Find)) != INVALID_HANDLE_VALUE)\r
851                 {\r
852                         FindClose(fHnd);\r
853 \r
854                         Pkt->ExistSize = MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow);\r
855 \r
856                         if(ExistNotify == YES)\r
857                         {\r
858                                 SoundPlay(SND_ERROR);\r
859                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(down_exist_dlg), GetMainHwnd(), DownExistDialogCallBack, (LPARAM)Pkt) == NO)\r
860                                         Ret = EXIST_ABORT;\r
861                                 else\r
862                                         Ret = ExistMode;\r
863                         }\r
864                         else\r
865                                 Ret = ExistMode;\r
866 \r
867                         if(Ret == EXIST_NEW)\r
868                         {\r
869                                 /*ファイル日付チェック */\r
870                                 if(CompareFileTime(&Find.ftLastWriteTime, &Pkt->Time) < 0)\r
871                                         Ret = EXIST_OVW;\r
872                                 else\r
873                                         Ret = EXIST_IGNORE;\r
874                         }\r
875                 }\r
876         }\r
877         return(Ret);\r
878 }\r
879 \r
880 \r
881 /*----- ローカルに同じ名前のファイルがある時の確認ダイアログのコールバック ----\r
882 *\r
883 *       Parameter\r
884 *               HWND hDlg : ウインドウハンドル\r
885 *               UINT message : メッセージ番号\r
886 *               WPARAM wParam : メッセージの WPARAM 引数\r
887 *               LPARAM lParam : メッセージの LPARAM 引数\r
888 *\r
889 *       Return Value\r
890 *               BOOL TRUE/FALSE\r
891 *----------------------------------------------------------------------------*/\r
892 \r
893 // 64ビット対応\r
894 //static BOOL CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
895 static INT_PTR CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
896 {\r
897         static TRANSPACKET *Pkt;\r
898         static const RADIOBUTTON DownExistButton[] = {\r
899                 { DOWN_EXIST_OVW, EXIST_OVW },\r
900                 { DOWN_EXIST_NEW, EXIST_NEW },\r
901                 { DOWN_EXIST_RESUME, EXIST_RESUME },\r
902                 { DOWN_EXIST_IGNORE, EXIST_IGNORE }\r
903         };\r
904         #define DOWNEXISTBUTTONS        (sizeof(DownExistButton)/sizeof(RADIOBUTTON))\r
905 \r
906         switch (iMessage)\r
907         {\r
908                 case WM_INITDIALOG :\r
909                         Pkt = (TRANSPACKET *)lParam;\r
910                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, EM_LIMITTEXT, FMAX_PATH, 0);\r
911                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, WM_SETTEXT, 0, (LPARAM)Pkt->LocalFile);\r
912 \r
913                         if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
914                                 EnableWindow(GetDlgItem(hDlg, DOWN_EXIST_RESUME), FALSE);\r
915 \r
916                         SetRadioButtonByValue(hDlg, ExistMode, DownExistButton, DOWNEXISTBUTTONS);\r
917                         return(TRUE);\r
918 \r
919                 case WM_COMMAND :\r
920                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
921                         {\r
922                                 case IDOK_ALL :\r
923                                         ExistNotify = NO;\r
924                                         /* ここに break はない */\r
925 \r
926                                 case IDOK :\r
927                                         ExistMode = AskRadioButtonValue(hDlg, DownExistButton, DOWNEXISTBUTTONS);\r
928                                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, WM_GETTEXT, FMAX_PATH, (LPARAM)Pkt->LocalFile);\r
929                                         EndDialog(hDlg, YES);\r
930                                         break;\r
931 \r
932                                 case IDCANCEL :\r
933 //                                      ExistMode = EXIST_ABORT;\r
934                                         EndDialog(hDlg, NO);\r
935                                         break;\r
936 \r
937                                 case IDHELP :\r
938                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000009);\r
939                                         break;\r
940                         }\r
941             return(TRUE);\r
942         }\r
943         return(FALSE);\r
944 }\r
945 \r
946 \r
947 \r
948 \r
949 \r
950 \r
951 /*----- ファイル一覧で指定されたファイルをアップロードする --------------------\r
952 *\r
953 *       Parameter\r
954 *               int ChName : 名前を変えるかどうか (YES/NO)\r
955 *               int All : 全てが選ばれている物として扱うかどうか (YES/NO)\r
956 *\r
957 *       Return Value\r
958 *               なし\r
959 *----------------------------------------------------------------------------*/\r
960 \r
961 // ディレクトリ自動作成\r
962 // リモート側のパスから必要なディレクトリを作成\r
963 int MakeDirFromRemotePath(char* RemoteFile, char* Old, int FirstAdd)\r
964 {\r
965         TRANSPACKET Pkt;\r
966         TRANSPACKET Pkt1;\r
967         char* pDelimiter;\r
968         char* pNext;\r
969         char* Cat;\r
970         int Len;\r
971         int Make;\r
972         pDelimiter = RemoteFile;\r
973         Make = NO;\r
974         while(pNext = strchr(pDelimiter, '/'))\r
975         {\r
976                 Len = pNext - RemoteFile;\r
977                 strncpy(Pkt.RemoteFile, RemoteFile, Len);\r
978                 Pkt.RemoteFile[Len] = '\0';\r
979                 if(strncmp(RemoteFile, Old, Len + 1) != 0)\r
980                 {\r
981                         Cat = Pkt.RemoteFile + (pDelimiter - RemoteFile);\r
982                         if(FnameCnv == FNAME_LOWER)\r
983                                 _mbslwr(Cat);\r
984                         else if(FnameCnv == FNAME_UPPER)\r
985                                 _mbsupr(Cat);\r
986 #if defined(HAVE_TANDEM)\r
987                         Pkt.FileCode = 0;\r
988                         Pkt.PriExt = DEF_PRIEXT;\r
989                         Pkt.SecExt = DEF_SECEXT;\r
990                         Pkt.MaxExt = DEF_MAXEXT;\r
991 #endif\r
992                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
993 \r
994                         if(AskHostType() == HTYPE_ACOS)\r
995                         {\r
996                                 strcpy(Pkt.RemoteFile, "'");\r
997                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
998                                 strcat(Pkt.RemoteFile, "(");\r
999                                 strcat(Pkt.RemoteFile, Cat);\r
1000                                 strcat(Pkt.RemoteFile, ")");\r
1001                                 strcat(Pkt.RemoteFile, "'");\r
1002                         }\r
1003                         else if(AskHostType() == HTYPE_ACOS_4)\r
1004                                 strcpy(Pkt.RemoteFile, Cat);\r
1005 \r
1006                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1007                         {\r
1008                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1009                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1010                                 AddTransFileList(&Pkt1);\r
1011                         }\r
1012                         FirstAdd = NO;\r
1013                         strcpy(Pkt.Cmd, "MKD ");\r
1014                         strcpy(Pkt.LocalFile, "");\r
1015                         AddTransFileList(&Pkt);\r
1016 \r
1017                         Make = YES;\r
1018                 }\r
1019                 pDelimiter = pNext + 1;\r
1020         }\r
1021         return Make;\r
1022 }\r
1023 \r
1024 void UploadListProc(int ChName, int All)\r
1025 {\r
1026         FILELIST *FileListBase;\r
1027         FILELIST *Pos;\r
1028         TRANSPACKET Pkt;\r
1029         TRANSPACKET Pkt1;\r
1030         char *Cat;\r
1031         FILELIST *RemoteList;\r
1032         char Tmp[FMAX_PATH+1];\r
1033         int FirstAdd;\r
1034 \r
1035         // 同時接続対応\r
1036         CancelFlg = NO;\r
1037 \r
1038         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1039         {\r
1040                 DisableUserOpe();\r
1041 \r
1042                 // ローカル側で選ばれているファイルをFileListBaseに登録\r
1043                 FileListBase = NULL;\r
1044                 MakeSelectedFileList(WIN_LOCAL, YES, All, &FileListBase, &CancelFlg);\r
1045 \r
1046                 // 現在ホスト側のファイル一覧に表示されているものをRemoteListに登録\r
1047                 // 同名ファイルチェック用\r
1048                 RemoteList = NULL;\r
1049                 AddRemoteTreeToFileList(AskCurrentFileListNum(), "", RDIR_NONE, &RemoteList);\r
1050 \r
1051                 FirstAdd = YES;\r
1052                 ExistNotify = YES;\r
1053 \r
1054                 Pos = FileListBase;\r
1055                 while(Pos != NULL)\r
1056                 {\r
1057                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1058                         SetSlashTail(Pkt.RemoteFile);\r
1059                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1060                         if((ChName == NO) || (Pos->Node == NODE_DIR))\r
1061                         {\r
1062                                 strcat(Pkt.RemoteFile, Pos->File);\r
1063                                 if(FnameCnv == FNAME_LOWER)\r
1064                                         _mbslwr(Cat);\r
1065                                 else if(FnameCnv == FNAME_UPPER)\r
1066                                         _mbsupr(Cat);\r
1067 #if defined(HAVE_TANDEM)\r
1068                                 Pkt.FileCode = 0;\r
1069                                 Pkt.PriExt = DEF_PRIEXT;\r
1070                                 Pkt.SecExt = DEF_SECEXT;\r
1071                                 Pkt.MaxExt = DEF_MAXEXT;\r
1072 #endif\r
1073                         }\r
1074                         else\r
1075                         {\r
1076                                 // 名前を変更する\r
1077                                 strcpy(TmpString, Pos->File);\r
1078                                 CurWin = WIN_LOCAL;\r
1079 #if defined(HAVE_TANDEM)\r
1080                                 strcpy(TmpFileCode, "0"); /* ASCII モードの場合は無視される */\r
1081                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1082                                         if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_with_ext_dlg), GetMainHwnd(), UpDownAsWithExtDialogCallBack) == YES) {\r
1083                                                 strcat(Pkt.RemoteFile, TmpString);\r
1084                                                 Pkt.FileCode = atoi(TmpFileCode);\r
1085                                         } else {\r
1086                                                 break;\r
1087                                         }\r
1088                                 } else\r
1089 #endif\r
1090                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_dlg), GetMainHwnd(), UpDownAsDialogCallBack) == YES)\r
1091                                         strcat(Pkt.RemoteFile, TmpString);\r
1092                                 else\r
1093                                         break;\r
1094                         }\r
1095                         // バグ修正\r
1096                         AskRemoteCurDir(Tmp, FMAX_PATH);\r
1097                         SetSlashTail(Tmp);\r
1098                         if(strncmp(Pkt.RemoteFile, Tmp, strlen(Tmp)) != 0)\r
1099                         {\r
1100                                 if((Cat = strrchr(Pkt.RemoteFile, '/')) != NULL)\r
1101                                         Cat++;\r
1102                                 else\r
1103                                         Cat = Pkt.RemoteFile;\r
1104                         }\r
1105                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1106 \r
1107                         if(AskHostType() == HTYPE_ACOS)\r
1108                         {\r
1109                                 strcpy(Pkt.RemoteFile, "'");\r
1110                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
1111                                 strcat(Pkt.RemoteFile, "(");\r
1112                                 strcat(Pkt.RemoteFile, Cat);\r
1113                                 strcat(Pkt.RemoteFile, ")");\r
1114                                 strcat(Pkt.RemoteFile, "'");\r
1115                         }\r
1116                         else if(AskHostType() == HTYPE_ACOS_4)\r
1117                                 strcpy(Pkt.RemoteFile, Cat);\r
1118 \r
1119                         if(Pos->Node == NODE_DIR)\r
1120                         {\r
1121                                 // フォルダの場合\r
1122 \r
1123                                 // ホスト側のファイル一覧をRemoteListに登録\r
1124                                 // 同名ファイルチェック用\r
1125                                 if(RemoteList != NULL)\r
1126                                         DeleteFileList(&RemoteList);\r
1127                                 RemoteList = NULL;\r
1128 \r
1129                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1130                                 if(DoCWD(Pkt.RemoteFile, NO, NO, NO) == FTP_COMPLETE)\r
1131                                 {\r
1132                                         if(DoDirListCmdSkt("", "", 998, &CancelFlg) == FTP_COMPLETE)\r
1133                                                 AddRemoteTreeToFileList(998, "", RDIR_NONE, &RemoteList);\r
1134                                         DoCWD(Tmp, NO, NO, NO);\r
1135                                 }\r
1136                                 else\r
1137                                 {\r
1138                                         // フォルダを作成\r
1139                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1140                                         {\r
1141                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1142                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1143                                                 AddTransFileList(&Pkt1);\r
1144                                         }\r
1145                                         FirstAdd = NO;\r
1146                                         strcpy(Pkt.Cmd, "MKD ");\r
1147                                         strcpy(Pkt.LocalFile, "");\r
1148                                         AddTransFileList(&Pkt);\r
1149                                 }\r
1150                         }\r
1151                         else if(Pos->Node == NODE_FILE)\r
1152                         {\r
1153                                 // ファイルの場合\r
1154                                 AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
1155                                 SetYenTail(Pkt.LocalFile);\r
1156                                 strcat(Pkt.LocalFile, Pos->File);\r
1157                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1158 \r
1159                                 strcpy(Pkt.Cmd, "STOR ");\r
1160                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1161                                 Pkt.Size = 0;\r
1162                                 Pkt.Time = Pos->Time;\r
1163                                 Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile);\r
1164                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1165                                 // UTF-8対応\r
1166                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1167                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1168 #if defined(HAVE_TANDEM)\r
1169                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1170                                         CalcExtentSize(&Pkt, Pos->Size);\r
1171                                 }\r
1172 #endif\r
1173                                 // ディレクトリ自動作成\r
1174                                 strcpy(Tmp, Pkt.RemoteFile);\r
1175                                 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
1176                                 if(Pkt.Mode == EXIST_ABORT)\r
1177                                         break;\r
1178                                 else if(Pkt.Mode != EXIST_IGNORE)\r
1179                                 {\r
1180                                         // ディレクトリ自動作成\r
1181                                         if(MakeAllDir == YES)\r
1182                                         {\r
1183                                                 if(MakeDirFromRemotePath(Pkt.RemoteFile, Tmp, FirstAdd) == YES)\r
1184                                                         FirstAdd = NO;\r
1185                                         }\r
1186                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1187                                         {\r
1188                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1189                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1190                                                 AddTransFileList(&Pkt1);\r
1191                                         }\r
1192                                         FirstAdd = NO;\r
1193                                         AddTransFileList(&Pkt);\r
1194                                 }\r
1195                         }\r
1196                         Pos = Pos->Next;\r
1197                 }\r
1198 \r
1199                 if((FirstAdd == NO) && (AskNoFullPathMode() == YES))\r
1200                 {\r
1201                         strcpy(Pkt.Cmd, "BACKCUR");\r
1202                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1203                         AddTransFileList(&Pkt);\r
1204                 }\r
1205 \r
1206                 if(RemoteList != NULL)\r
1207                         DeleteFileList(&RemoteList);\r
1208 \r
1209                 DeleteFileList(&FileListBase);\r
1210 \r
1211                 // 同時接続対応\r
1212 //              strcpy(Pkt.Cmd, "GOQUIT");\r
1213 //              AddTransFileList(&Pkt);\r
1214 \r
1215                 // バグ対策\r
1216                 AddNullTransFileList();\r
1217 \r
1218                 GoForwardTransWindow();\r
1219 \r
1220                 EnableUserOpe();\r
1221         }\r
1222         return;\r
1223 }\r
1224 \r
1225 \r
1226 /*----- ドラッグ&ドロップで指定されたファイルをアップロードする --------------\r
1227 *\r
1228 *       Parameter\r
1229 *               WPARAM wParam : ドロップされたファイルの情報\r
1230 *\r
1231 *       Return Value\r
1232 *               なし\r
1233 *----------------------------------------------------------------------------*/\r
1234 \r
1235 void UploadDragProc(WPARAM wParam)\r
1236 {\r
1237         FILELIST *FileListBase;\r
1238         FILELIST *Pos;\r
1239         TRANSPACKET Pkt;\r
1240         TRANSPACKET Pkt1;\r
1241         char *Cat;\r
1242         FILELIST *RemoteList;\r
1243         char Tmp[FMAX_PATH+1];\r
1244         int FirstAdd;\r
1245         char Cur[FMAX_PATH+1];\r
1246 \r
1247         // 同時接続対応\r
1248         CancelFlg = NO;\r
1249 \r
1250         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1251         {\r
1252                 DisableUserOpe();\r
1253 \r
1254                 // ローカル側で選ばれているファイルをFileListBaseに登録\r
1255                 FileListBase = NULL;\r
1256                 MakeDroppedFileList(wParam, Cur, &FileListBase);\r
1257 \r
1258                 // 現在ホスト側のファイル一覧に表示されているものをRemoteListに登録\r
1259                 // 同名ファイルチェック用\r
1260                 RemoteList = NULL;\r
1261                 AddRemoteTreeToFileList(AskCurrentFileListNum(), "", RDIR_NONE, &RemoteList);\r
1262 \r
1263                 FirstAdd = YES;\r
1264                 ExistNotify = YES;\r
1265 \r
1266                 Pos = FileListBase;\r
1267                 while(Pos != NULL)\r
1268                 {\r
1269                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1270                         SetSlashTail(Pkt.RemoteFile);\r
1271                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1272 \r
1273                         strcat(Pkt.RemoteFile, Pos->File);\r
1274                         if(FnameCnv == FNAME_LOWER)\r
1275                                 _mbslwr(Cat);\r
1276                         else if(FnameCnv == FNAME_UPPER)\r
1277                                 _mbsupr(Cat);\r
1278                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1279 #if defined(HAVE_TANDEM)\r
1280                         Pkt.FileCode = 0;\r
1281                         Pkt.PriExt = DEF_PRIEXT;\r
1282                         Pkt.SecExt = DEF_SECEXT;\r
1283                         Pkt.MaxExt = DEF_MAXEXT;\r
1284 #endif\r
1285 \r
1286                         if(AskHostType() == HTYPE_ACOS)\r
1287                         {\r
1288                                 strcpy(Pkt.RemoteFile, "'");\r
1289                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
1290                                 strcat(Pkt.RemoteFile, "(");\r
1291                                 strcat(Pkt.RemoteFile, Cat);\r
1292                                 strcat(Pkt.RemoteFile, ")");\r
1293                                 strcat(Pkt.RemoteFile, "'");\r
1294                         }\r
1295                         else if(AskHostType() == HTYPE_ACOS_4)\r
1296                                 strcpy(Pkt.RemoteFile, Cat);\r
1297 \r
1298                         if(Pos->Node == NODE_DIR)\r
1299                         {\r
1300                                 // フォルダの場合\r
1301 \r
1302                                 // ホスト側のファイル一覧をRemoteListに登録\r
1303                                 // 同名ファイルチェック用\r
1304                                 if(RemoteList != NULL)\r
1305                                         DeleteFileList(&RemoteList);\r
1306                                 RemoteList = NULL;\r
1307 \r
1308                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1309                                 if(DoCWD(Pkt.RemoteFile, NO, NO, NO) == FTP_COMPLETE)\r
1310                                 {\r
1311                                         if(DoDirListCmdSkt("", "", 998, &CancelFlg) == FTP_COMPLETE)\r
1312                                                 AddRemoteTreeToFileList(998, "", RDIR_NONE, &RemoteList);\r
1313                                         DoCWD(Tmp, NO, NO, NO);\r
1314                                 }\r
1315                                 else\r
1316                                 {\r
1317                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1318                                         {\r
1319                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1320                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1321                                                 AddTransFileList(&Pkt1);\r
1322                                         }\r
1323                                         FirstAdd = NO;\r
1324                                         strcpy(Pkt.Cmd, "MKD ");\r
1325                                         strcpy(Pkt.LocalFile, "");\r
1326                                         AddTransFileList(&Pkt);\r
1327                                 }\r
1328                         }\r
1329                         else if(Pos->Node == NODE_FILE)\r
1330                         {\r
1331                                 // ファイルの場合\r
1332                                 strcpy(Pkt.LocalFile, Cur);\r
1333                                 SetYenTail(Pkt.LocalFile);\r
1334                                 strcat(Pkt.LocalFile, Pos->File);\r
1335                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1336 \r
1337                                 strcpy(Pkt.Cmd, "STOR ");\r
1338                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1339                                 Pkt.Size = 0;\r
1340                                 Pkt.Time = Pos->Time;\r
1341                                 Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile);\r
1342                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1343                                 // UTF-8対応\r
1344                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1345                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1346 #if defined(HAVE_TANDEM)\r
1347                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1348                                         int a = Pos->InfoExist && FINFO_SIZE;\r
1349                                         CalcExtentSize(&Pkt, Pos->Size);\r
1350                                 }\r
1351 #endif\r
1352                                 // ディレクトリ自動作成\r
1353                                 strcpy(Tmp, Pkt.RemoteFile);\r
1354                                 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
1355                                 if(Pkt.Mode == EXIST_ABORT)\r
1356                                         break;\r
1357                                 else if(Pkt.Mode != EXIST_IGNORE)\r
1358                                 {\r
1359                                         // ディレクトリ自動作成\r
1360                                         if(MakeAllDir == YES)\r
1361                                         {\r
1362                                                 if(MakeDirFromRemotePath(Pkt.RemoteFile, Tmp, FirstAdd) == YES)\r
1363                                                         FirstAdd = NO;\r
1364                                         }\r
1365                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1366                                         {\r
1367                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1368                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1369                                                 AddTransFileList(&Pkt1);\r
1370                                         }\r
1371                                         FirstAdd = NO;\r
1372                                         AddTransFileList(&Pkt);\r
1373                                 }\r
1374                         }\r
1375                         Pos = Pos->Next;\r
1376                 }\r
1377 \r
1378                 if((FirstAdd == NO) && (AskNoFullPathMode() == YES))\r
1379                 {\r
1380                         strcpy(Pkt.Cmd, "BACKCUR");\r
1381                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1382                         AddTransFileList(&Pkt);\r
1383                 }\r
1384 \r
1385                 if(RemoteList != NULL)\r
1386                         DeleteFileList(&RemoteList);\r
1387 \r
1388                 DeleteFileList(&FileListBase);\r
1389 \r
1390                 // 同時接続対応\r
1391 //              strcpy(Pkt.Cmd, "GOQUIT");\r
1392 //              AddTransFileList(&Pkt);\r
1393 \r
1394                 // バグ対策\r
1395                 AddNullTransFileList();\r
1396 \r
1397                 GoForwardTransWindow();\r
1398 \r
1399                 EnableUserOpe();\r
1400         }\r
1401         return;\r
1402 }\r
1403 \r
1404 \r
1405 /*----- ミラーリングアップロードを行う ----------------------------------------\r
1406 *\r
1407 *       Parameter\r
1408 *               int Notify : 確認を行うかどうか (YES/NO)\r
1409 *\r
1410 *       Return Value\r
1411 *               なし\r
1412 *----------------------------------------------------------------------------*/\r
1413 \r
1414 void MirrorUploadProc(int Notify)\r
1415 {\r
1416         FILELIST *LocalListBase;\r
1417         FILELIST *RemoteListBase;\r
1418         FILELIST *LocalPos;\r
1419         FILELIST *RemotePos;\r
1420         TRANSPACKET Pkt;\r
1421         TRANSPACKET *Base;\r
1422         char Name[FMAX_PATH+1];\r
1423         char *Cat;\r
1424         int Level;\r
1425         int Mode;\r
1426         SYSTEMTIME TmpStime;\r
1427         FILETIME TmpFtimeL;\r
1428         FILETIME TmpFtimeR;\r
1429 \r
1430         // 同時接続対応\r
1431         CancelFlg = NO;\r
1432 \r
1433         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1434         {\r
1435                 DisableUserOpe();\r
1436 \r
1437                 Base = NULL;\r
1438 \r
1439                 if(Notify == YES)\r
1440                         Notify = DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_up_dlg), GetMainHwnd(), MirrorNotifyCallBack, 1);\r
1441                 else\r
1442                         Notify = YES;\r
1443 \r
1444                 if((Notify == YES) || (Notify == YES_LIST))\r
1445                 {\r
1446                         /*===== ファイルリスト取得 =====*/\r
1447 \r
1448                         LocalListBase = NULL;\r
1449                         MakeSelectedFileList(WIN_LOCAL, YES, YES, &LocalListBase, &CancelFlg);\r
1450                         RemoteListBase = NULL;\r
1451                         MakeSelectedFileList(WIN_REMOTE, YES, YES, &RemoteListBase, &CancelFlg);\r
1452 \r
1453                         LocalPos = LocalListBase;\r
1454                         while(LocalPos != NULL)\r
1455                         {\r
1456                                 LocalPos->Attr = YES;           /* LocalPos->Attrは転送するかどうかのフラグに使用 (YES/NO) */\r
1457                                 LocalPos = LocalPos->Next;\r
1458                         }\r
1459 \r
1460                         RemotePos = RemoteListBase;\r
1461                         while(RemotePos != NULL)\r
1462                         {\r
1463                                 if(AskMirrorNoTrn(RemotePos->File, 1) == NO)\r
1464                                 {\r
1465                                         RemotePos->Attr = YES;\r
1466                                         RemotePos = RemotePos->Next;\r
1467                                 }\r
1468                                 else\r
1469                                 {\r
1470                                         RemotePos->Attr = NO;   /* RemotePos->Attrは削除するかどうかのフラグに使用 (YES/NO) */\r
1471 \r
1472                                         if(RemotePos->Node == NODE_DIR)\r
1473                                         {\r
1474                                                 Level = AskDirLevel(RemotePos->File);\r
1475                                                 RemotePos = RemotePos->Next;\r
1476                                                 while(RemotePos != NULL)\r
1477                                                 {\r
1478                                                         if((RemotePos->Node == NODE_DIR) &&\r
1479                                                            (AskDirLevel(RemotePos->File) <= Level))\r
1480                                                         {\r
1481                                                                 break;\r
1482                                                         }\r
1483                                                         RemotePos->Attr = NO;\r
1484                                                         RemotePos = RemotePos->Next;\r
1485                                                 }\r
1486                                         }\r
1487                                         else\r
1488                                                 RemotePos = RemotePos->Next;\r
1489                                 }\r
1490                         }\r
1491 \r
1492                         /*===== ファイルリスト比較 =====*/\r
1493 \r
1494                         LocalPos = LocalListBase;\r
1495                         while(LocalPos != NULL)\r
1496                         {\r
1497                                 if(AskMirrorNoTrn(LocalPos->File, 0) == NO)\r
1498                                 {\r
1499                                         strcpy(Name, LocalPos->File);\r
1500                                         ReplaceAll(Name, '\\', '/');\r
1501 \r
1502                                         if(MirrorFnameCnv == YES)\r
1503                                                 Mode = COMP_LOWERMATCH;\r
1504                                         else\r
1505                                                 Mode = COMP_STRICT;\r
1506 \r
1507                                         if(LocalPos->Node == NODE_DIR)\r
1508                                         {\r
1509                                                 if((RemotePos = SearchFileList(Name, RemoteListBase, Mode)) != NULL)\r
1510                                                 {\r
1511                                                         if(RemotePos->Node == NODE_DIR)\r
1512                                                         {\r
1513                                                                 RemotePos->Attr = NO;\r
1514                                                                 LocalPos->Attr = NO;\r
1515                                                         }\r
1516                                                 }\r
1517                                         }\r
1518                                         else if(LocalPos->Node == NODE_FILE)\r
1519                                         {\r
1520                                                 if((RemotePos = SearchFileList(Name, RemoteListBase, Mode)) != NULL)\r
1521                                                 {\r
1522                                                         if(RemotePos->Node == NODE_FILE)\r
1523                                                         {\r
1524                                                                 FileTimeToLocalFileTime(&LocalPos->Time, &TmpFtimeL);\r
1525                                                                 FileTimeToLocalFileTime(&RemotePos->Time, &TmpFtimeR);\r
1526                                                                 if((RemotePos->InfoExist & FINFO_TIME) == 0)\r
1527                                                                 {\r
1528                                                                         FileTimeToSystemTime(&TmpFtimeL, &TmpStime);\r
1529                                                                         TmpStime.wHour = 0;\r
1530                                                                         TmpStime.wMinute = 0;\r
1531                                                                         TmpStime.wSecond = 0;\r
1532                                                                         TmpStime.wMilliseconds = 0;\r
1533                                                                         SystemTimeToFileTime(&TmpStime, &TmpFtimeL);\r
1534 \r
1535                                                                         FileTimeToSystemTime(&TmpFtimeR, &TmpStime);\r
1536                                                                         TmpStime.wHour = 0;\r
1537                                                                         TmpStime.wMinute = 0;\r
1538                                                                         TmpStime.wSecond = 0;\r
1539                                                                         TmpStime.wMilliseconds = 0;\r
1540                                                                         SystemTimeToFileTime(&TmpStime, &TmpFtimeR);\r
1541                                                                 }\r
1542                                                                 RemotePos->Attr = NO;\r
1543                                                                 if(CompareFileTime(&TmpFtimeL, &TmpFtimeR) <= 0)\r
1544                                                                         LocalPos->Attr = NO;\r
1545                                                         }\r
1546                                                 }\r
1547                                         }\r
1548 \r
1549                                         LocalPos = LocalPos->Next;\r
1550                                 }\r
1551                                 else\r
1552                                 {\r
1553                                         if(LocalPos->Node == NODE_FILE)\r
1554                                         {\r
1555                                                 LocalPos->Attr = NO;\r
1556                                                 LocalPos = LocalPos->Next;\r
1557                                         }\r
1558                                         else\r
1559                                         {\r
1560                                                 LocalPos->Attr = NO;\r
1561                                                 Level = AskDirLevel(LocalPos->File);\r
1562                                                 LocalPos = LocalPos->Next;\r
1563                                                 while(LocalPos != NULL)\r
1564                                                 {\r
1565                                                         if((LocalPos->Node == NODE_DIR) &&\r
1566                                                            (AskDirLevel(LocalPos->File) <= Level))\r
1567                                                         {\r
1568                                                                 break;\r
1569                                                         }\r
1570                                                         LocalPos->Attr = NO;\r
1571                                                         LocalPos = LocalPos->Next;\r
1572                                                 }\r
1573                                         }\r
1574                                 }\r
1575                         }\r
1576 \r
1577                         DispMirrorFiles(LocalListBase, RemoteListBase);\r
1578 \r
1579                         /*===== 削除/アップロード =====*/\r
1580 \r
1581                         RemotePos = RemoteListBase;\r
1582                         while(RemotePos != NULL)\r
1583                         {\r
1584                                 if((RemotePos->Attr == YES) && (RemotePos->Node == NODE_FILE))\r
1585                                 {\r
1586                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1587                                         SetSlashTail(Pkt.RemoteFile);\r
1588                                         strcat(Pkt.RemoteFile, RemotePos->File);\r
1589                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1590                                         strcpy(Pkt.LocalFile, "");\r
1591                                         strcpy(Pkt.Cmd, "R-DELE ");\r
1592                                         AddTmpTransFileList(&Pkt, &Base);\r
1593                                 }\r
1594                                 RemotePos = RemotePos->Next;\r
1595                         }\r
1596                         MirrorDeleteAllDir(RemoteListBase, &Pkt, &Base);\r
1597 \r
1598                         LocalPos = LocalListBase;\r
1599                         while(LocalPos != NULL)\r
1600                         {\r
1601                                 if(LocalPos->Attr == YES)\r
1602                                 {\r
1603                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1604                                         SetSlashTail(Pkt.RemoteFile);\r
1605                                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1606                                         strcat(Pkt.RemoteFile, LocalPos->File);\r
1607 \r
1608                                         if(MirrorFnameCnv == YES)\r
1609                                                 _mbslwr(Cat);\r
1610 \r
1611                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1612 \r
1613                                         if(LocalPos->Node == NODE_DIR)\r
1614                                         {\r
1615                                                 strcpy(Pkt.LocalFile, "");\r
1616                                                 strcpy(Pkt.Cmd, "R-MKD ");\r
1617                                                 AddTmpTransFileList(&Pkt, &Base);\r
1618                                         }\r
1619                                         else if(LocalPos->Node == NODE_FILE)\r
1620                                         {\r
1621                                                 AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
1622                                                 SetYenTail(Pkt.LocalFile);\r
1623                                                 strcat(Pkt.LocalFile, LocalPos->File);\r
1624                                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1625 \r
1626                                                 strcpy(Pkt.Cmd, "STOR ");\r
1627                                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1628                                                 Pkt.Size = 0;\r
1629                                                 Pkt.Time = LocalPos->Time;\r
1630                                                 Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile);\r
1631                                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1632                                                 // UTF-8対応\r
1633                                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1634                                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1635 #if defined(HAVE_TANDEM)\r
1636                                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1637                                                         CalcExtentSize(&Pkt, LocalPos->Size);\r
1638                                                 }\r
1639 #endif\r
1640                                                 Pkt.Mode = EXIST_OVW;\r
1641                                                 AddTmpTransFileList(&Pkt, &Base);\r
1642                                         }\r
1643                                 }\r
1644                                 LocalPos = LocalPos->Next;\r
1645                         }\r
1646 \r
1647                         if((Notify == YES) ||\r
1648                            (DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_notify_dlg), GetMainHwnd(), MirrorDispListCallBack, (LPARAM)&Base) == YES))\r
1649                         {\r
1650                                 if(AskNoFullPathMode() == YES)\r
1651                                 {\r
1652                                         strcpy(Pkt.Cmd, "SETCUR");\r
1653                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1654                                         AddTransFileList(&Pkt);\r
1655                                 }\r
1656                                 AppendTransFileList(Base);\r
1657 \r
1658                                 if(AskNoFullPathMode() == YES)\r
1659                                 {\r
1660                                         strcpy(Pkt.Cmd, "BACKCUR");\r
1661                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1662                                         AddTransFileList(&Pkt);\r
1663                                 }\r
1664 \r
1665                                 // 同時接続対応\r
1666 //                              strcpy(Pkt.Cmd, "GOQUIT");\r
1667 //                              AddTransFileList(&Pkt);\r
1668                         }\r
1669                         else\r
1670                                 EraseTmpTransFileList(&Base);\r
1671 \r
1672                         // バグ対策\r
1673                         AddNullTransFileList();\r
1674 \r
1675                         DeleteFileList(&LocalListBase);\r
1676                         DeleteFileList(&RemoteListBase);\r
1677 \r
1678                         GoForwardTransWindow();\r
1679                 }\r
1680 \r
1681                 EnableUserOpe();\r
1682         }\r
1683         return;\r
1684 }\r
1685 \r
1686 \r
1687 /*----- ミラーリング時のホスト側のフォルダ削除 --------------------------------\r
1688 *\r
1689 *       Parameter\r
1690 *               FILELIST *Base : ファイルリスト\r
1691 *               TRANSPACKET *Pkt : \r
1692 *               TRANSPACKET **Base : \r
1693 *\r
1694 *       Return Value\r
1695 *               なし\r
1696 *----------------------------------------------------------------------------*/\r
1697 \r
1698 static void MirrorDeleteAllDir(FILELIST *Remote, TRANSPACKET *Pkt, TRANSPACKET **Base)\r
1699 {\r
1700         while(Remote != NULL)\r
1701         {\r
1702                 if(Remote->Node == NODE_DIR)\r
1703                 {\r
1704                         MirrorDeleteAllDir(Remote->Next, Pkt, Base);\r
1705 \r
1706                         if(Remote->Attr == YES)\r
1707                         {\r
1708                                 AskRemoteCurDir(Pkt->RemoteFile, FMAX_PATH);\r
1709                                 SetSlashTail(Pkt->RemoteFile);\r
1710                                 strcat(Pkt->RemoteFile, Remote->File);\r
1711                                 ReplaceAll(Pkt->RemoteFile, '\\', '/');\r
1712                                 strcpy(Pkt->LocalFile, "");\r
1713                                 strcpy(Pkt->Cmd, "R-RMD ");\r
1714                                 AddTmpTransFileList(Pkt, Base);\r
1715                         }\r
1716                         break;\r
1717                 }\r
1718                 Remote = Remote->Next;\r
1719         }\r
1720         return;\r
1721 }\r
1722 \r
1723 \r
1724 /*----- ミラーリングアップロード開始確認ウインドウのコールバック --------------\r
1725 *\r
1726 *       Parameter\r
1727 *               HWND hDlg : ウインドウハンドル\r
1728 *               UINT message : メッセージ番号\r
1729 *               WPARAM wParam : メッセージの WPARAM 引数\r
1730 *               LPARAM lParam : メッセージの LPARAM 引数\r
1731 *\r
1732 *       Return Value\r
1733 *               BOOL TRUE/FALSE\r
1734 *----------------------------------------------------------------------------*/\r
1735 \r
1736 // 64ビット対応\r
1737 //static BOOL CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1738 static INT_PTR CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1739 {\r
1740         static int Mode;\r
1741 \r
1742         switch (iMessage)\r
1743         {\r
1744                 case WM_INITDIALOG :\r
1745                         Mode = lParam;\r
1746                         return(TRUE);\r
1747 \r
1748                 case WM_COMMAND :\r
1749                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1750                         {\r
1751                                 case IDOK :\r
1752                                         EndDialog(hDlg, YES);\r
1753                                         break;\r
1754 \r
1755                                 case IDCANCEL :\r
1756                                         EndDialog(hDlg, NO);\r
1757                                         break;\r
1758 \r
1759                                 case MIRRORUP_DISP :\r
1760                                         EndDialog(hDlg, YES_LIST);\r
1761                                         break;\r
1762 \r
1763                                 case IDHELP :\r
1764                                         if(Mode == 0)\r
1765                                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000013);\r
1766                                         else\r
1767                                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000012);\r
1768                         }\r
1769             return(TRUE);\r
1770         }\r
1771         return(FALSE);\r
1772 }\r
1773 \r
1774 \r
1775 /*----- ミラーリングアップロード処理内容確認ウインドウのコールバック ----------\r
1776 *\r
1777 *       Parameter\r
1778 *               HWND hDlg : ウインドウハンドル\r
1779 *               UINT message : メッセージ番号\r
1780 *               WPARAM wParam : メッセージの WPARAM 引数\r
1781 *               LPARAM lParam : メッセージの LPARAM 引数\r
1782 *\r
1783 *       Return Value\r
1784 *               BOOL TRUE/FALSE\r
1785 *----------------------------------------------------------------------------*/\r
1786 \r
1787 // 64ビット対応\r
1788 //static BOOL CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1789 static INT_PTR CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1790 {\r
1791         static DIALOGSIZE DlgSize = {\r
1792                 { MIRROR_DEL, MIRROR_SIZEGRIP, -1 },\r
1793                 { IDOK, IDCANCEL, IDHELP, MIRROR_DEL, MIRROR_COPYNUM, MIRROR_MAKENUM, MIRROR_DELNUM, MIRROR_SIZEGRIP, -1 },\r
1794                 { MIRROR_LIST, -1 },\r
1795                 { 0, 0 },\r
1796                 { 0, 0 }\r
1797         };\r
1798 \r
1799         static TRANSPACKET **Base;\r
1800         TRANSPACKET *Pos;\r
1801         char Tmp[FMAX_PATH+1+6];\r
1802         int Num;\r
1803         int *List;\r
1804 \r
1805         switch (iMessage)\r
1806         {\r
1807                 case WM_INITDIALOG :\r
1808                         Base = (TRANSPACKET **)lParam;\r
1809                         Pos = *Base;\r
1810                         while(Pos != NULL)\r
1811                         {\r
1812                                 strcpy(Tmp, "");\r
1813                                 if((strncmp(Pos->Cmd, "R-DELE", 6) == 0) ||\r
1814                                    (strncmp(Pos->Cmd, "R-RMD", 5) == 0))\r
1815                                         sprintf(Tmp, MSGJPN052, Pos->RemoteFile);\r
1816                                 else if(strncmp(Pos->Cmd, "R-MKD", 5) == 0)\r
1817                                         sprintf(Tmp, MSGJPN053, Pos->RemoteFile);\r
1818                                 else if(strncmp(Pos->Cmd, "STOR", 4) == 0)\r
1819                                         sprintf(Tmp, MSGJPN054, Pos->RemoteFile);\r
1820                                 else if((strncmp(Pos->Cmd, "L-DELE", 6) == 0) ||\r
1821                                                 (strncmp(Pos->Cmd, "L-RMD", 5) == 0))\r
1822                                         sprintf(Tmp, MSGJPN055, Pos->LocalFile);\r
1823                                 else if(strncmp(Pos->Cmd, "L-MKD", 5) == 0)\r
1824                                         sprintf(Tmp, MSGJPN056, Pos->LocalFile);\r
1825                                 else if(strncmp(Pos->Cmd, "RETR", 4) == 0)\r
1826                                         sprintf(Tmp, MSGJPN057, Pos->LocalFile);\r
1827 \r
1828                                 if(strlen(Tmp) > 0)\r
1829                                         SendDlgItemMessage(hDlg, MIRROR_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
1830                                 Pos = Pos->Next;\r
1831                         }\r
1832                         CountMirrorFiles(hDlg, *Base);\r
1833                         DlgSizeInit(hDlg, &DlgSize, &MirrorDlgSize);\r
1834                         EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), FALSE);\r
1835                         return(TRUE);\r
1836 \r
1837                 case WM_COMMAND :\r
1838                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1839                         {\r
1840                                 case IDOK :\r
1841                                         AskDlgSize(hDlg, &DlgSize, &MirrorDlgSize);\r
1842                                         EndDialog(hDlg, YES);\r
1843                                         break;\r
1844 \r
1845                                 case IDCANCEL :\r
1846                                         AskDlgSize(hDlg, &DlgSize, &MirrorDlgSize);\r
1847                                         EndDialog(hDlg, NO);\r
1848                                         break;\r
1849 \r
1850                                 case MIRROR_DEL :\r
1851                                         Num = SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELCOUNT, 0, 0);\r
1852                                         if((List = malloc(Num * sizeof(int))) != NULL)\r
1853                                         {\r
1854                                                 Num = SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELITEMS, Num, (LPARAM)List);\r
1855                                                 for(Num--; Num >= 0; Num--)\r
1856                                                 {\r
1857                                                         if(RemoveTmpTransFileListItem(Base, List[Num]) == FFFTP_SUCCESS)\r
1858                                                                 SendDlgItemMessage(hDlg, MIRROR_LIST, LB_DELETESTRING, List[Num], 0);\r
1859                                                         else\r
1860                                                                 MessageBeep(-1);\r
1861                                                 }\r
1862                                                 free(List);\r
1863                                                 CountMirrorFiles(hDlg, *Base);\r
1864                                         }\r
1865                                         break;\r
1866 \r
1867                                 case MIRROR_LIST :\r
1868                                         switch(GET_WM_COMMAND_CMD(wParam, lParam))\r
1869                                         {\r
1870                                                 case LBN_SELCHANGE :\r
1871                                                         if(SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELCOUNT, 0, 0) > 0)\r
1872                                                                 EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), TRUE);\r
1873                                                         else\r
1874                                                                 EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), FALSE);\r
1875                                                         break;\r
1876                                         }\r
1877                                         break;\r
1878 \r
1879                                 case IDHELP :\r
1880                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000012);\r
1881                         }\r
1882             return(TRUE);\r
1883 \r
1884                 case WM_SIZING :\r
1885                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
1886                     return(TRUE);\r
1887         }\r
1888         return(FALSE);\r
1889 }\r
1890 \r
1891 \r
1892 /*----- ミラーリングで転送/削除するファイルの数を数えダイアログに表示---------\r
1893 *\r
1894 *       Parameter\r
1895 *               HWND hWnd : \r
1896 *               TRANSPACKET *Pkt : \r
1897 *\r
1898 *       Return Value\r
1899 *               なし\r
1900 *----------------------------------------------------------------------------*/\r
1901 \r
1902 static void CountMirrorFiles(HWND hDlg, TRANSPACKET *Pkt)\r
1903 {\r
1904         char Tmp[80];\r
1905         int Del;\r
1906         int Make;\r
1907         int Copy;\r
1908 \r
1909         Del = 0;\r
1910         Make = 0;\r
1911         Copy = 0;\r
1912         while(Pkt != NULL)\r
1913         {\r
1914                 if((strncmp(Pkt->Cmd, "R-DELE", 6) == 0) ||\r
1915                    (strncmp(Pkt->Cmd, "R-RMD", 5) == 0) ||\r
1916                    (strncmp(Pkt->Cmd, "L-DELE", 6) == 0) ||\r
1917                    (strncmp(Pkt->Cmd, "L-RMD", 5) == 0))\r
1918                 {\r
1919                         Del += 1;\r
1920                 }\r
1921                 else if((strncmp(Pkt->Cmd, "R-MKD", 5) == 0) ||\r
1922                                 (strncmp(Pkt->Cmd, "L-MKD", 5) == 0))\r
1923                 {\r
1924                         Make += 1;\r
1925                 }\r
1926                 else if((strncmp(Pkt->Cmd, "STOR", 4) == 0) ||\r
1927                                 (strncmp(Pkt->Cmd, "RETR", 4) == 0))\r
1928                 {\r
1929                         Copy += 1;\r
1930                 }\r
1931                 Pkt = Pkt->Next;\r
1932         }\r
1933 \r
1934         if(Copy != 0)\r
1935                 sprintf(Tmp, MSGJPN058, Copy);\r
1936         else\r
1937                 sprintf(Tmp, MSGJPN059);\r
1938         SendDlgItemMessage(hDlg, MIRROR_COPYNUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1939 \r
1940         if(Make != 0)\r
1941                 sprintf(Tmp, MSGJPN060, Make);\r
1942         else\r
1943                 sprintf(Tmp, MSGJPN061);\r
1944         SendDlgItemMessage(hDlg, MIRROR_MAKENUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1945 \r
1946         if(Del != 0)\r
1947                 sprintf(Tmp, MSGJPN062, Del);\r
1948         else\r
1949                 sprintf(Tmp, MSGJPN063);\r
1950         SendDlgItemMessage(hDlg, MIRROR_DELNUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1951 \r
1952         return;\r
1953 }\r
1954 \r
1955 \r
1956 \r
1957 \r
1958 /*----- ミラーリングで転送/削除しないファイルかどうかを返す ------------------\r
1959 *\r
1960 *       Parameter\r
1961 *               char Fname : ファイル名\r
1962 *               int Mode : モード\r
1963 *                       0=転送しないファイル, 1=削除しないファイル\r
1964 *\r
1965 *       Return Value\r
1966 *               int ステータス\r
1967 *                       YES=転送・削除しない/NO\r
1968 *----------------------------------------------------------------------------*/\r
1969 \r
1970 static int AskMirrorNoTrn(char *Fname, int Mode)\r
1971 {\r
1972         int Ret;\r
1973         char *Tbl;\r
1974 \r
1975         Tbl = MirrorNoTrn;\r
1976         if(Mode == 1)\r
1977                 Tbl = MirrorNoDel;\r
1978 \r
1979         Ret = NO;\r
1980         if(StrMultiLen(Tbl) > 0)\r
1981         {\r
1982                 Fname = GetFileName(Fname);\r
1983                 while(*Tbl != NUL)\r
1984                 {\r
1985                         if(CheckFname(Fname, Tbl) == FFFTP_SUCCESS)\r
1986                         {\r
1987                                 Ret = YES;\r
1988                                 break;\r
1989                         }\r
1990                         Tbl += strlen(Tbl) + 1;\r
1991                 }\r
1992         }\r
1993         return(Ret);\r
1994 }\r
1995 \r
1996 \r
1997 /*----- アップロードするファイルの属性を返す ----------------------------------\r
1998 *\r
1999 *       Parameter\r
2000 *               char Fname : ファイル名\r
2001 *\r
2002 *       Return Value\r
2003 *               int 属性 (-1=設定なし)\r
2004 *----------------------------------------------------------------------------*/\r
2005 \r
2006 static int AskUploadFileAttr(char *Fname)\r
2007 {\r
2008         int Ret;\r
2009         int Sts;\r
2010         char *Tbl;\r
2011 \r
2012         Tbl = DefAttrList;\r
2013         Fname = GetFileName(Fname);\r
2014         Ret = -1;\r
2015         while(*Tbl != NUL)\r
2016         {\r
2017                 Sts = CheckFname(Fname, Tbl);\r
2018                 Tbl += strlen(Tbl) + 1;\r
2019 \r
2020                 if((Sts == FFFTP_SUCCESS) && (*Tbl != NUL))\r
2021                 {\r
2022                         Ret = xtoi(Tbl);\r
2023                         break;\r
2024                 }\r
2025                 Tbl += strlen(Tbl) + 1;\r
2026         }\r
2027         return(Ret);\r
2028 }\r
2029 \r
2030 \r
2031 /*----- ホストに同じ名前のファイルがないかチェック- ---------------------------a\r
2032 *\r
2033 *       Parameter\r
2034 *               TRANSPACKET *Pkt : 転送ファイル情報\r
2035 *               FILELIST *ListList : \r
2036 *\r
2037 *       Return Value\r
2038 *               int 処理方法\r
2039 *                       EXIST_OVW/EXIST_UNIQUE/EXIST_IGNORE\r
2040 *\r
2041 *       Note\r
2042 *               Pkt.ExistSize, UpExistMode、ExistNotify が変更される\r
2043 *----------------------------------------------------------------------------*/\r
2044 \r
2045 static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList)\r
2046 {\r
2047         int Ret;\r
2048 #if defined(HAVE_TANDEM)\r
2049         int Mode;\r
2050 #endif\r
2051         FILELIST *Exist;\r
2052 \r
2053         Ret = EXIST_OVW;\r
2054         Pkt->ExistSize = 0;\r
2055         if(SendMode != TRANS_OVW)\r
2056         {\r
2057 #if defined(HAVE_TANDEM)\r
2058                 /* HP NonStop Server は大文字小文字の区別なし(すべて大文字) */\r
2059                 if(AskHostType() == HTYPE_TANDEM)\r
2060                         Mode = COMP_IGNORE;\r
2061                 else\r
2062                         Mode = COMP_STRICT;\r
2063 \r
2064                 if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, Mode)) != NULL)\r
2065 #else\r
2066                 if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, COMP_STRICT)) != NULL)\r
2067 #endif\r
2068                 {\r
2069                         Pkt->ExistSize = Exist->Size;\r
2070 \r
2071                         if(ExistNotify == YES)\r
2072                         {\r
2073                                 SoundPlay(SND_ERROR);\r
2074                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(up_exist_dlg), GetMainHwnd(), UpExistDialogCallBack, (LPARAM)Pkt) == NO)\r
2075                                         Ret = EXIST_ABORT;\r
2076                                 else\r
2077                                         Ret = UpExistMode;\r
2078                         }\r
2079                         else\r
2080                                 Ret = UpExistMode;\r
2081 \r
2082                         if(Ret == EXIST_NEW)\r
2083                         {\r
2084                                 /*ファイル日付チェック */\r
2085                                 if(CompareFileTime(&Exist->Time, &Pkt->Time) < 0)\r
2086                                         Ret = EXIST_OVW;\r
2087                                 else\r
2088                                         Ret = EXIST_IGNORE;\r
2089                         }\r
2090                 }\r
2091         }\r
2092         return(Ret);\r
2093 }\r
2094 \r
2095 \r
2096 /*----- ホストに同じ名前のファイルがある時の確認ダイアログのコールバック ------\r
2097 *\r
2098 *       Parameter\r
2099 *               HWND hDlg : ウインドウハンドル\r
2100 *               UINT message : メッセージ番号\r
2101 *               WPARAM wParam : メッセージの WPARAM 引数\r
2102 *               LPARAM lParam : メッセージの LPARAM 引数\r
2103 *\r
2104 *       Return Value\r
2105 *               BOOL TRUE/FALSE\r
2106 *----------------------------------------------------------------------------*/\r
2107 \r
2108 // 64ビット対応\r
2109 //static BOOL CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2110 static INT_PTR CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2111 {\r
2112         static TRANSPACKET *Pkt;\r
2113         static const RADIOBUTTON UpExistButton[] = {\r
2114                 { UP_EXIST_OVW, EXIST_OVW },\r
2115                 { UP_EXIST_NEW, EXIST_NEW },\r
2116                 { UP_EXIST_RESUME, EXIST_RESUME },\r
2117                 { UP_EXIST_UNIQUE, EXIST_UNIQUE },\r
2118                 { UP_EXIST_IGNORE, EXIST_IGNORE }\r
2119         };\r
2120         #define UPEXISTBUTTONS  (sizeof(UpExistButton)/sizeof(RADIOBUTTON))\r
2121 \r
2122         switch (iMessage)\r
2123         {\r
2124                 case WM_INITDIALOG :\r
2125                         Pkt = (TRANSPACKET *)lParam;\r
2126                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, EM_LIMITTEXT, FMAX_PATH, 0);\r
2127                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, WM_SETTEXT, 0, (LPARAM)Pkt->RemoteFile);\r
2128 \r
2129                         if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
2130                                 EnableWindow(GetDlgItem(hDlg, UP_EXIST_RESUME), FALSE);\r
2131 \r
2132                         SetRadioButtonByValue(hDlg, UpExistMode, UpExistButton, UPEXISTBUTTONS);\r
2133                         return(TRUE);\r
2134 \r
2135                 case WM_COMMAND :\r
2136                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2137                         {\r
2138                                 case IDOK_ALL :\r
2139                                         ExistNotify = NO;\r
2140                                         /* ここに break はない */\r
2141 \r
2142                                 case IDOK :\r
2143                                         UpExistMode = AskRadioButtonValue(hDlg, UpExistButton, UPEXISTBUTTONS);\r
2144                                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, WM_GETTEXT, FMAX_PATH, (LPARAM)Pkt->RemoteFile);\r
2145                                         EndDialog(hDlg, YES);\r
2146                                         break;\r
2147 \r
2148                                 case IDCANCEL :\r
2149 //                                      Pkt->Abort = ABORT_USER;\r
2150 //                                      UpExistMode = EXIST_IGNORE;\r
2151                                         EndDialog(hDlg, NO);\r
2152                                         break;\r
2153 \r
2154                                 case IDHELP :\r
2155                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000011);\r
2156                                         break;\r
2157                         }\r
2158             return(TRUE);\r
2159         }\r
2160         return(FALSE);\r
2161 }\r
2162 \r
2163 \r
2164 /*----- アップロード/ダウンロードファイル名入力ダイアログのコールバック ------\r
2165 *\r
2166 *       Parameter\r
2167 *               HWND hDlg : ウインドウハンドル\r
2168 *               UINT message : メッセージ番号\r
2169 *               WPARAM wParam : メッセージの WPARAM 引数\r
2170 *               LPARAM lParam : メッセージの LPARAM 引数\r
2171 *\r
2172 *       Return Value\r
2173 *               BOOL TRUE/FALSE\r
2174 *----------------------------------------------------------------------------*/\r
2175 \r
2176 // 64ビット対応\r
2177 //static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2178 static INT_PTR CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2179 {\r
2180         switch (iMessage)\r
2181         {\r
2182                 case WM_INITDIALOG :\r
2183                         if(CurWin == WIN_LOCAL)\r
2184                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN064);\r
2185                         else\r
2186                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN065);\r
2187 \r
2188                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2189                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2190                         SendDlgItemMessage(hDlg, UPDOWNAS_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2191                         return(TRUE);\r
2192 \r
2193                 case WM_COMMAND :\r
2194                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2195                         {\r
2196                                 case IDOK :\r
2197                                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2198                                         EndDialog(hDlg, YES);\r
2199                                         break;\r
2200 \r
2201                                 case UPDOWNAS_STOP :\r
2202                                         EndDialog(hDlg, NO_ALL);\r
2203                                         break;\r
2204                         }\r
2205             return(TRUE);\r
2206         }\r
2207         return(FALSE);\r
2208 }\r
2209 \r
2210 \r
2211 #if defined(HAVE_TANDEM)\r
2212 /*----- アップロード/ダウンロードファイル名入力ダイアログのコールバック ------\r
2213 *\r
2214 *       Parameter\r
2215 *               HWND hDlg : ウインドウハンドル\r
2216 *               UINT message : メッセージ番号\r
2217 *               WPARAM wParam : メッセージの WPARAM 引数\r
2218 *               LPARAM lParam : メッセージの LPARAM 引数\r
2219 *\r
2220 *       Return Value\r
2221 *               BOOL TRUE/FALSE\r
2222 *----------------------------------------------------------------------------*/\r
2223 \r
2224 static INT_PTR CALLBACK UpDownAsWithExtDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2225 {\r
2226         switch (iMessage)\r
2227         {\r
2228                 case WM_INITDIALOG :\r
2229                         if(CurWin == WIN_LOCAL)\r
2230                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN064);\r
2231                         else\r
2232                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN065);\r
2233 \r
2234                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2235                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2236                         SendDlgItemMessage(hDlg, UPDOWNAS_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2237                         SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, EM_LIMITTEXT, 4, 0);\r
2238                         SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, WM_SETTEXT, 0, (LPARAM)TmpFileCode);\r
2239 \r
2240                         return(TRUE);\r
2241 \r
2242                 case WM_COMMAND :\r
2243                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2244                         {\r
2245                                 case IDOK :\r
2246                                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2247                                         SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpFileCode);\r
2248                                         EndDialog(hDlg, YES);\r
2249                                         break;\r
2250 \r
2251                                 case UPDOWNAS_STOP :\r
2252                                         EndDialog(hDlg, NO_ALL);\r
2253                                         break;\r
2254                         }\r
2255             return(TRUE);\r
2256         }\r
2257         return(FALSE);\r
2258 }\r
2259 #endif\r
2260 \r
2261 \r
2262 /*----- ファイル一覧で指定されたファイルを削除する ----------------------------\r
2263 *\r
2264 *       Parameter\r
2265 *               なし\r
2266 *\r
2267 *       Return Value\r
2268 *               なし\r
2269 *----------------------------------------------------------------------------*/\r
2270 \r
2271 void DeleteProc(void)\r
2272 {\r
2273         int Win;\r
2274         FILELIST *FileListBase;\r
2275         FILELIST *Pos;\r
2276         int DelFlg;\r
2277         int Sts;\r
2278         char CurDir[FMAX_PATH+1];\r
2279         char Tmp[FMAX_PATH+1];\r
2280 \r
2281         // 同時接続対応\r
2282         CancelFlg = NO;\r
2283 \r
2284         // デッドロック対策\r
2285         DisableUserOpe();\r
2286         Sts = YES;\r
2287         AskRemoteCurDir(CurDir, FMAX_PATH);\r
2288         FileListBase = NULL;\r
2289         if(GetFocus() == GetLocalHwnd())\r
2290         {\r
2291                 Win = WIN_LOCAL;\r
2292                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2293         }\r
2294         else\r
2295         {\r
2296                 Win = WIN_REMOTE;\r
2297                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2298                         MakeSelectedFileList(Win, YES, NO, &FileListBase, &CancelFlg);\r
2299                 else\r
2300                         Sts = NO;\r
2301         }\r
2302 \r
2303         if(Sts == YES)\r
2304         {\r
2305                 // デッドロック対策\r
2306 //              DisableUserOpe();\r
2307 \r
2308                 DelFlg = NO;\r
2309                 Sts = NO;\r
2310                 Pos = FileListBase;\r
2311                 while(Pos != NULL)\r
2312                 {\r
2313                         if(Pos->Node == NODE_FILE)\r
2314                         {\r
2315                                 DelNotifyAndDo(Pos, Win, &Sts, &DelFlg, CurDir);\r
2316                                 if(Sts == NO_ALL)\r
2317                                         break;\r
2318                         }\r
2319                         Pos = Pos->Next;\r
2320                 }\r
2321 \r
2322                 if(Sts != NO_ALL)\r
2323                         DeleteAllDir(FileListBase, Win, &Sts, &DelFlg, CurDir);\r
2324 \r
2325                 if(Win == WIN_REMOTE)\r
2326                 {\r
2327                         AskRemoteCurDir(Tmp, FMAX_PATH);\r
2328                         if(strcmp(Tmp, CurDir) != 0)\r
2329                                 DoCWD(Tmp, NO, NO, NO);\r
2330                 }\r
2331 \r
2332                 DeleteFileList(&FileListBase);\r
2333 \r
2334                 if(DelFlg == YES)\r
2335                 {\r
2336                         if(Win == WIN_LOCAL)\r
2337                                 GetLocalDirForWnd();\r
2338                         else\r
2339                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2340                 }\r
2341 \r
2342                 // デッドロック対策\r
2343 //              EnableUserOpe();\r
2344         }\r
2345         // デッドロック対策\r
2346         EnableUserOpe();\r
2347         return;\r
2348 }\r
2349 \r
2350 \r
2351 /*----- サブディレクトリ以下を全て削除する ------------------------------------\r
2352 *\r
2353 *       Parameter\r
2354 *               FILELIST *Dt : 削除するファイルのリスト\r
2355 *               int Win : ウインドウ番号 (WIN_xxx)\r
2356 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2357 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2358 *               char *CurDir : カレントディレクトリ\r
2359 *\r
2360 *       Return Value\r
2361 *               なし\r
2362 *----------------------------------------------------------------------------*/\r
2363 \r
2364 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2365 {\r
2366         while(Dt != NULL)\r
2367         {\r
2368                 if(Dt->Node == NODE_DIR)\r
2369                 {\r
2370                         DeleteAllDir(Dt->Next, Win, Sw, Flg, CurDir);\r
2371                         if(*Sw == NO_ALL)\r
2372                                 break;\r
2373 \r
2374                         DelNotifyAndDo(Dt, Win, Sw, Flg, CurDir);\r
2375                         break;\r
2376                 }\r
2377                 Dt = Dt->Next;\r
2378         }\r
2379         return;\r
2380 }\r
2381 \r
2382 \r
2383 /*----- 削除するかどうかの確認と削除実行 --------------------------------------\r
2384 *\r
2385 *       Parameter\r
2386 *               FILELIST *Dt : 削除するファイルのリスト\r
2387 *               int Win : ウインドウ番号 (WIN_xxx)\r
2388 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2389 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2390 *               char *CurDir : カレントディレクトリ\r
2391 *\r
2392 *       Return Value\r
2393 *               なし\r
2394 *----------------------------------------------------------------------------*/\r
2395 \r
2396 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2397 {\r
2398         char Path[FMAX_PATH+1];\r
2399 \r
2400         if(Win == WIN_LOCAL)\r
2401         {\r
2402                 AskLocalCurDir(Path, FMAX_PATH);\r
2403                 SetYenTail(Path);\r
2404                 strcat(Path, Dt->File);\r
2405                 ReplaceAll(Path, '/', '\\');\r
2406         }\r
2407         else\r
2408         {\r
2409                 AskRemoteCurDir(Path, FMAX_PATH);\r
2410                 SetSlashTail(Path);\r
2411                 strcat(Path, Dt->File);\r
2412                 ReplaceAll(Path, '\\', '/');\r
2413         }\r
2414 \r
2415         if(*Sw != YES_ALL)\r
2416         {\r
2417                 sprintf(TmpString, "%s", Path);\r
2418 \r
2419                 // ローカルのファイルのパスの最後の'\\'が消えるバグ修正\r
2420 //              if(AskHostType() == HTYPE_VMS)\r
2421                 if(Win == WIN_REMOTE && AskHostType() == HTYPE_VMS)\r
2422                         ReformToVMSstylePathName(TmpString);\r
2423 \r
2424                 CurWin = Win;\r
2425                 *Sw = DialogBox(GetFtpInst(), MAKEINTRESOURCE(delete_dlg), GetMainHwnd(), DeleteDialogCallBack);\r
2426         }\r
2427 \r
2428         if((*Sw == YES) || (*Sw == YES_ALL))\r
2429         {\r
2430                 if(Win == WIN_LOCAL)\r
2431                 {\r
2432                         if(Dt->Node == NODE_FILE)\r
2433                                 DoLocalDELE(Path);\r
2434                         else\r
2435                                 DoLocalRMD(Path);\r
2436                         *Flg = YES;\r
2437                 }\r
2438                 else\r
2439                 {\r
2440                         /* フルパスを使わない時のための処理 */\r
2441                         // 同時接続対応\r
2442 //                      if(ProcForNonFullpath(Path, CurDir, GetMainHwnd(), 0) == FFFTP_FAIL)\r
2443                         if(ProcForNonFullpath(AskCmdCtrlSkt(), Path, CurDir, GetMainHwnd(), &CancelFlg) == FFFTP_FAIL)\r
2444                                 *Sw = NO_ALL;\r
2445 \r
2446                         if(*Sw != NO_ALL)\r
2447                         {\r
2448                                 if(Dt->Node == NODE_FILE)\r
2449                                         DoDELE(Path);\r
2450                                 else\r
2451                                         DoRMD(Path);\r
2452                                 *Flg = YES;\r
2453                         }\r
2454                 }\r
2455         }\r
2456         return;\r
2457 }\r
2458 \r
2459 \r
2460 /*----- ファイル削除ダイアログのコールバック ----------------------------------\r
2461 *\r
2462 *       Parameter\r
2463 *               HWND hDlg : ウインドウハンドル\r
2464 *               UINT message : メッセージ番号\r
2465 *               WPARAM wParam : メッセージの WPARAM 引数\r
2466 *               LPARAM lParam : メッセージの LPARAM 引数\r
2467 *\r
2468 *       Return Value\r
2469 *               BOOL TRUE/FALSE\r
2470 *----------------------------------------------------------------------------*/\r
2471 \r
2472 // 64ビット対応\r
2473 //static BOOL CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2474 static INT_PTR CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2475 {\r
2476         switch (iMessage)\r
2477         {\r
2478                 case WM_INITDIALOG :\r
2479                         if(CurWin == WIN_LOCAL)\r
2480                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN066);\r
2481                         else\r
2482                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN067);\r
2483                         SendDlgItemMessage(hDlg, DELETE_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2484                         return(TRUE);\r
2485 \r
2486                 case WM_COMMAND :\r
2487                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2488                         {\r
2489                                 case IDOK :\r
2490                                         EndDialog(hDlg, YES);\r
2491                                         break;\r
2492 \r
2493                                 case DELETE_NO :\r
2494                                         EndDialog(hDlg, NO);\r
2495                                         break;\r
2496 \r
2497                                 case DELETE_ALL :\r
2498                                         EndDialog(hDlg, YES_ALL);\r
2499                                         break;\r
2500 \r
2501                                 case IDCANCEL :\r
2502                                         EndDialog(hDlg, NO_ALL);\r
2503                                         break;\r
2504                         }\r
2505             return(TRUE);\r
2506         }\r
2507         return(FALSE);\r
2508 }\r
2509 \r
2510 \r
2511 /*----- ファイル一覧で指定されたファイルの名前を変更する ----------------------\r
2512 *\r
2513 *       Parameter\r
2514 *               なし\r
2515 *\r
2516 *       Return Value\r
2517 *               なし\r
2518 *----------------------------------------------------------------------------*/\r
2519 \r
2520 void RenameProc(void)\r
2521 {\r
2522         int Win;\r
2523         FILELIST *FileListBase;\r
2524         FILELIST *Pos;\r
2525         char New[FMAX_PATH+1];\r
2526         int RenFlg;\r
2527         int Sts;\r
2528 \r
2529         // 同時接続対応\r
2530         CancelFlg = NO;\r
2531 \r
2532         Sts = FFFTP_SUCCESS;\r
2533         if(GetFocus() == GetLocalHwnd())\r
2534                 Win = WIN_LOCAL;\r
2535         else\r
2536         {\r
2537                 Win = WIN_REMOTE;\r
2538                 Sts = CheckClosedAndReconnect();\r
2539         }\r
2540 \r
2541         if(Sts == FFFTP_SUCCESS)\r
2542         {\r
2543                 DisableUserOpe();\r
2544 \r
2545                 FileListBase = NULL;\r
2546                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2547 \r
2548                 RenFlg = NO;\r
2549                 Sts = NO;\r
2550                 Pos = FileListBase;\r
2551                 while(Pos != NULL)\r
2552                 {\r
2553                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2554                         {\r
2555                                 strcpy(TmpString, Pos->File);\r
2556                                 CurWin = Win;\r
2557                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2558 \r
2559                                 if(Sts == NO_ALL)\r
2560                                         break;\r
2561 \r
2562                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2563                                 {\r
2564                                         strcpy(New, TmpString);\r
2565                                         if(Win == WIN_LOCAL)\r
2566                                                 DoLocalRENAME(Pos->File, New);\r
2567                                         else\r
2568                                                 DoRENAME(Pos->File, New);\r
2569                                         RenFlg = YES;\r
2570                                 }\r
2571                         }\r
2572                         Pos = Pos->Next;\r
2573                 }\r
2574                 DeleteFileList(&FileListBase);\r
2575 \r
2576                 if(RenFlg == YES)\r
2577                 {\r
2578                         if(Win == WIN_LOCAL)\r
2579                                 GetLocalDirForWnd();\r
2580                         else\r
2581                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2582                 }\r
2583 \r
2584                 EnableUserOpe();\r
2585         }\r
2586         return;\r
2587 }\r
2588 \r
2589 \r
2590 //\r
2591 // リモート側でのファイルの移動(リネーム)を行う\r
2592 //  \r
2593 // RenameProc()をベースに改造。(2007.9.5 yutaka)\r
2594 //\r
2595 void MoveRemoteFileProc(int drop_index)\r
2596 {\r
2597         int Win;\r
2598         FILELIST *FileListBase;\r
2599         FILELIST *Pos;\r
2600         FILELIST Pkt;\r
2601         char New[FMAX_PATH+1];\r
2602         char Old[FMAX_PATH+1];\r
2603         char HostDir[FMAX_PATH+1];\r
2604         int RenFlg;\r
2605         int Sts;\r
2606 \r
2607         // 同時接続対応\r
2608         CancelFlg = NO;\r
2609 \r
2610         if(MoveMode == MOVE_DISABLE)\r
2611         {\r
2612                 return;\r
2613         }\r
2614 \r
2615         AskRemoteCurDir(HostDir, FMAX_PATH);\r
2616 \r
2617         // ドロップ先のフォルダ名を得る\r
2618         GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH);\r
2619 \r
2620         if(MoveMode == MOVE_DLG)\r
2621         {\r
2622                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(move_notify_dlg), GetRemoteHwnd(), ExeEscTextDialogProc, (LPARAM)Pkt.File) == NO)\r
2623                 {\r
2624                         return;\r
2625                 }\r
2626         }\r
2627 \r
2628         Sts = FFFTP_SUCCESS;\r
2629 #if 0\r
2630         if(GetFocus() == GetLocalHwnd())\r
2631                 Win = WIN_LOCAL;\r
2632         else\r
2633         {\r
2634                 Win = WIN_REMOTE;\r
2635                 Sts = CheckClosedAndReconnect();\r
2636         }\r
2637 #else\r
2638                 Win = WIN_REMOTE;\r
2639                 Sts = CheckClosedAndReconnect();\r
2640 #endif\r
2641 \r
2642         if(Sts == FFFTP_SUCCESS)\r
2643         {\r
2644                 DisableUserOpe();\r
2645 \r
2646                 FileListBase = NULL;\r
2647                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2648 \r
2649                 RenFlg = NO;\r
2650                 Sts = NO;\r
2651                 Pos = FileListBase;\r
2652                 while(Pos != NULL)\r
2653                 {\r
2654                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2655                         {\r
2656                                 strcpy(TmpString, Pos->File);\r
2657                                 CurWin = Win;\r
2658 #if 0\r
2659                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2660 \r
2661                                 if(Sts == NO_ALL)\r
2662                                         break;\r
2663 #else\r
2664                                 Sts = YES;\r
2665 #endif\r
2666 \r
2667                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2668                                 {\r
2669                                         // パスの設定(local)\r
2670                                         strncpy_s(Old, sizeof(Old), HostDir, _TRUNCATE);\r
2671                                         strncat_s(Old, sizeof(Old), "/", _TRUNCATE);\r
2672                                         strncat_s(Old, sizeof(Old), Pos->File, _TRUNCATE);\r
2673 \r
2674                                         // パスの設定(remote)\r
2675                                         strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2676                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2677                                         strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2678                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2679                                         strncat_s(New, sizeof(New), Pos->File, _TRUNCATE);\r
2680 \r
2681                                         if(Win == WIN_LOCAL)\r
2682                                                 DoLocalRENAME(Old, New);\r
2683                                         else\r
2684                                                 DoRENAME(Old, New);\r
2685                                         RenFlg = YES;\r
2686                                 }\r
2687                         }\r
2688                         Pos = Pos->Next;\r
2689                 }\r
2690                 DeleteFileList(&FileListBase);\r
2691 \r
2692                 if(RenFlg == YES)\r
2693                 {\r
2694                         if(Win == WIN_LOCAL) {\r
2695                                 GetLocalDirForWnd();\r
2696                         } else {\r
2697                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2698 \r
2699                                 strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2700                                 strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2701                                 strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2702                                 DoCWD(New, YES, YES, YES);\r
2703                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2704                         }\r
2705                 }\r
2706 \r
2707                 EnableUserOpe();\r
2708         }\r
2709         return;\r
2710 }\r
2711 \r
2712 \r
2713 \r
2714 /*----- 新ファイル名入力ダイアログのコールバック ------------------------------\r
2715 *\r
2716 *       Parameter\r
2717 *               HWND hDlg : ウインドウハンドル\r
2718 *               UINT message : メッセージ番号\r
2719 *               WPARAM wParam : メッセージの WPARAM 引数\r
2720 *               LPARAM lParam : メッセージの LPARAM 引数\r
2721 *\r
2722 *       Return Value\r
2723 *               BOOL TRUE/FALSE\r
2724 *----------------------------------------------------------------------------*/\r
2725 \r
2726 // 64ビット対応\r
2727 //static BOOL CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2728 static INT_PTR CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2729 {\r
2730         switch (iMessage)\r
2731         {\r
2732                 case WM_INITDIALOG :\r
2733                         if(CurWin == WIN_LOCAL)\r
2734                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN068);\r
2735                         else\r
2736                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN069);\r
2737                         SendDlgItemMessage(hDlg, RENAME_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2738                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2739                         SendDlgItemMessage(hDlg, RENAME_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2740                         return(TRUE);\r
2741 \r
2742                 case WM_COMMAND :\r
2743                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2744                         {\r
2745                                 case IDOK :\r
2746                                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2747                                         EndDialog(hDlg, YES);\r
2748                                         break;\r
2749 \r
2750                                 case IDCANCEL :\r
2751                                         EndDialog(hDlg, NO);\r
2752                                         break;\r
2753 \r
2754                                 case RENAME_STOP :\r
2755                                         EndDialog(hDlg, NO_ALL);\r
2756                                         break;\r
2757                         }\r
2758             return(TRUE);\r
2759         }\r
2760         return(FALSE);\r