OSDN Git Service

Update to 66d24c0aad0c81cae0fb0630e91257f7acd819e2 (1.98e).
[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                 GoForwardTransWindow();\r
318 //              KeepTransferDialog(NO);\r
319 \r
320                 EnableUserOpe();\r
321         }\r
322         return;\r
323 }\r
324 \r
325 \r
326 /*----- 指定されたファイルを一つダウンロードする ------------------------------\r
327 *\r
328 *       Parameter\r
329 *               char *Fname : ファイル名\r
330 *\r
331 *       Return Value\r
332 *               なし\r
333 *----------------------------------------------------------------------------*/\r
334 \r
335 void DirectDownloadProc(char *Fname)\r
336 {\r
337         TRANSPACKET Pkt;\r
338         // ディレクトリ自動作成\r
339         char Tmp[FMAX_PATH+1];\r
340 \r
341         // 同時接続対応\r
342         CancelFlg = NO;\r
343 \r
344         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
345         {\r
346                 DisableUserOpe();\r
347 \r
348                 ExistNotify = YES;\r
349 //              KeepTransferDialog(YES);\r
350 \r
351                 if(AskNoFullPathMode() == YES)\r
352                 {\r
353                         strcpy(Pkt.Cmd, "SETCUR");\r
354                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
355                         AddTransFileList(&Pkt);\r
356                 }\r
357 \r
358                 if(strlen(Fname) > 0)\r
359                 {\r
360                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
361                         SetYenTail(Pkt.LocalFile);\r
362                         strcpy(TmpString, Fname);\r
363                         if(FnameCnv == FNAME_LOWER)\r
364                                 _mbslwr(TmpString);\r
365                         else if(FnameCnv == FNAME_UPPER)\r
366                                 _mbsupr(TmpString);\r
367                         RemoveAfterSemicolon(TmpString);\r
368 \r
369                         if(RenameUnuseableName(TmpString) == FFFTP_SUCCESS)\r
370                         {\r
371                                 strcat(Pkt.LocalFile, TmpString);\r
372                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
373 \r
374                                 if(AskHostType() == HTYPE_ACOS)\r
375                                 {\r
376                                         strcpy(Pkt.RemoteFile, "'");\r
377                                         strcat(Pkt.RemoteFile, AskHostLsName());\r
378                                         strcat(Pkt.RemoteFile, "(");\r
379                                         strcat(Pkt.RemoteFile, Fname);\r
380                                         strcat(Pkt.RemoteFile, ")");\r
381                                         strcat(Pkt.RemoteFile, "'");\r
382                                 }\r
383                                 else if(AskHostType() == HTYPE_ACOS_4)\r
384                                 {\r
385                                         strcpy(Pkt.RemoteFile, Fname);\r
386                                 }\r
387                                 else\r
388                                 {\r
389                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
390                                         SetSlashTail(Pkt.RemoteFile);\r
391                                         strcat(Pkt.RemoteFile, Fname);\r
392                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
393                                 }\r
394 \r
395                                 strcpy(Pkt.Cmd, "RETR-S ");\r
396                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
397 \r
398                                 /* サイズと日付は転送側スレッドで取得し、セットする */\r
399 \r
400                                 Pkt.KanjiCode = AskHostKanjiCode();\r
401                                 // UTF-8対応\r
402                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
403                                 Pkt.KanaCnv = AskHostKanaCnv();\r
404 \r
405                                 // ディレクトリ自動作成\r
406                                 strcpy(Tmp, Pkt.LocalFile);\r
407                                 Pkt.Mode = CheckLocalFile(&Pkt);        /* Pkt.ExistSize がセットされる */\r
408                                 if((Pkt.Mode != EXIST_ABORT) && (Pkt.Mode != EXIST_IGNORE))\r
409                                 // ディレクトリ自動作成\r
410 //                                      AddTransFileList(&Pkt);\r
411                                 {\r
412                                         if(MakeAllDir == YES)\r
413                                                 MakeDirFromLocalPath(Pkt.LocalFile, Tmp);\r
414                                         AddTransFileList(&Pkt);\r
415                                 }\r
416                         }\r
417                 }\r
418 \r
419                 if(AskNoFullPathMode() == YES)\r
420                 {\r
421                         strcpy(Pkt.Cmd, "BACKCUR");\r
422                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
423                         AddTransFileList(&Pkt);\r
424                 }\r
425 \r
426                 // 同時接続対応\r
427 //              strcpy(Pkt.Cmd, "GOQUIT");\r
428 //              AddTransFileList(&Pkt);\r
429 \r
430                 GoForwardTransWindow();\r
431 //              KeepTransferDialog(NO);\r
432 \r
433                 EnableUserOpe();\r
434         }\r
435         return;\r
436 }\r
437 \r
438 \r
439 /*----- 入力されたファイル名のファイルを一つダウンロードする ------------------\r
440 *\r
441 *       Parameter\r
442 *               なし\r
443 *\r
444 *       Return Value\r
445 *               なし\r
446 *----------------------------------------------------------------------------*/\r
447 \r
448 void InputDownloadProc(void)\r
449 {\r
450         char Path[FMAX_PATH+1];\r
451         int Tmp;\r
452 \r
453 //      DisableUserOpe();\r
454 \r
455         strcpy(Path, "");\r
456         if(InputDialogBox(downname_dlg, GetMainHwnd(), NULL, Path, FMAX_PATH, &Tmp, IDH_HELP_TOPIC_0000001) == YES)\r
457         {\r
458                 DirectDownloadProc(Path);\r
459         }\r
460 \r
461 //      EnableUserOpe();\r
462 \r
463         return;\r
464 }\r
465 \r
466 \r
467 /*----- ミラーリングダウンロードを行う ----------------------------------------\r
468 *\r
469 *       Parameter\r
470 *               int Notify : 確認を行うかどうか (YES/NO)\r
471 *\r
472 *       Return Value\r
473 *               なし\r
474 *----------------------------------------------------------------------------*/\r
475 \r
476 void MirrorDownloadProc(int Notify)\r
477 {\r
478         FILELIST *LocalListBase;\r
479         FILELIST *RemoteListBase;\r
480         FILELIST *LocalPos;\r
481         FILELIST *RemotePos;\r
482         TRANSPACKET Pkt;\r
483         TRANSPACKET *Base;\r
484         char Name[FMAX_PATH+1];\r
485         char *Cat;\r
486         int Level;\r
487         int Mode;\r
488 \r
489         // 同時接続対応\r
490         CancelFlg = NO;\r
491 \r
492         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
493         {\r
494                 DisableUserOpe();\r
495 \r
496                 Base = NULL;\r
497 \r
498                 if(Notify == YES)\r
499                         Notify = DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_down_dlg), GetMainHwnd(), MirrorNotifyCallBack, 0);\r
500                 else\r
501                         Notify = YES;\r
502 \r
503                 if((Notify == YES) || (Notify == YES_LIST))\r
504                 {\r
505                         /*===== ファイルリスト取得 =====*/\r
506 \r
507                         LocalListBase = NULL;\r
508                         MakeSelectedFileList(WIN_LOCAL, YES, YES, &LocalListBase, &CancelFlg);\r
509                         RemoteListBase = NULL;\r
510                         MakeSelectedFileList(WIN_REMOTE, YES, YES, &RemoteListBase, &CancelFlg);\r
511 \r
512                         RemotePos = RemoteListBase;\r
513                         while(RemotePos != NULL)\r
514                         {\r
515                                 RemotePos->Attr = YES;          /* RemotePos->Attrは転送するかどうかのフラグに使用 (YES/NO) */\r
516                                 RemotePos = RemotePos->Next;\r
517                         }\r
518 \r
519                         LocalPos = LocalListBase;\r
520                         while(LocalPos != NULL)\r
521                         {\r
522                                 if(AskMirrorNoTrn(LocalPos->File, 1) == NO)\r
523                                 {\r
524                                         LocalPos->Attr = YES;\r
525                                         LocalPos = LocalPos->Next;\r
526                                 }\r
527                                 else\r
528                                 {\r
529                                         LocalPos->Attr = NO;    /* LocalPos->Attrは削除するかどうかのフラグに使用 (YES/NO) */\r
530 \r
531                                         if(LocalPos->Node == NODE_DIR)\r
532                                         {\r
533                                                 Level = AskDirLevel(LocalPos->File);\r
534                                                 LocalPos = LocalPos->Next;\r
535                                                 while(LocalPos != NULL)\r
536                                                 {\r
537                                                         if((LocalPos->Node == NODE_DIR) &&\r
538                                                            (AskDirLevel(LocalPos->File) <= Level))\r
539                                                         {\r
540                                                                 break;\r
541                                                         }\r
542                                                         LocalPos->Attr = NO;\r
543                                                         LocalPos = LocalPos->Next;\r
544                                                 }\r
545                                         }\r
546                                         else\r
547                                                 LocalPos = LocalPos->Next;\r
548                                 }\r
549                         }\r
550 \r
551                         /*===== ファイルリスト比較 =====*/\r
552 \r
553                         RemotePos = RemoteListBase;\r
554                         while(RemotePos != NULL)\r
555                         {\r
556                                 if(AskMirrorNoTrn(RemotePos->File, 0) == NO)\r
557                                 {\r
558                                         strcpy(Name, RemotePos->File);\r
559 //                                      ReplaceAll(Name, '/', '\\');\r
560 \r
561                                         if(MirrorFnameCnv == YES)\r
562                                                 Mode = COMP_LOWERMATCH;\r
563                                         else\r
564                                                 Mode = COMP_STRICT;\r
565 \r
566                                         if((LocalPos = SearchFileList(Name, LocalListBase, Mode)) != NULL)\r
567                                         {\r
568                                                 if((RemotePos->Node == NODE_DIR) && (LocalPos->Node == NODE_DIR))\r
569                                                 {\r
570                                                         LocalPos->Attr = NO;\r
571                                                         RemotePos->Attr = NO;\r
572                                                 }\r
573                                                 else if((RemotePos->Node == NODE_FILE) && (LocalPos->Node == NODE_FILE))\r
574                                                 {\r
575                                                         LocalPos->Attr = NO;\r
576                                                         if(CompareFileTime(&RemotePos->Time, &LocalPos->Time) <= 0)\r
577                                                                 RemotePos->Attr = NO;\r
578                                                 }\r
579                                         }\r
580                                         RemotePos = RemotePos->Next;\r
581                                 }\r
582                                 else\r
583                                 {\r
584                                         if(RemotePos->Node == NODE_FILE)\r
585                                         {\r
586                                                 RemotePos->Attr = NO;\r
587                                                 RemotePos = RemotePos->Next;\r
588                                         }\r
589                                         else\r
590                                         {\r
591                                                 RemotePos->Attr = NO;\r
592                                                 Level = AskDirLevel(RemotePos->File);\r
593                                                 RemotePos = RemotePos->Next;\r
594                                                 while(RemotePos != NULL)\r
595                                                 {\r
596                                                         if((RemotePos->Node == NODE_DIR) &&\r
597                                                            (AskDirLevel(RemotePos->File) <= Level))\r
598                                                         {\r
599                                                                 break;\r
600                                                         }\r
601                                                         RemotePos->Attr = NO;\r
602                                                         RemotePos = RemotePos->Next;\r
603                                                 }\r
604                                         }\r
605                                 }\r
606                         }\r
607 \r
608                         DispMirrorFiles(LocalListBase, RemoteListBase);\r
609 \r
610                         /*===== 削除/アップロード =====*/\r
611 \r
612                         LocalPos = LocalListBase;\r
613                         while(LocalPos != NULL)\r
614                         {\r
615                                 if((LocalPos->Attr == YES) && (LocalPos->Node == NODE_FILE))\r
616                                 {\r
617                                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
618                                         SetYenTail(Pkt.LocalFile);\r
619                                         strcat(Pkt.LocalFile, LocalPos->File);\r
620                                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
621                                         strcpy(Pkt.RemoteFile, "");\r
622                                         strcpy(Pkt.Cmd, "L-DELE ");\r
623                                         AddTmpTransFileList(&Pkt, &Base);\r
624                                 }\r
625                                 LocalPos = LocalPos->Next;\r
626                         }\r
627                         MirrorDeleteAllLocalDir(LocalListBase, &Pkt, &Base);\r
628 \r
629 \r
630                         RemotePos = RemoteListBase;\r
631                         while(RemotePos != NULL)\r
632                         {\r
633                                 if(RemotePos->Attr == YES)\r
634                                 {\r
635                                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
636                                         SetYenTail(Pkt.LocalFile);\r
637                                         Cat = strchr(Pkt.LocalFile, NUL);\r
638                                         strcat(Pkt.LocalFile, RemotePos->File);\r
639 \r
640                                         if(MirrorFnameCnv == YES)\r
641                                                 _mbslwr(Cat);\r
642 \r
643                                         RemoveAfterSemicolon(Cat);\r
644                                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
645 \r
646                                         if(RemotePos->Node == NODE_DIR)\r
647                                         {\r
648                                                 strcpy(Pkt.RemoteFile, "");\r
649                                                 strcpy(Pkt.Cmd, "L-MKD ");\r
650                                                 AddTmpTransFileList(&Pkt, &Base);\r
651                                         }\r
652                                         else if(RemotePos->Node == NODE_FILE)\r
653                                         {\r
654                                                 AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
655                                                 SetSlashTail(Pkt.RemoteFile);\r
656                                                 strcat(Pkt.RemoteFile, RemotePos->File);\r
657                                                 ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
658 \r
659                                                 strcpy(Pkt.Cmd, "RETR ");\r
660                                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
661                                                 Pkt.Size = RemotePos->Size;\r
662                                                 Pkt.Time = RemotePos->Time;\r
663 //                                              Pkt.Attr = 0;\r
664                                                 Pkt.KanjiCode = AskHostKanjiCode();\r
665                                                 // UTF-8対応\r
666                                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
667                                                 Pkt.KanaCnv = AskHostKanaCnv();\r
668                                                 Pkt.Mode = EXIST_OVW;\r
669                                                 AddTmpTransFileList(&Pkt, &Base);\r
670                                         }\r
671                                 }\r
672                                 RemotePos = RemotePos->Next;\r
673                         }\r
674 \r
675                         if((Notify == YES) ||\r
676                            (DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirrordown_notify_dlg), GetMainHwnd(), MirrorDispListCallBack, (LPARAM)&Base) == YES))\r
677                         {\r
678                                 if(AskNoFullPathMode() == YES)\r
679                                 {\r
680                                         strcpy(Pkt.Cmd, "SETCUR");\r
681                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
682                                         AddTransFileList(&Pkt);\r
683                                 }\r
684                                 AppendTransFileList(Base);\r
685 \r
686                                 if(AskNoFullPathMode() == YES)\r
687                                 {\r
688                                         strcpy(Pkt.Cmd, "BACKCUR");\r
689                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
690                                         AddTransFileList(&Pkt);\r
691                                 }\r
692 \r
693                                 // 同時接続対応\r
694 //                              strcpy(Pkt.Cmd, "GOQUIT");\r
695 //                              AddTransFileList(&Pkt);\r
696                         }\r
697                         else\r
698                                 EraseTmpTransFileList(&Base);\r
699 \r
700                         DeleteFileList(&LocalListBase);\r
701                         DeleteFileList(&RemoteListBase);\r
702 \r
703                         GoForwardTransWindow();\r
704                 }\r
705 \r
706                 EnableUserOpe();\r
707         }\r
708         return;\r
709 }\r
710 \r
711 \r
712 /*----- ミラーリングのファイル一覧を表示 --------------------------------------\r
713 *\r
714 *       Parameter\r
715 *               FILELIST *Local : ローカル側\r
716 *               FILELIST *Remote : リモート側\r
717 *\r
718 *       Return Value\r
719 *               なし\r
720 *----------------------------------------------------------------------------*/\r
721 \r
722 static void DispMirrorFiles(FILELIST *Local, FILELIST *Remote)\r
723 {\r
724         char Date[80];\r
725         SYSTEMTIME sTime;\r
726         FILETIME fTime;\r
727 \r
728         if(DebugConsole == YES)\r
729         {\r
730                 DoPrintf("---- MIRROR FILE LIST ----");\r
731                 while(Local != NULL)\r
732                 {\r
733                         FileTimeToLocalFileTime(&Local->Time, &fTime);\r
734                         FileTimeToSystemTime(&fTime, &sTime);\r
735                         sprintf(Date, "%04d/%02d/%02d %02d:%02d:%02d.%04d", \r
736                                 sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond, sTime.wMilliseconds);\r
737                         DoPrintf("LOCAL  : %s %s [%s] %s", Local->Attr==1?"YES":"NO ", Local->Node==NODE_DIR?"DIR ":"FILE", Date, Local->File);\r
738                         Local = Local->Next;\r
739                 }\r
740                 while(Remote != NULL)\r
741                 {\r
742                         FileTimeToLocalFileTime(&Remote->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("REMOTE : %s %s [%s] %s", Remote->Attr==1?"YES":"NO ", Remote->Node==NODE_DIR?"DIR ":"FILE", Date, Remote->File);\r
747                         Remote = Remote->Next;\r
748                 }\r
749                 DoPrintf("---- END ----");\r
750         }\r
751         return;\r
752 }\r
753 \r
754 \r
755 /*----- ミラーリング時のローカル側のフォルダ削除 ------------------------------\r
756 *\r
757 *       Parameter\r
758 *               FILELIST *Local : ファイルリスト\r
759 *               TRANSPACKET *Pkt : \r
760 *               TRANSPACKET **Base : \r
761 *\r
762 *       Return Value\r
763 *               なし\r
764 *----------------------------------------------------------------------------*/\r
765 \r
766 static void MirrorDeleteAllLocalDir(FILELIST *Local, TRANSPACKET *Pkt, TRANSPACKET **Base)\r
767 {\r
768         while(Local != NULL)\r
769         {\r
770                 if(Local->Node == NODE_DIR)\r
771                 {\r
772                         MirrorDeleteAllLocalDir(Local->Next, Pkt, Base);\r
773 \r
774                         if(Local->Attr == YES)\r
775                         {\r
776                                 AskLocalCurDir(Pkt->LocalFile, FMAX_PATH);\r
777                                 SetYenTail(Pkt->LocalFile);\r
778                                 strcat(Pkt->LocalFile, Local->File);\r
779                                 ReplaceAll(Pkt->LocalFile, '/', '\\');\r
780                                 strcpy(Pkt->RemoteFile, "");\r
781                                 strcpy(Pkt->Cmd, "L-RMD ");\r
782                                 AddTmpTransFileList(Pkt, Base);\r
783                         }\r
784                         break;\r
785                 }\r
786                 Local = Local->Next;\r
787         }\r
788         return;\r
789 }\r
790 \r
791 \r
792 /*----- ファイル名のセミコロン以降を取り除く ----------------------------------\r
793 *\r
794 *       Parameter\r
795 *               char *Path : ファイル名\r
796 *\r
797 *       Return Value\r
798 *               なし\r
799 *\r
800 *       Note\r
801 *               Pathの内容が書き換えられる\r
802 *               オプション設定によって処理を切替える\r
803 *----------------------------------------------------------------------------*/\r
804 \r
805 static void RemoveAfterSemicolon(char *Path)\r
806 {\r
807         char *Pos;\r
808 \r
809         if(VaxSemicolon == YES)\r
810         {\r
811                 if((Pos = strchr(Path, ';')) != NULL)\r
812                         *Pos = NUL;\r
813         }\r
814         return;\r
815 }\r
816 \r
817 \r
818 /*----- ローカルに同じ名前のファイルがないかチェック --------------------------\r
819 *\r
820 *       Parameter\r
821 *               TRANSPACKET *Pkt : 転送ファイル情報\r
822 *\r
823 *       Return Value\r
824 *               int 処理方法\r
825 *                       EXIST_OVW/EXIST_RESUME/EXIST_IGNORE\r
826 *\r
827 *       Note\r
828 *               Pkt.ExistSize, ExistMode、ExistNotify が変更される\r
829 *----------------------------------------------------------------------------*/\r
830 \r
831 static int CheckLocalFile(TRANSPACKET *Pkt)\r
832 {\r
833         HANDLE fHnd;\r
834         WIN32_FIND_DATA Find;\r
835         int Ret;\r
836 \r
837         Ret = EXIST_OVW;\r
838         Pkt->ExistSize = 0;\r
839         if(RecvMode != TRANS_OVW)\r
840         {\r
841                 if((fHnd = FindFirstFile(Pkt->LocalFile, &Find)) != INVALID_HANDLE_VALUE)\r
842                 {\r
843                         FindClose(fHnd);\r
844 \r
845                         Pkt->ExistSize = MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow);\r
846 \r
847                         if(ExistNotify == YES)\r
848                         {\r
849                                 SoundPlay(SND_ERROR);\r
850                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(down_exist_dlg), GetMainHwnd(), DownExistDialogCallBack, (LPARAM)Pkt) == NO)\r
851                                         Ret = EXIST_ABORT;\r
852                                 else\r
853                                         Ret = ExistMode;\r
854                         }\r
855                         else\r
856                                 Ret = ExistMode;\r
857 \r
858                         if(Ret == EXIST_NEW)\r
859                         {\r
860                                 /*ファイル日付チェック */\r
861                                 if(CompareFileTime(&Find.ftLastWriteTime, &Pkt->Time) < 0)\r
862                                         Ret = EXIST_OVW;\r
863                                 else\r
864                                         Ret = EXIST_IGNORE;\r
865                         }\r
866                 }\r
867         }\r
868         return(Ret);\r
869 }\r
870 \r
871 \r
872 /*----- ローカルに同じ名前のファイルがある時の確認ダイアログのコールバック ----\r
873 *\r
874 *       Parameter\r
875 *               HWND hDlg : ウインドウハンドル\r
876 *               UINT message : メッセージ番号\r
877 *               WPARAM wParam : メッセージの WPARAM 引数\r
878 *               LPARAM lParam : メッセージの LPARAM 引数\r
879 *\r
880 *       Return Value\r
881 *               BOOL TRUE/FALSE\r
882 *----------------------------------------------------------------------------*/\r
883 \r
884 // 64ビット対応\r
885 //static BOOL CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
886 static INT_PTR CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
887 {\r
888         static TRANSPACKET *Pkt;\r
889         static const RADIOBUTTON DownExistButton[] = {\r
890                 { DOWN_EXIST_OVW, EXIST_OVW },\r
891                 { DOWN_EXIST_NEW, EXIST_NEW },\r
892                 { DOWN_EXIST_RESUME, EXIST_RESUME },\r
893                 { DOWN_EXIST_IGNORE, EXIST_IGNORE }\r
894         };\r
895         #define DOWNEXISTBUTTONS        (sizeof(DownExistButton)/sizeof(RADIOBUTTON))\r
896 \r
897         switch (iMessage)\r
898         {\r
899                 case WM_INITDIALOG :\r
900                         Pkt = (TRANSPACKET *)lParam;\r
901                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, EM_LIMITTEXT, FMAX_PATH, 0);\r
902                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, WM_SETTEXT, 0, (LPARAM)Pkt->LocalFile);\r
903 \r
904                         if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
905                                 EnableWindow(GetDlgItem(hDlg, DOWN_EXIST_RESUME), FALSE);\r
906 \r
907                         SetRadioButtonByValue(hDlg, ExistMode, DownExistButton, DOWNEXISTBUTTONS);\r
908                         return(TRUE);\r
909 \r
910                 case WM_COMMAND :\r
911                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
912                         {\r
913                                 case IDOK_ALL :\r
914                                         ExistNotify = NO;\r
915                                         /* ここに break はない */\r
916 \r
917                                 case IDOK :\r
918                                         ExistMode = AskRadioButtonValue(hDlg, DownExistButton, DOWNEXISTBUTTONS);\r
919                                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, WM_GETTEXT, FMAX_PATH, (LPARAM)Pkt->LocalFile);\r
920                                         EndDialog(hDlg, YES);\r
921                                         break;\r
922 \r
923                                 case IDCANCEL :\r
924 //                                      ExistMode = EXIST_ABORT;\r
925                                         EndDialog(hDlg, NO);\r
926                                         break;\r
927 \r
928                                 case IDHELP :\r
929                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000009);\r
930                                         break;\r
931                         }\r
932             return(TRUE);\r
933         }\r
934         return(FALSE);\r
935 }\r
936 \r
937 \r
938 \r
939 \r
940 \r
941 \r
942 /*----- ファイル一覧で指定されたファイルをアップロードする --------------------\r
943 *\r
944 *       Parameter\r
945 *               int ChName : 名前を変えるかどうか (YES/NO)\r
946 *               int All : 全てが選ばれている物として扱うかどうか (YES/NO)\r
947 *\r
948 *       Return Value\r
949 *               なし\r
950 *----------------------------------------------------------------------------*/\r
951 \r
952 // ディレクトリ自動作成\r
953 // リモート側のパスから必要なディレクトリを作成\r
954 int MakeDirFromRemotePath(char* RemoteFile, char* Old, int FirstAdd)\r
955 {\r
956         TRANSPACKET Pkt;\r
957         TRANSPACKET Pkt1;\r
958         char* pDelimiter;\r
959         char* pNext;\r
960         char* Cat;\r
961         int Len;\r
962         int Make;\r
963         pDelimiter = RemoteFile;\r
964         Make = NO;\r
965         while(pNext = strchr(pDelimiter, '/'))\r
966         {\r
967                 Len = pNext - RemoteFile;\r
968                 strncpy(Pkt.RemoteFile, RemoteFile, Len);\r
969                 Pkt.RemoteFile[Len] = '\0';\r
970                 if(strncmp(RemoteFile, Old, Len + 1) != 0)\r
971                 {\r
972                         Cat = Pkt.RemoteFile + (pDelimiter - RemoteFile);\r
973                         if(FnameCnv == FNAME_LOWER)\r
974                                 _mbslwr(Cat);\r
975                         else if(FnameCnv == FNAME_UPPER)\r
976                                 _mbsupr(Cat);\r
977 #if defined(HAVE_TANDEM)\r
978                         Pkt.FileCode = 0;\r
979                         Pkt.PriExt = DEF_PRIEXT;\r
980                         Pkt.SecExt = DEF_SECEXT;\r
981                         Pkt.MaxExt = DEF_MAXEXT;\r
982 #endif\r
983                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
984 \r
985                         if(AskHostType() == HTYPE_ACOS)\r
986                         {\r
987                                 strcpy(Pkt.RemoteFile, "'");\r
988                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
989                                 strcat(Pkt.RemoteFile, "(");\r
990                                 strcat(Pkt.RemoteFile, Cat);\r
991                                 strcat(Pkt.RemoteFile, ")");\r
992                                 strcat(Pkt.RemoteFile, "'");\r
993                         }\r
994                         else if(AskHostType() == HTYPE_ACOS_4)\r
995                                 strcpy(Pkt.RemoteFile, Cat);\r
996 \r
997                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
998                         {\r
999                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1000                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1001                                 AddTransFileList(&Pkt1);\r
1002                         }\r
1003                         FirstAdd = NO;\r
1004                         strcpy(Pkt.Cmd, "MKD ");\r
1005                         strcpy(Pkt.LocalFile, "");\r
1006                         AddTransFileList(&Pkt);\r
1007 \r
1008                         Make = YES;\r
1009                 }\r
1010                 pDelimiter = pNext + 1;\r
1011         }\r
1012         return Make;\r
1013 }\r
1014 \r
1015 void UploadListProc(int ChName, int All)\r
1016 {\r
1017         FILELIST *FileListBase;\r
1018         FILELIST *Pos;\r
1019         TRANSPACKET Pkt;\r
1020         TRANSPACKET Pkt1;\r
1021         char *Cat;\r
1022         FILELIST *RemoteList;\r
1023         char Tmp[FMAX_PATH+1];\r
1024         int FirstAdd;\r
1025 \r
1026         // 同時接続対応\r
1027         CancelFlg = NO;\r
1028 \r
1029         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1030         {\r
1031                 DisableUserOpe();\r
1032 \r
1033                 // ローカル側で選ばれているファイルをFileListBaseに登録\r
1034                 FileListBase = NULL;\r
1035                 MakeSelectedFileList(WIN_LOCAL, YES, All, &FileListBase, &CancelFlg);\r
1036 \r
1037                 // 現在ホスト側のファイル一覧に表示されているものをRemoteListに登録\r
1038                 // 同名ファイルチェック用\r
1039                 RemoteList = NULL;\r
1040                 AddRemoteTreeToFileList(AskCurrentFileListNum(), "", RDIR_NONE, &RemoteList);\r
1041 \r
1042                 FirstAdd = YES;\r
1043                 ExistNotify = YES;\r
1044 \r
1045                 Pos = FileListBase;\r
1046                 while(Pos != NULL)\r
1047                 {\r
1048                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1049                         SetSlashTail(Pkt.RemoteFile);\r
1050                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1051                         if((ChName == NO) || (Pos->Node == NODE_DIR))\r
1052                         {\r
1053                                 strcat(Pkt.RemoteFile, Pos->File);\r
1054                                 if(FnameCnv == FNAME_LOWER)\r
1055                                         _mbslwr(Cat);\r
1056                                 else if(FnameCnv == FNAME_UPPER)\r
1057                                         _mbsupr(Cat);\r
1058 #if defined(HAVE_TANDEM)\r
1059                                 Pkt.FileCode = 0;\r
1060                                 Pkt.PriExt = DEF_PRIEXT;\r
1061                                 Pkt.SecExt = DEF_SECEXT;\r
1062                                 Pkt.MaxExt = DEF_MAXEXT;\r
1063 #endif\r
1064                         }\r
1065                         else\r
1066                         {\r
1067                                 // 名前を変更する\r
1068                                 strcpy(TmpString, Pos->File);\r
1069                                 CurWin = WIN_LOCAL;\r
1070 #if defined(HAVE_TANDEM)\r
1071                                 strcpy(TmpFileCode, "0"); /* ASCII モードの場合は無視される */\r
1072                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1073                                         if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_with_ext_dlg), GetMainHwnd(), UpDownAsWithExtDialogCallBack) == YES) {\r
1074                                                 strcat(Pkt.RemoteFile, TmpString);\r
1075                                                 Pkt.FileCode = atoi(TmpFileCode);\r
1076                                         } else {\r
1077                                                 break;\r
1078                                         }\r
1079                                 } else\r
1080 #endif\r
1081                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_dlg), GetMainHwnd(), UpDownAsDialogCallBack) == YES)\r
1082                                         strcat(Pkt.RemoteFile, TmpString);\r
1083                                 else\r
1084                                         break;\r
1085                         }\r
1086                         // バグ修正\r
1087                         AskRemoteCurDir(Tmp, FMAX_PATH);\r
1088                         SetSlashTail(Tmp);\r
1089                         if(strncmp(Pkt.RemoteFile, Tmp, strlen(Tmp)) != 0)\r
1090                         {\r
1091                                 if((Cat = strrchr(Pkt.RemoteFile, '/')) != NULL)\r
1092                                         Cat++;\r
1093                                 else\r
1094                                         Cat = Pkt.RemoteFile;\r
1095                         }\r
1096                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1097 \r
1098                         if(AskHostType() == HTYPE_ACOS)\r
1099                         {\r
1100                                 strcpy(Pkt.RemoteFile, "'");\r
1101                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
1102                                 strcat(Pkt.RemoteFile, "(");\r
1103                                 strcat(Pkt.RemoteFile, Cat);\r
1104                                 strcat(Pkt.RemoteFile, ")");\r
1105                                 strcat(Pkt.RemoteFile, "'");\r
1106                         }\r
1107                         else if(AskHostType() == HTYPE_ACOS_4)\r
1108                                 strcpy(Pkt.RemoteFile, Cat);\r
1109 \r
1110                         if(Pos->Node == NODE_DIR)\r
1111                         {\r
1112                                 // フォルダの場合\r
1113 \r
1114                                 // ホスト側のファイル一覧をRemoteListに登録\r
1115                                 // 同名ファイルチェック用\r
1116                                 if(RemoteList != NULL)\r
1117                                         DeleteFileList(&RemoteList);\r
1118                                 RemoteList = NULL;\r
1119 \r
1120                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1121                                 if(DoCWD(Pkt.RemoteFile, NO, NO, NO) == FTP_COMPLETE)\r
1122                                 {\r
1123                                         if(DoDirListCmdSkt("", "", 998, &CancelFlg) == FTP_COMPLETE)\r
1124                                                 AddRemoteTreeToFileList(998, "", RDIR_NONE, &RemoteList);\r
1125                                         DoCWD(Tmp, NO, NO, NO);\r
1126                                 }\r
1127                                 else\r
1128                                 {\r
1129                                         // フォルダを作成\r
1130                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1131                                         {\r
1132                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1133                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1134                                                 AddTransFileList(&Pkt1);\r
1135                                         }\r
1136                                         FirstAdd = NO;\r
1137                                         strcpy(Pkt.Cmd, "MKD ");\r
1138                                         strcpy(Pkt.LocalFile, "");\r
1139                                         AddTransFileList(&Pkt);\r
1140                                 }\r
1141                         }\r
1142                         else if(Pos->Node == NODE_FILE)\r
1143                         {\r
1144                                 // ファイルの場合\r
1145                                 AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
1146                                 SetYenTail(Pkt.LocalFile);\r
1147                                 strcat(Pkt.LocalFile, Pos->File);\r
1148                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1149 \r
1150                                 strcpy(Pkt.Cmd, "STOR ");\r
1151                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1152                                 Pkt.Size = 0;\r
1153                                 Pkt.Time = Pos->Time;\r
1154                                 Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile);\r
1155                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1156                                 // UTF-8対応\r
1157                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1158                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1159 #if defined(HAVE_TANDEM)\r
1160                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1161                                         CalcExtentSize(&Pkt, Pos->Size);\r
1162                                 }\r
1163 #endif\r
1164                                 // ディレクトリ自動作成\r
1165                                 strcpy(Tmp, Pkt.RemoteFile);\r
1166                                 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
1167                                 if(Pkt.Mode == EXIST_ABORT)\r
1168                                         break;\r
1169                                 else if(Pkt.Mode != EXIST_IGNORE)\r
1170                                 {\r
1171                                         // ディレクトリ自動作成\r
1172                                         if(MakeAllDir == YES)\r
1173                                         {\r
1174                                                 if(MakeDirFromRemotePath(Pkt.RemoteFile, Tmp, FirstAdd) == YES)\r
1175                                                         FirstAdd = NO;\r
1176                                         }\r
1177                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1178                                         {\r
1179                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1180                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1181                                                 AddTransFileList(&Pkt1);\r
1182                                         }\r
1183                                         FirstAdd = NO;\r
1184                                         AddTransFileList(&Pkt);\r
1185                                 }\r
1186                         }\r
1187                         Pos = Pos->Next;\r
1188                 }\r
1189 \r
1190                 if((FirstAdd == NO) && (AskNoFullPathMode() == YES))\r
1191                 {\r
1192                         strcpy(Pkt.Cmd, "BACKCUR");\r
1193                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1194                         AddTransFileList(&Pkt);\r
1195                 }\r
1196 \r
1197                 if(RemoteList != NULL)\r
1198                         DeleteFileList(&RemoteList);\r
1199 \r
1200                 DeleteFileList(&FileListBase);\r
1201 \r
1202                 // 同時接続対応\r
1203 //              strcpy(Pkt.Cmd, "GOQUIT");\r
1204 //              AddTransFileList(&Pkt);\r
1205 \r
1206                 GoForwardTransWindow();\r
1207 \r
1208                 EnableUserOpe();\r
1209         }\r
1210         return;\r
1211 }\r
1212 \r
1213 \r
1214 /*----- ドラッグ&ドロップで指定されたファイルをアップロードする --------------\r
1215 *\r
1216 *       Parameter\r
1217 *               WPARAM wParam : ドロップされたファイルの情報\r
1218 *\r
1219 *       Return Value\r
1220 *               なし\r
1221 *----------------------------------------------------------------------------*/\r
1222 \r
1223 void UploadDragProc(WPARAM wParam)\r
1224 {\r
1225         FILELIST *FileListBase;\r
1226         FILELIST *Pos;\r
1227         TRANSPACKET Pkt;\r
1228         TRANSPACKET Pkt1;\r
1229         char *Cat;\r
1230         FILELIST *RemoteList;\r
1231         char Tmp[FMAX_PATH+1];\r
1232         int FirstAdd;\r
1233         char Cur[FMAX_PATH+1];\r
1234 \r
1235         // 同時接続対応\r
1236         CancelFlg = NO;\r
1237 \r
1238         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1239         {\r
1240                 DisableUserOpe();\r
1241 \r
1242                 // ローカル側で選ばれているファイルをFileListBaseに登録\r
1243                 FileListBase = NULL;\r
1244                 MakeDroppedFileList(wParam, Cur, &FileListBase);\r
1245 \r
1246                 // 現在ホスト側のファイル一覧に表示されているものをRemoteListに登録\r
1247                 // 同名ファイルチェック用\r
1248                 RemoteList = NULL;\r
1249                 AddRemoteTreeToFileList(AskCurrentFileListNum(), "", RDIR_NONE, &RemoteList);\r
1250 \r
1251                 FirstAdd = YES;\r
1252                 ExistNotify = YES;\r
1253 \r
1254                 Pos = FileListBase;\r
1255                 while(Pos != NULL)\r
1256                 {\r
1257                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1258                         SetSlashTail(Pkt.RemoteFile);\r
1259                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1260 \r
1261                         strcat(Pkt.RemoteFile, Pos->File);\r
1262                         if(FnameCnv == FNAME_LOWER)\r
1263                                 _mbslwr(Cat);\r
1264                         else if(FnameCnv == FNAME_UPPER)\r
1265                                 _mbsupr(Cat);\r
1266                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1267 #if defined(HAVE_TANDEM)\r
1268                         Pkt.FileCode = 0;\r
1269                         Pkt.PriExt = DEF_PRIEXT;\r
1270                         Pkt.SecExt = DEF_SECEXT;\r
1271                         Pkt.MaxExt = DEF_MAXEXT;\r
1272 #endif\r
1273 \r
1274                         if(AskHostType() == HTYPE_ACOS)\r
1275                         {\r
1276                                 strcpy(Pkt.RemoteFile, "'");\r
1277                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
1278                                 strcat(Pkt.RemoteFile, "(");\r
1279                                 strcat(Pkt.RemoteFile, Cat);\r
1280                                 strcat(Pkt.RemoteFile, ")");\r
1281                                 strcat(Pkt.RemoteFile, "'");\r
1282                         }\r
1283                         else if(AskHostType() == HTYPE_ACOS_4)\r
1284                                 strcpy(Pkt.RemoteFile, Cat);\r
1285 \r
1286                         if(Pos->Node == NODE_DIR)\r
1287                         {\r
1288                                 // フォルダの場合\r
1289 \r
1290                                 // ホスト側のファイル一覧をRemoteListに登録\r
1291                                 // 同名ファイルチェック用\r
1292                                 if(RemoteList != NULL)\r
1293                                         DeleteFileList(&RemoteList);\r
1294                                 RemoteList = NULL;\r
1295 \r
1296                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1297                                 if(DoCWD(Pkt.RemoteFile, NO, NO, NO) == FTP_COMPLETE)\r
1298                                 {\r
1299                                         if(DoDirListCmdSkt("", "", 998, &CancelFlg) == FTP_COMPLETE)\r
1300                                                 AddRemoteTreeToFileList(998, "", RDIR_NONE, &RemoteList);\r
1301                                         DoCWD(Tmp, NO, NO, NO);\r
1302                                 }\r
1303                                 else\r
1304                                 {\r
1305                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1306                                         {\r
1307                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1308                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1309                                                 AddTransFileList(&Pkt1);\r
1310                                         }\r
1311                                         FirstAdd = NO;\r
1312                                         strcpy(Pkt.Cmd, "MKD ");\r
1313                                         strcpy(Pkt.LocalFile, "");\r
1314                                         AddTransFileList(&Pkt);\r
1315                                 }\r
1316                         }\r
1317                         else if(Pos->Node == NODE_FILE)\r
1318                         {\r
1319                                 // ファイルの場合\r
1320                                 strcpy(Pkt.LocalFile, Cur);\r
1321                                 SetYenTail(Pkt.LocalFile);\r
1322                                 strcat(Pkt.LocalFile, Pos->File);\r
1323                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1324 \r
1325                                 strcpy(Pkt.Cmd, "STOR ");\r
1326                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1327                                 Pkt.Size = 0;\r
1328                                 Pkt.Time = Pos->Time;\r
1329                                 Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile);\r
1330                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1331                                 // UTF-8対応\r
1332                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1333                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1334 #if defined(HAVE_TANDEM)\r
1335                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1336                                         int a = Pos->InfoExist && FINFO_SIZE;\r
1337                                         CalcExtentSize(&Pkt, Pos->Size);\r
1338                                 }\r
1339 #endif\r
1340                                 // ディレクトリ自動作成\r
1341                                 strcpy(Tmp, Pkt.RemoteFile);\r
1342                                 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
1343                                 if(Pkt.Mode == EXIST_ABORT)\r
1344                                         break;\r
1345                                 else if(Pkt.Mode != EXIST_IGNORE)\r
1346                                 {\r
1347                                         // ディレクトリ自動作成\r
1348                                         if(MakeAllDir == YES)\r
1349                                         {\r
1350                                                 if(MakeDirFromRemotePath(Pkt.RemoteFile, Tmp, FirstAdd) == YES)\r
1351                                                         FirstAdd = NO;\r
1352                                         }\r
1353                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1354                                         {\r
1355                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1356                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1357                                                 AddTransFileList(&Pkt1);\r
1358                                         }\r
1359                                         FirstAdd = NO;\r
1360                                         AddTransFileList(&Pkt);\r
1361                                 }\r
1362                         }\r
1363                         Pos = Pos->Next;\r
1364                 }\r
1365 \r
1366                 if((FirstAdd == NO) && (AskNoFullPathMode() == YES))\r
1367                 {\r
1368                         strcpy(Pkt.Cmd, "BACKCUR");\r
1369                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1370                         AddTransFileList(&Pkt);\r
1371                 }\r
1372 \r
1373                 if(RemoteList != NULL)\r
1374                         DeleteFileList(&RemoteList);\r
1375 \r
1376                 DeleteFileList(&FileListBase);\r
1377 \r
1378                 // 同時接続対応\r
1379 //              strcpy(Pkt.Cmd, "GOQUIT");\r
1380 //              AddTransFileList(&Pkt);\r
1381 \r
1382                 GoForwardTransWindow();\r
1383 \r
1384                 EnableUserOpe();\r
1385         }\r
1386         return;\r
1387 }\r
1388 \r
1389 \r
1390 /*----- ミラーリングアップロードを行う ----------------------------------------\r
1391 *\r
1392 *       Parameter\r
1393 *               int Notify : 確認を行うかどうか (YES/NO)\r
1394 *\r
1395 *       Return Value\r
1396 *               なし\r
1397 *----------------------------------------------------------------------------*/\r
1398 \r
1399 void MirrorUploadProc(int Notify)\r
1400 {\r
1401         FILELIST *LocalListBase;\r
1402         FILELIST *RemoteListBase;\r
1403         FILELIST *LocalPos;\r
1404         FILELIST *RemotePos;\r
1405         TRANSPACKET Pkt;\r
1406         TRANSPACKET *Base;\r
1407         char Name[FMAX_PATH+1];\r
1408         char *Cat;\r
1409         int Level;\r
1410         int Mode;\r
1411         SYSTEMTIME TmpStime;\r
1412         FILETIME TmpFtimeL;\r
1413         FILETIME TmpFtimeR;\r
1414 \r
1415         // 同時接続対応\r
1416         CancelFlg = NO;\r
1417 \r
1418         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1419         {\r
1420                 DisableUserOpe();\r
1421 \r
1422                 Base = NULL;\r
1423 \r
1424                 if(Notify == YES)\r
1425                         Notify = DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_up_dlg), GetMainHwnd(), MirrorNotifyCallBack, 1);\r
1426                 else\r
1427                         Notify = YES;\r
1428 \r
1429                 if((Notify == YES) || (Notify == YES_LIST))\r
1430                 {\r
1431                         /*===== ファイルリスト取得 =====*/\r
1432 \r
1433                         LocalListBase = NULL;\r
1434                         MakeSelectedFileList(WIN_LOCAL, YES, YES, &LocalListBase, &CancelFlg);\r
1435                         RemoteListBase = NULL;\r
1436                         MakeSelectedFileList(WIN_REMOTE, YES, YES, &RemoteListBase, &CancelFlg);\r
1437 \r
1438                         LocalPos = LocalListBase;\r
1439                         while(LocalPos != NULL)\r
1440                         {\r
1441                                 LocalPos->Attr = YES;           /* LocalPos->Attrは転送するかどうかのフラグに使用 (YES/NO) */\r
1442                                 LocalPos = LocalPos->Next;\r
1443                         }\r
1444 \r
1445                         RemotePos = RemoteListBase;\r
1446                         while(RemotePos != NULL)\r
1447                         {\r
1448                                 if(AskMirrorNoTrn(RemotePos->File, 1) == NO)\r
1449                                 {\r
1450                                         RemotePos->Attr = YES;\r
1451                                         RemotePos = RemotePos->Next;\r
1452                                 }\r
1453                                 else\r
1454                                 {\r
1455                                         RemotePos->Attr = NO;   /* RemotePos->Attrは削除するかどうかのフラグに使用 (YES/NO) */\r
1456 \r
1457                                         if(RemotePos->Node == NODE_DIR)\r
1458                                         {\r
1459                                                 Level = AskDirLevel(RemotePos->File);\r
1460                                                 RemotePos = RemotePos->Next;\r
1461                                                 while(RemotePos != NULL)\r
1462                                                 {\r
1463                                                         if((RemotePos->Node == NODE_DIR) &&\r
1464                                                            (AskDirLevel(RemotePos->File) <= Level))\r
1465                                                         {\r
1466                                                                 break;\r
1467                                                         }\r
1468                                                         RemotePos->Attr = NO;\r
1469                                                         RemotePos = RemotePos->Next;\r
1470                                                 }\r
1471                                         }\r
1472                                         else\r
1473                                                 RemotePos = RemotePos->Next;\r
1474                                 }\r
1475                         }\r
1476 \r
1477                         /*===== ファイルリスト比較 =====*/\r
1478 \r
1479                         LocalPos = LocalListBase;\r
1480                         while(LocalPos != NULL)\r
1481                         {\r
1482                                 if(AskMirrorNoTrn(LocalPos->File, 0) == NO)\r
1483                                 {\r
1484                                         strcpy(Name, LocalPos->File);\r
1485                                         ReplaceAll(Name, '\\', '/');\r
1486 \r
1487                                         if(MirrorFnameCnv == YES)\r
1488                                                 Mode = COMP_LOWERMATCH;\r
1489                                         else\r
1490                                                 Mode = COMP_STRICT;\r
1491 \r
1492                                         if(LocalPos->Node == NODE_DIR)\r
1493                                         {\r
1494                                                 if((RemotePos = SearchFileList(Name, RemoteListBase, Mode)) != NULL)\r
1495                                                 {\r
1496                                                         if(RemotePos->Node == NODE_DIR)\r
1497                                                         {\r
1498                                                                 RemotePos->Attr = NO;\r
1499                                                                 LocalPos->Attr = NO;\r
1500                                                         }\r
1501                                                 }\r
1502                                         }\r
1503                                         else if(LocalPos->Node == NODE_FILE)\r
1504                                         {\r
1505                                                 if((RemotePos = SearchFileList(Name, RemoteListBase, Mode)) != NULL)\r
1506                                                 {\r
1507                                                         if(RemotePos->Node == NODE_FILE)\r
1508                                                         {\r
1509                                                                 FileTimeToLocalFileTime(&LocalPos->Time, &TmpFtimeL);\r
1510                                                                 FileTimeToLocalFileTime(&RemotePos->Time, &TmpFtimeR);\r
1511                                                                 if((RemotePos->InfoExist & FINFO_TIME) == 0)\r
1512                                                                 {\r
1513                                                                         FileTimeToSystemTime(&TmpFtimeL, &TmpStime);\r
1514                                                                         TmpStime.wHour = 0;\r
1515                                                                         TmpStime.wMinute = 0;\r
1516                                                                         TmpStime.wSecond = 0;\r
1517                                                                         TmpStime.wMilliseconds = 0;\r
1518                                                                         SystemTimeToFileTime(&TmpStime, &TmpFtimeL);\r
1519 \r
1520                                                                         FileTimeToSystemTime(&TmpFtimeR, &TmpStime);\r
1521                                                                         TmpStime.wHour = 0;\r
1522                                                                         TmpStime.wMinute = 0;\r
1523                                                                         TmpStime.wSecond = 0;\r
1524                                                                         TmpStime.wMilliseconds = 0;\r
1525                                                                         SystemTimeToFileTime(&TmpStime, &TmpFtimeR);\r
1526                                                                 }\r
1527                                                                 RemotePos->Attr = NO;\r
1528                                                                 if(CompareFileTime(&TmpFtimeL, &TmpFtimeR) <= 0)\r
1529                                                                         LocalPos->Attr = NO;\r
1530                                                         }\r
1531                                                 }\r
1532                                         }\r
1533 \r
1534                                         LocalPos = LocalPos->Next;\r
1535                                 }\r
1536                                 else\r
1537                                 {\r
1538                                         if(LocalPos->Node == NODE_FILE)\r
1539                                         {\r
1540                                                 LocalPos->Attr = NO;\r
1541                                                 LocalPos = LocalPos->Next;\r
1542                                         }\r
1543                                         else\r
1544                                         {\r
1545                                                 LocalPos->Attr = NO;\r
1546                                                 Level = AskDirLevel(LocalPos->File);\r
1547                                                 LocalPos = LocalPos->Next;\r
1548                                                 while(LocalPos != NULL)\r
1549                                                 {\r
1550                                                         if((LocalPos->Node == NODE_DIR) &&\r
1551                                                            (AskDirLevel(LocalPos->File) <= Level))\r
1552                                                         {\r
1553                                                                 break;\r
1554                                                         }\r
1555                                                         LocalPos->Attr = NO;\r
1556                                                         LocalPos = LocalPos->Next;\r
1557                                                 }\r
1558                                         }\r
1559                                 }\r
1560                         }\r
1561 \r
1562                         DispMirrorFiles(LocalListBase, RemoteListBase);\r
1563 \r
1564                         /*===== 削除/アップロード =====*/\r
1565 \r
1566                         RemotePos = RemoteListBase;\r
1567                         while(RemotePos != NULL)\r
1568                         {\r
1569                                 if((RemotePos->Attr == YES) && (RemotePos->Node == NODE_FILE))\r
1570                                 {\r
1571                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1572                                         SetSlashTail(Pkt.RemoteFile);\r
1573                                         strcat(Pkt.RemoteFile, RemotePos->File);\r
1574                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1575                                         strcpy(Pkt.LocalFile, "");\r
1576                                         strcpy(Pkt.Cmd, "R-DELE ");\r
1577                                         AddTmpTransFileList(&Pkt, &Base);\r
1578                                 }\r
1579                                 RemotePos = RemotePos->Next;\r
1580                         }\r
1581                         MirrorDeleteAllDir(RemoteListBase, &Pkt, &Base);\r
1582 \r
1583                         LocalPos = LocalListBase;\r
1584                         while(LocalPos != NULL)\r
1585                         {\r
1586                                 if(LocalPos->Attr == YES)\r
1587                                 {\r
1588                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1589                                         SetSlashTail(Pkt.RemoteFile);\r
1590                                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1591                                         strcat(Pkt.RemoteFile, LocalPos->File);\r
1592 \r
1593                                         if(MirrorFnameCnv == YES)\r
1594                                                 _mbslwr(Cat);\r
1595 \r
1596                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1597 \r
1598                                         if(LocalPos->Node == NODE_DIR)\r
1599                                         {\r
1600                                                 strcpy(Pkt.LocalFile, "");\r
1601                                                 strcpy(Pkt.Cmd, "R-MKD ");\r
1602                                                 AddTmpTransFileList(&Pkt, &Base);\r
1603                                         }\r
1604                                         else if(LocalPos->Node == NODE_FILE)\r
1605                                         {\r
1606                                                 AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
1607                                                 SetYenTail(Pkt.LocalFile);\r
1608                                                 strcat(Pkt.LocalFile, LocalPos->File);\r
1609                                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1610 \r
1611                                                 strcpy(Pkt.Cmd, "STOR ");\r
1612                                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1613                                                 Pkt.Size = 0;\r
1614                                                 Pkt.Time = LocalPos->Time;\r
1615                                                 Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile);\r
1616                                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1617                                                 // UTF-8対応\r
1618                                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1619                                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1620 #if defined(HAVE_TANDEM)\r
1621                                                 if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
1622                                                         CalcExtentSize(&Pkt, LocalPos->Size);\r
1623                                                 }\r
1624 #endif\r
1625                                                 Pkt.Mode = EXIST_OVW;\r
1626                                                 AddTmpTransFileList(&Pkt, &Base);\r
1627                                         }\r
1628                                 }\r
1629                                 LocalPos = LocalPos->Next;\r
1630                         }\r
1631 \r
1632                         if((Notify == YES) ||\r
1633                            (DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_notify_dlg), GetMainHwnd(), MirrorDispListCallBack, (LPARAM)&Base) == YES))\r
1634                         {\r
1635                                 if(AskNoFullPathMode() == YES)\r
1636                                 {\r
1637                                         strcpy(Pkt.Cmd, "SETCUR");\r
1638                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1639                                         AddTransFileList(&Pkt);\r
1640                                 }\r
1641                                 AppendTransFileList(Base);\r
1642 \r
1643                                 if(AskNoFullPathMode() == YES)\r
1644                                 {\r
1645                                         strcpy(Pkt.Cmd, "BACKCUR");\r
1646                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1647                                         AddTransFileList(&Pkt);\r
1648                                 }\r
1649 \r
1650                                 // 同時接続対応\r
1651 //                              strcpy(Pkt.Cmd, "GOQUIT");\r
1652 //                              AddTransFileList(&Pkt);\r
1653                         }\r
1654                         else\r
1655                                 EraseTmpTransFileList(&Base);\r
1656 \r
1657                         DeleteFileList(&LocalListBase);\r
1658                         DeleteFileList(&RemoteListBase);\r
1659 \r
1660                         GoForwardTransWindow();\r
1661                 }\r
1662 \r
1663                 EnableUserOpe();\r
1664         }\r
1665         return;\r
1666 }\r
1667 \r
1668 \r
1669 /*----- ミラーリング時のホスト側のフォルダ削除 --------------------------------\r
1670 *\r
1671 *       Parameter\r
1672 *               FILELIST *Base : ファイルリスト\r
1673 *               TRANSPACKET *Pkt : \r
1674 *               TRANSPACKET **Base : \r
1675 *\r
1676 *       Return Value\r
1677 *               なし\r
1678 *----------------------------------------------------------------------------*/\r
1679 \r
1680 static void MirrorDeleteAllDir(FILELIST *Remote, TRANSPACKET *Pkt, TRANSPACKET **Base)\r
1681 {\r
1682         while(Remote != NULL)\r
1683         {\r
1684                 if(Remote->Node == NODE_DIR)\r
1685                 {\r
1686                         MirrorDeleteAllDir(Remote->Next, Pkt, Base);\r
1687 \r
1688                         if(Remote->Attr == YES)\r
1689                         {\r
1690                                 AskRemoteCurDir(Pkt->RemoteFile, FMAX_PATH);\r
1691                                 SetSlashTail(Pkt->RemoteFile);\r
1692                                 strcat(Pkt->RemoteFile, Remote->File);\r
1693                                 ReplaceAll(Pkt->RemoteFile, '\\', '/');\r
1694                                 strcpy(Pkt->LocalFile, "");\r
1695                                 strcpy(Pkt->Cmd, "R-RMD ");\r
1696                                 AddTmpTransFileList(Pkt, Base);\r
1697                         }\r
1698                         break;\r
1699                 }\r
1700                 Remote = Remote->Next;\r
1701         }\r
1702         return;\r
1703 }\r
1704 \r
1705 \r
1706 /*----- ミラーリングアップロード開始確認ウインドウのコールバック --------------\r
1707 *\r
1708 *       Parameter\r
1709 *               HWND hDlg : ウインドウハンドル\r
1710 *               UINT message : メッセージ番号\r
1711 *               WPARAM wParam : メッセージの WPARAM 引数\r
1712 *               LPARAM lParam : メッセージの LPARAM 引数\r
1713 *\r
1714 *       Return Value\r
1715 *               BOOL TRUE/FALSE\r
1716 *----------------------------------------------------------------------------*/\r
1717 \r
1718 // 64ビット対応\r
1719 //static BOOL CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1720 static INT_PTR CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1721 {\r
1722         static int Mode;\r
1723 \r
1724         switch (iMessage)\r
1725         {\r
1726                 case WM_INITDIALOG :\r
1727                         Mode = lParam;\r
1728                         return(TRUE);\r
1729 \r
1730                 case WM_COMMAND :\r
1731                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1732                         {\r
1733                                 case IDOK :\r
1734                                         EndDialog(hDlg, YES);\r
1735                                         break;\r
1736 \r
1737                                 case IDCANCEL :\r
1738                                         EndDialog(hDlg, NO);\r
1739                                         break;\r
1740 \r
1741                                 case MIRRORUP_DISP :\r
1742                                         EndDialog(hDlg, YES_LIST);\r
1743                                         break;\r
1744 \r
1745                                 case IDHELP :\r
1746                                         if(Mode == 0)\r
1747                                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000013);\r
1748                                         else\r
1749                                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000012);\r
1750                         }\r
1751             return(TRUE);\r
1752         }\r
1753         return(FALSE);\r
1754 }\r
1755 \r
1756 \r
1757 /*----- ミラーリングアップロード処理内容確認ウインドウのコールバック ----------\r
1758 *\r
1759 *       Parameter\r
1760 *               HWND hDlg : ウインドウハンドル\r
1761 *               UINT message : メッセージ番号\r
1762 *               WPARAM wParam : メッセージの WPARAM 引数\r
1763 *               LPARAM lParam : メッセージの LPARAM 引数\r
1764 *\r
1765 *       Return Value\r
1766 *               BOOL TRUE/FALSE\r
1767 *----------------------------------------------------------------------------*/\r
1768 \r
1769 // 64ビット対応\r
1770 //static BOOL CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1771 static INT_PTR CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1772 {\r
1773         static DIALOGSIZE DlgSize = {\r
1774                 { MIRROR_DEL, MIRROR_SIZEGRIP, -1 },\r
1775                 { IDOK, IDCANCEL, IDHELP, MIRROR_DEL, MIRROR_COPYNUM, MIRROR_MAKENUM, MIRROR_DELNUM, MIRROR_SIZEGRIP, -1 },\r
1776                 { MIRROR_LIST, -1 },\r
1777                 { 0, 0 },\r
1778                 { 0, 0 }\r
1779         };\r
1780 \r
1781         static TRANSPACKET **Base;\r
1782         TRANSPACKET *Pos;\r
1783         char Tmp[FMAX_PATH+1+6];\r
1784         int Num;\r
1785         int *List;\r
1786 \r
1787         switch (iMessage)\r
1788         {\r
1789                 case WM_INITDIALOG :\r
1790                         Base = (TRANSPACKET **)lParam;\r
1791                         Pos = *Base;\r
1792                         while(Pos != NULL)\r
1793                         {\r
1794                                 strcpy(Tmp, "");\r
1795                                 if((strncmp(Pos->Cmd, "R-DELE", 6) == 0) ||\r
1796                                    (strncmp(Pos->Cmd, "R-RMD", 5) == 0))\r
1797                                         sprintf(Tmp, MSGJPN052, Pos->RemoteFile);\r
1798                                 else if(strncmp(Pos->Cmd, "R-MKD", 5) == 0)\r
1799                                         sprintf(Tmp, MSGJPN053, Pos->RemoteFile);\r
1800                                 else if(strncmp(Pos->Cmd, "STOR", 4) == 0)\r
1801                                         sprintf(Tmp, MSGJPN054, Pos->RemoteFile);\r
1802                                 else if((strncmp(Pos->Cmd, "L-DELE", 6) == 0) ||\r
1803                                                 (strncmp(Pos->Cmd, "L-RMD", 5) == 0))\r
1804                                         sprintf(Tmp, MSGJPN055, Pos->LocalFile);\r
1805                                 else if(strncmp(Pos->Cmd, "L-MKD", 5) == 0)\r
1806                                         sprintf(Tmp, MSGJPN056, Pos->LocalFile);\r
1807                                 else if(strncmp(Pos->Cmd, "RETR", 4) == 0)\r
1808                                         sprintf(Tmp, MSGJPN057, Pos->LocalFile);\r
1809 \r
1810                                 if(strlen(Tmp) > 0)\r
1811                                         SendDlgItemMessage(hDlg, MIRROR_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
1812                                 Pos = Pos->Next;\r
1813                         }\r
1814                         CountMirrorFiles(hDlg, *Base);\r
1815                         DlgSizeInit(hDlg, &DlgSize, &MirrorDlgSize);\r
1816                         EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), FALSE);\r
1817                         return(TRUE);\r
1818 \r
1819                 case WM_COMMAND :\r
1820                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1821                         {\r
1822                                 case IDOK :\r
1823                                         AskDlgSize(hDlg, &DlgSize, &MirrorDlgSize);\r
1824                                         EndDialog(hDlg, YES);\r
1825                                         break;\r
1826 \r
1827                                 case IDCANCEL :\r
1828                                         AskDlgSize(hDlg, &DlgSize, &MirrorDlgSize);\r
1829                                         EndDialog(hDlg, NO);\r
1830                                         break;\r
1831 \r
1832                                 case MIRROR_DEL :\r
1833                                         Num = SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELCOUNT, 0, 0);\r
1834                                         if((List = malloc(Num * sizeof(int))) != NULL)\r
1835                                         {\r
1836                                                 Num = SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELITEMS, Num, (LPARAM)List);\r
1837                                                 for(Num--; Num >= 0; Num--)\r
1838                                                 {\r
1839                                                         if(RemoveTmpTransFileListItem(Base, List[Num]) == FFFTP_SUCCESS)\r
1840                                                                 SendDlgItemMessage(hDlg, MIRROR_LIST, LB_DELETESTRING, List[Num], 0);\r
1841                                                         else\r
1842                                                                 MessageBeep(-1);\r
1843                                                 }\r
1844                                                 free(List);\r
1845                                                 CountMirrorFiles(hDlg, *Base);\r
1846                                         }\r
1847                                         break;\r
1848 \r
1849                                 case MIRROR_LIST :\r
1850                                         switch(GET_WM_COMMAND_CMD(wParam, lParam))\r
1851                                         {\r
1852                                                 case LBN_SELCHANGE :\r
1853                                                         if(SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELCOUNT, 0, 0) > 0)\r
1854                                                                 EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), TRUE);\r
1855                                                         else\r
1856                                                                 EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), FALSE);\r
1857                                                         break;\r
1858                                         }\r
1859                                         break;\r
1860 \r
1861                                 case IDHELP :\r
1862                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000012);\r
1863                         }\r
1864             return(TRUE);\r
1865 \r
1866                 case WM_SIZING :\r
1867                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
1868                     return(TRUE);\r
1869         }\r
1870         return(FALSE);\r
1871 }\r
1872 \r
1873 \r
1874 /*----- ミラーリングで転送/削除するファイルの数を数えダイアログに表示---------\r
1875 *\r
1876 *       Parameter\r
1877 *               HWND hWnd : \r
1878 *               TRANSPACKET *Pkt : \r
1879 *\r
1880 *       Return Value\r
1881 *               なし\r
1882 *----------------------------------------------------------------------------*/\r
1883 \r
1884 static void CountMirrorFiles(HWND hDlg, TRANSPACKET *Pkt)\r
1885 {\r
1886         char Tmp[80];\r
1887         int Del;\r
1888         int Make;\r
1889         int Copy;\r
1890 \r
1891         Del = 0;\r
1892         Make = 0;\r
1893         Copy = 0;\r
1894         while(Pkt != NULL)\r
1895         {\r
1896                 if((strncmp(Pkt->Cmd, "R-DELE", 6) == 0) ||\r
1897                    (strncmp(Pkt->Cmd, "R-RMD", 5) == 0) ||\r
1898                    (strncmp(Pkt->Cmd, "L-DELE", 6) == 0) ||\r
1899                    (strncmp(Pkt->Cmd, "L-RMD", 5) == 0))\r
1900                 {\r
1901                         Del += 1;\r
1902                 }\r
1903                 else if((strncmp(Pkt->Cmd, "R-MKD", 5) == 0) ||\r
1904                                 (strncmp(Pkt->Cmd, "L-MKD", 5) == 0))\r
1905                 {\r
1906                         Make += 1;\r
1907                 }\r
1908                 else if((strncmp(Pkt->Cmd, "STOR", 4) == 0) ||\r
1909                                 (strncmp(Pkt->Cmd, "RETR", 4) == 0))\r
1910                 {\r
1911                         Copy += 1;\r
1912                 }\r
1913                 Pkt = Pkt->Next;\r
1914         }\r
1915 \r
1916         if(Copy != 0)\r
1917                 sprintf(Tmp, MSGJPN058, Copy);\r
1918         else\r
1919                 sprintf(Tmp, MSGJPN059);\r
1920         SendDlgItemMessage(hDlg, MIRROR_COPYNUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1921 \r
1922         if(Make != 0)\r
1923                 sprintf(Tmp, MSGJPN060, Make);\r
1924         else\r
1925                 sprintf(Tmp, MSGJPN061);\r
1926         SendDlgItemMessage(hDlg, MIRROR_MAKENUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1927 \r
1928         if(Del != 0)\r
1929                 sprintf(Tmp, MSGJPN062, Del);\r
1930         else\r
1931                 sprintf(Tmp, MSGJPN063);\r
1932         SendDlgItemMessage(hDlg, MIRROR_DELNUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1933 \r
1934         return;\r
1935 }\r
1936 \r
1937 \r
1938 \r
1939 \r
1940 /*----- ミラーリングで転送/削除しないファイルかどうかを返す ------------------\r
1941 *\r
1942 *       Parameter\r
1943 *               char Fname : ファイル名\r
1944 *               int Mode : モード\r
1945 *                       0=転送しないファイル, 1=削除しないファイル\r
1946 *\r
1947 *       Return Value\r
1948 *               int ステータス\r
1949 *                       YES=転送・削除しない/NO\r
1950 *----------------------------------------------------------------------------*/\r
1951 \r
1952 static int AskMirrorNoTrn(char *Fname, int Mode)\r
1953 {\r
1954         int Ret;\r
1955         char *Tbl;\r
1956 \r
1957         Tbl = MirrorNoTrn;\r
1958         if(Mode == 1)\r
1959                 Tbl = MirrorNoDel;\r
1960 \r
1961         Ret = NO;\r
1962         if(StrMultiLen(Tbl) > 0)\r
1963         {\r
1964                 Fname = GetFileName(Fname);\r
1965                 while(*Tbl != NUL)\r
1966                 {\r
1967                         if(CheckFname(Fname, Tbl) == FFFTP_SUCCESS)\r
1968                         {\r
1969                                 Ret = YES;\r
1970                                 break;\r
1971                         }\r
1972                         Tbl += strlen(Tbl) + 1;\r
1973                 }\r
1974         }\r
1975         return(Ret);\r
1976 }\r
1977 \r
1978 \r
1979 /*----- アップロードするファイルの属性を返す ----------------------------------\r
1980 *\r
1981 *       Parameter\r
1982 *               char Fname : ファイル名\r
1983 *\r
1984 *       Return Value\r
1985 *               int 属性 (-1=設定なし)\r
1986 *----------------------------------------------------------------------------*/\r
1987 \r
1988 static int AskUploadFileAttr(char *Fname)\r
1989 {\r
1990         int Ret;\r
1991         int Sts;\r
1992         char *Tbl;\r
1993 \r
1994         Tbl = DefAttrList;\r
1995         Fname = GetFileName(Fname);\r
1996         Ret = -1;\r
1997         while(*Tbl != NUL)\r
1998         {\r
1999                 Sts = CheckFname(Fname, Tbl);\r
2000                 Tbl += strlen(Tbl) + 1;\r
2001 \r
2002                 if((Sts == FFFTP_SUCCESS) && (*Tbl != NUL))\r
2003                 {\r
2004                         Ret = xtoi(Tbl);\r
2005                         break;\r
2006                 }\r
2007                 Tbl += strlen(Tbl) + 1;\r
2008         }\r
2009         return(Ret);\r
2010 }\r
2011 \r
2012 \r
2013 /*----- ホストに同じ名前のファイルがないかチェック- ---------------------------a\r
2014 *\r
2015 *       Parameter\r
2016 *               TRANSPACKET *Pkt : 転送ファイル情報\r
2017 *               FILELIST *ListList : \r
2018 *\r
2019 *       Return Value\r
2020 *               int 処理方法\r
2021 *                       EXIST_OVW/EXIST_UNIQUE/EXIST_IGNORE\r
2022 *\r
2023 *       Note\r
2024 *               Pkt.ExistSize, UpExistMode、ExistNotify が変更される\r
2025 *----------------------------------------------------------------------------*/\r
2026 \r
2027 static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList)\r
2028 {\r
2029         int Ret;\r
2030 #if defined(HAVE_TANDEM)\r
2031         int Mode;\r
2032 #endif\r
2033         FILELIST *Exist;\r
2034 \r
2035         Ret = EXIST_OVW;\r
2036         Pkt->ExistSize = 0;\r
2037         if(SendMode != TRANS_OVW)\r
2038         {\r
2039 #if defined(HAVE_TANDEM)\r
2040                 /* HP NonStop Server は大文字小文字の区別なし(すべて大文字) */\r
2041                 if(AskHostType() == HTYPE_TANDEM)\r
2042                         Mode = COMP_IGNORE;\r
2043                 else\r
2044                         Mode = COMP_STRICT;\r
2045 \r
2046                 if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, Mode)) != NULL)\r
2047 #else\r
2048                 if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, COMP_STRICT)) != NULL)\r
2049 #endif\r
2050                 {\r
2051                         Pkt->ExistSize = Exist->Size;\r
2052 \r
2053                         if(ExistNotify == YES)\r
2054                         {\r
2055                                 SoundPlay(SND_ERROR);\r
2056                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(up_exist_dlg), GetMainHwnd(), UpExistDialogCallBack, (LPARAM)Pkt) == NO)\r
2057                                         Ret = EXIST_ABORT;\r
2058                                 else\r
2059                                         Ret = UpExistMode;\r
2060                         }\r
2061                         else\r
2062                                 Ret = UpExistMode;\r
2063 \r
2064                         if(Ret == EXIST_NEW)\r
2065                         {\r
2066                                 /*ファイル日付チェック */\r
2067                                 if(CompareFileTime(&Exist->Time, &Pkt->Time) < 0)\r
2068                                         Ret = EXIST_OVW;\r
2069                                 else\r
2070                                         Ret = EXIST_IGNORE;\r
2071                         }\r
2072                 }\r
2073         }\r
2074         return(Ret);\r
2075 }\r
2076 \r
2077 \r
2078 /*----- ホストに同じ名前のファイルがある時の確認ダイアログのコールバック ------\r
2079 *\r
2080 *       Parameter\r
2081 *               HWND hDlg : ウインドウハンドル\r
2082 *               UINT message : メッセージ番号\r
2083 *               WPARAM wParam : メッセージの WPARAM 引数\r
2084 *               LPARAM lParam : メッセージの LPARAM 引数\r
2085 *\r
2086 *       Return Value\r
2087 *               BOOL TRUE/FALSE\r
2088 *----------------------------------------------------------------------------*/\r
2089 \r
2090 // 64ビット対応\r
2091 //static BOOL CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2092 static INT_PTR CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2093 {\r
2094         static TRANSPACKET *Pkt;\r
2095         static const RADIOBUTTON UpExistButton[] = {\r
2096                 { UP_EXIST_OVW, EXIST_OVW },\r
2097                 { UP_EXIST_NEW, EXIST_NEW },\r
2098                 { UP_EXIST_RESUME, EXIST_RESUME },\r
2099                 { UP_EXIST_UNIQUE, EXIST_UNIQUE },\r
2100                 { UP_EXIST_IGNORE, EXIST_IGNORE }\r
2101         };\r
2102         #define UPEXISTBUTTONS  (sizeof(UpExistButton)/sizeof(RADIOBUTTON))\r
2103 \r
2104         switch (iMessage)\r
2105         {\r
2106                 case WM_INITDIALOG :\r
2107                         Pkt = (TRANSPACKET *)lParam;\r
2108                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, EM_LIMITTEXT, FMAX_PATH, 0);\r
2109                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, WM_SETTEXT, 0, (LPARAM)Pkt->RemoteFile);\r
2110 \r
2111                         if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
2112                                 EnableWindow(GetDlgItem(hDlg, UP_EXIST_RESUME), FALSE);\r
2113 \r
2114                         SetRadioButtonByValue(hDlg, UpExistMode, UpExistButton, UPEXISTBUTTONS);\r
2115                         return(TRUE);\r
2116 \r
2117                 case WM_COMMAND :\r
2118                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2119                         {\r
2120                                 case IDOK_ALL :\r
2121                                         ExistNotify = NO;\r
2122                                         /* ここに break はない */\r
2123 \r
2124                                 case IDOK :\r
2125                                         UpExistMode = AskRadioButtonValue(hDlg, UpExistButton, UPEXISTBUTTONS);\r
2126                                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, WM_GETTEXT, FMAX_PATH, (LPARAM)Pkt->RemoteFile);\r
2127                                         EndDialog(hDlg, YES);\r
2128                                         break;\r
2129 \r
2130                                 case IDCANCEL :\r
2131 //                                      Pkt->Abort = ABORT_USER;\r
2132 //                                      UpExistMode = EXIST_IGNORE;\r
2133                                         EndDialog(hDlg, NO);\r
2134                                         break;\r
2135 \r
2136                                 case IDHELP :\r
2137                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000011);\r
2138                                         break;\r
2139                         }\r
2140             return(TRUE);\r
2141         }\r
2142         return(FALSE);\r
2143 }\r
2144 \r
2145 \r
2146 /*----- アップロード/ダウンロードファイル名入力ダイアログのコールバック ------\r
2147 *\r
2148 *       Parameter\r
2149 *               HWND hDlg : ウインドウハンドル\r
2150 *               UINT message : メッセージ番号\r
2151 *               WPARAM wParam : メッセージの WPARAM 引数\r
2152 *               LPARAM lParam : メッセージの LPARAM 引数\r
2153 *\r
2154 *       Return Value\r
2155 *               BOOL TRUE/FALSE\r
2156 *----------------------------------------------------------------------------*/\r
2157 \r
2158 // 64ビット対応\r
2159 //static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2160 static INT_PTR CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2161 {\r
2162         switch (iMessage)\r
2163         {\r
2164                 case WM_INITDIALOG :\r
2165                         if(CurWin == WIN_LOCAL)\r
2166                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN064);\r
2167                         else\r
2168                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN065);\r
2169 \r
2170                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2171                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2172                         SendDlgItemMessage(hDlg, UPDOWNAS_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2173                         return(TRUE);\r
2174 \r
2175                 case WM_COMMAND :\r
2176                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2177                         {\r
2178                                 case IDOK :\r
2179                                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2180                                         EndDialog(hDlg, YES);\r
2181                                         break;\r
2182 \r
2183                                 case UPDOWNAS_STOP :\r
2184                                         EndDialog(hDlg, NO_ALL);\r
2185                                         break;\r
2186                         }\r
2187             return(TRUE);\r
2188         }\r
2189         return(FALSE);\r
2190 }\r
2191 \r
2192 \r
2193 #if defined(HAVE_TANDEM)\r
2194 /*----- アップロード/ダウンロードファイル名入力ダイアログのコールバック ------\r
2195 *\r
2196 *       Parameter\r
2197 *               HWND hDlg : ウインドウハンドル\r
2198 *               UINT message : メッセージ番号\r
2199 *               WPARAM wParam : メッセージの WPARAM 引数\r
2200 *               LPARAM lParam : メッセージの LPARAM 引数\r
2201 *\r
2202 *       Return Value\r
2203 *               BOOL TRUE/FALSE\r
2204 *----------------------------------------------------------------------------*/\r
2205 \r
2206 static INT_PTR CALLBACK UpDownAsWithExtDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2207 {\r
2208         switch (iMessage)\r
2209         {\r
2210                 case WM_INITDIALOG :\r
2211                         if(CurWin == WIN_LOCAL)\r
2212                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN064);\r
2213                         else\r
2214                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN065);\r
2215 \r
2216                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2217                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2218                         SendDlgItemMessage(hDlg, UPDOWNAS_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2219                         SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, EM_LIMITTEXT, 4, 0);\r
2220                         SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, WM_SETTEXT, 0, (LPARAM)TmpFileCode);\r
2221 \r
2222                         return(TRUE);\r
2223 \r
2224                 case WM_COMMAND :\r
2225                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2226                         {\r
2227                                 case IDOK :\r
2228                                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2229                                         SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpFileCode);\r
2230                                         EndDialog(hDlg, YES);\r
2231                                         break;\r
2232 \r
2233                                 case UPDOWNAS_STOP :\r
2234                                         EndDialog(hDlg, NO_ALL);\r
2235                                         break;\r
2236                         }\r
2237             return(TRUE);\r
2238         }\r
2239         return(FALSE);\r
2240 }\r
2241 #endif\r
2242 \r
2243 \r
2244 /*----- ファイル一覧で指定されたファイルを削除する ----------------------------\r
2245 *\r
2246 *       Parameter\r
2247 *               なし\r
2248 *\r
2249 *       Return Value\r
2250 *               なし\r
2251 *----------------------------------------------------------------------------*/\r
2252 \r
2253 void DeleteProc(void)\r
2254 {\r
2255         int Win;\r
2256         FILELIST *FileListBase;\r
2257         FILELIST *Pos;\r
2258         int DelFlg;\r
2259         int Sts;\r
2260         char CurDir[FMAX_PATH+1];\r
2261         char Tmp[FMAX_PATH+1];\r
2262 \r
2263         // 同時接続対応\r
2264         CancelFlg = NO;\r
2265 \r
2266         // デッドロック対策\r
2267         DisableUserOpe();\r
2268         Sts = YES;\r
2269         AskRemoteCurDir(CurDir, FMAX_PATH);\r
2270         FileListBase = NULL;\r
2271         if(GetFocus() == GetLocalHwnd())\r
2272         {\r
2273                 Win = WIN_LOCAL;\r
2274                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2275         }\r
2276         else\r
2277         {\r
2278                 Win = WIN_REMOTE;\r
2279                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2280                         MakeSelectedFileList(Win, YES, NO, &FileListBase, &CancelFlg);\r
2281                 else\r
2282                         Sts = NO;\r
2283         }\r
2284 \r
2285         if(Sts == YES)\r
2286         {\r
2287                 // デッドロック対策\r
2288 //              DisableUserOpe();\r
2289 \r
2290                 DelFlg = NO;\r
2291                 Sts = NO;\r
2292                 Pos = FileListBase;\r
2293                 while(Pos != NULL)\r
2294                 {\r
2295                         if(Pos->Node == NODE_FILE)\r
2296                         {\r
2297                                 DelNotifyAndDo(Pos, Win, &Sts, &DelFlg, CurDir);\r
2298                                 if(Sts == NO_ALL)\r
2299                                         break;\r
2300                         }\r
2301                         Pos = Pos->Next;\r
2302                 }\r
2303 \r
2304                 if(Sts != NO_ALL)\r
2305                         DeleteAllDir(FileListBase, Win, &Sts, &DelFlg, CurDir);\r
2306 \r
2307                 if(Win == WIN_REMOTE)\r
2308                 {\r
2309                         AskRemoteCurDir(Tmp, FMAX_PATH);\r
2310                         if(strcmp(Tmp, CurDir) != 0)\r
2311                                 DoCWD(Tmp, NO, NO, NO);\r
2312                 }\r
2313 \r
2314                 DeleteFileList(&FileListBase);\r
2315 \r
2316                 if(DelFlg == YES)\r
2317                 {\r
2318                         if(Win == WIN_LOCAL)\r
2319                                 GetLocalDirForWnd();\r
2320                         else\r
2321                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2322                 }\r
2323 \r
2324                 // デッドロック対策\r
2325 //              EnableUserOpe();\r
2326         }\r
2327         // デッドロック対策\r
2328         EnableUserOpe();\r
2329         return;\r
2330 }\r
2331 \r
2332 \r
2333 /*----- サブディレクトリ以下を全て削除する ------------------------------------\r
2334 *\r
2335 *       Parameter\r
2336 *               FILELIST *Dt : 削除するファイルのリスト\r
2337 *               int Win : ウインドウ番号 (WIN_xxx)\r
2338 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2339 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2340 *               char *CurDir : カレントディレクトリ\r
2341 *\r
2342 *       Return Value\r
2343 *               なし\r
2344 *----------------------------------------------------------------------------*/\r
2345 \r
2346 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2347 {\r
2348         while(Dt != NULL)\r
2349         {\r
2350                 if(Dt->Node == NODE_DIR)\r
2351                 {\r
2352                         DeleteAllDir(Dt->Next, Win, Sw, Flg, CurDir);\r
2353                         if(*Sw == NO_ALL)\r
2354                                 break;\r
2355 \r
2356                         DelNotifyAndDo(Dt, Win, Sw, Flg, CurDir);\r
2357                         break;\r
2358                 }\r
2359                 Dt = Dt->Next;\r
2360         }\r
2361         return;\r
2362 }\r
2363 \r
2364 \r
2365 /*----- 削除するかどうかの確認と削除実行 --------------------------------------\r
2366 *\r
2367 *       Parameter\r
2368 *               FILELIST *Dt : 削除するファイルのリスト\r
2369 *               int Win : ウインドウ番号 (WIN_xxx)\r
2370 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2371 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2372 *               char *CurDir : カレントディレクトリ\r
2373 *\r
2374 *       Return Value\r
2375 *               なし\r
2376 *----------------------------------------------------------------------------*/\r
2377 \r
2378 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2379 {\r
2380         char Path[FMAX_PATH+1];\r
2381 \r
2382         if(Win == WIN_LOCAL)\r
2383         {\r
2384                 AskLocalCurDir(Path, FMAX_PATH);\r
2385                 SetYenTail(Path);\r
2386                 strcat(Path, Dt->File);\r
2387                 ReplaceAll(Path, '/', '\\');\r
2388         }\r
2389         else\r
2390         {\r
2391                 AskRemoteCurDir(Path, FMAX_PATH);\r
2392                 SetSlashTail(Path);\r
2393                 strcat(Path, Dt->File);\r
2394                 ReplaceAll(Path, '\\', '/');\r
2395         }\r
2396 \r
2397         if(*Sw != YES_ALL)\r
2398         {\r
2399                 sprintf(TmpString, "%s", Path);\r
2400 \r
2401                 // ローカルのファイルのパスの最後の'\\'が消えるバグ修正\r
2402 //              if(AskHostType() == HTYPE_VMS)\r
2403                 if(Win == WIN_REMOTE && AskHostType() == HTYPE_VMS)\r
2404                         ReformToVMSstylePathName(TmpString);\r
2405 \r
2406                 CurWin = Win;\r
2407                 *Sw = DialogBox(GetFtpInst(), MAKEINTRESOURCE(delete_dlg), GetMainHwnd(), DeleteDialogCallBack);\r
2408         }\r
2409 \r
2410         if((*Sw == YES) || (*Sw == YES_ALL))\r
2411         {\r
2412                 if(Win == WIN_LOCAL)\r
2413                 {\r
2414                         if(Dt->Node == NODE_FILE)\r
2415                                 DoLocalDELE(Path);\r
2416                         else\r
2417                                 DoLocalRMD(Path);\r
2418                         *Flg = YES;\r
2419                 }\r
2420                 else\r
2421                 {\r
2422                         /* フルパスを使わない時のための処理 */\r
2423                         // 同時接続対応\r
2424 //                      if(ProcForNonFullpath(Path, CurDir, GetMainHwnd(), 0) == FFFTP_FAIL)\r
2425                         if(ProcForNonFullpath(AskCmdCtrlSkt(), Path, CurDir, GetMainHwnd(), &CancelFlg) == FFFTP_FAIL)\r
2426                                 *Sw = NO_ALL;\r
2427 \r
2428                         if(*Sw != NO_ALL)\r
2429                         {\r
2430                                 if(Dt->Node == NODE_FILE)\r
2431                                         DoDELE(Path);\r
2432                                 else\r
2433                                         DoRMD(Path);\r
2434                                 *Flg = YES;\r
2435                         }\r
2436                 }\r
2437         }\r
2438         return;\r
2439 }\r
2440 \r
2441 \r
2442 /*----- ファイル削除ダイアログのコールバック ----------------------------------\r
2443 *\r
2444 *       Parameter\r
2445 *               HWND hDlg : ウインドウハンドル\r
2446 *               UINT message : メッセージ番号\r
2447 *               WPARAM wParam : メッセージの WPARAM 引数\r
2448 *               LPARAM lParam : メッセージの LPARAM 引数\r
2449 *\r
2450 *       Return Value\r
2451 *               BOOL TRUE/FALSE\r
2452 *----------------------------------------------------------------------------*/\r
2453 \r
2454 // 64ビット対応\r
2455 //static BOOL CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2456 static INT_PTR CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2457 {\r
2458         switch (iMessage)\r
2459         {\r
2460                 case WM_INITDIALOG :\r
2461                         if(CurWin == WIN_LOCAL)\r
2462                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN066);\r
2463                         else\r
2464                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN067);\r
2465                         SendDlgItemMessage(hDlg, DELETE_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2466                         return(TRUE);\r
2467 \r
2468                 case WM_COMMAND :\r
2469                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2470                         {\r
2471                                 case IDOK :\r
2472                                         EndDialog(hDlg, YES);\r
2473                                         break;\r
2474 \r
2475                                 case DELETE_NO :\r
2476                                         EndDialog(hDlg, NO);\r
2477                                         break;\r
2478 \r
2479                                 case DELETE_ALL :\r
2480                                         EndDialog(hDlg, YES_ALL);\r
2481                                         break;\r
2482 \r
2483                                 case IDCANCEL :\r
2484                                         EndDialog(hDlg, NO_ALL);\r
2485                                         break;\r
2486                         }\r
2487             return(TRUE);\r
2488         }\r
2489         return(FALSE);\r
2490 }\r
2491 \r
2492 \r
2493 /*----- ファイル一覧で指定されたファイルの名前を変更する ----------------------\r
2494 *\r
2495 *       Parameter\r
2496 *               なし\r
2497 *\r
2498 *       Return Value\r
2499 *               なし\r
2500 *----------------------------------------------------------------------------*/\r
2501 \r
2502 void RenameProc(void)\r
2503 {\r
2504         int Win;\r
2505         FILELIST *FileListBase;\r
2506         FILELIST *Pos;\r
2507         char New[FMAX_PATH+1];\r
2508         int RenFlg;\r
2509         int Sts;\r
2510 \r
2511         // 同時接続対応\r
2512         CancelFlg = NO;\r
2513 \r
2514         Sts = FFFTP_SUCCESS;\r
2515         if(GetFocus() == GetLocalHwnd())\r
2516                 Win = WIN_LOCAL;\r
2517         else\r
2518         {\r
2519                 Win = WIN_REMOTE;\r
2520                 Sts = CheckClosedAndReconnect();\r
2521         }\r
2522 \r
2523         if(Sts == FFFTP_SUCCESS)\r
2524         {\r
2525                 DisableUserOpe();\r
2526 \r
2527                 FileListBase = NULL;\r
2528                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2529 \r
2530                 RenFlg = NO;\r
2531                 Sts = NO;\r
2532                 Pos = FileListBase;\r
2533                 while(Pos != NULL)\r
2534                 {\r
2535                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2536                         {\r
2537                                 strcpy(TmpString, Pos->File);\r
2538                                 CurWin = Win;\r
2539                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2540 \r
2541                                 if(Sts == NO_ALL)\r
2542                                         break;\r
2543 \r
2544                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2545                                 {\r
2546                                         strcpy(New, TmpString);\r
2547                                         if(Win == WIN_LOCAL)\r
2548                                                 DoLocalRENAME(Pos->File, New);\r
2549                                         else\r
2550                                                 DoRENAME(Pos->File, New);\r
2551                                         RenFlg = YES;\r
2552                                 }\r
2553                         }\r
2554                         Pos = Pos->Next;\r
2555                 }\r
2556                 DeleteFileList(&FileListBase);\r
2557 \r
2558                 if(RenFlg == YES)\r
2559                 {\r
2560                         if(Win == WIN_LOCAL)\r
2561                                 GetLocalDirForWnd();\r
2562                         else\r
2563                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2564                 }\r
2565 \r
2566                 EnableUserOpe();\r
2567         }\r
2568         return;\r
2569 }\r
2570 \r
2571 \r
2572 //\r
2573 // リモート側でのファイルの移動(リネーム)を行う\r
2574 //  \r
2575 // RenameProc()をベースに改造。(2007.9.5 yutaka)\r
2576 //\r
2577 void MoveRemoteFileProc(int drop_index)\r
2578 {\r
2579         int Win;\r
2580         FILELIST *FileListBase;\r
2581         FILELIST *Pos;\r
2582         FILELIST Pkt;\r
2583         char New[FMAX_PATH+1];\r
2584         char Old[FMAX_PATH+1];\r
2585         char HostDir[FMAX_PATH+1];\r
2586         int RenFlg;\r
2587         int Sts;\r
2588 \r
2589         // 同時接続対応\r
2590         CancelFlg = NO;\r
2591 \r
2592         if(MoveMode == MOVE_DISABLE)\r
2593         {\r
2594                 return;\r
2595         }\r
2596 \r
2597         AskRemoteCurDir(HostDir, FMAX_PATH);\r
2598 \r
2599         // ドロップ先のフォルダ名を得る\r
2600         GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH);\r
2601 \r
2602         if(MoveMode == MOVE_DLG)\r
2603         {\r
2604                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(move_notify_dlg), GetRemoteHwnd(), ExeEscTextDialogProc, (LPARAM)Pkt.File) == NO)\r
2605                 {\r
2606                         return;\r
2607                 }\r
2608         }\r
2609 \r
2610         Sts = FFFTP_SUCCESS;\r
2611 #if 0\r
2612         if(GetFocus() == GetLocalHwnd())\r
2613                 Win = WIN_LOCAL;\r
2614         else\r
2615         {\r
2616                 Win = WIN_REMOTE;\r
2617                 Sts = CheckClosedAndReconnect();\r
2618         }\r
2619 #else\r
2620                 Win = WIN_REMOTE;\r
2621                 Sts = CheckClosedAndReconnect();\r
2622 #endif\r
2623 \r
2624         if(Sts == FFFTP_SUCCESS)\r
2625         {\r
2626                 DisableUserOpe();\r
2627 \r
2628                 FileListBase = NULL;\r
2629                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2630 \r
2631                 RenFlg = NO;\r
2632                 Sts = NO;\r
2633                 Pos = FileListBase;\r
2634                 while(Pos != NULL)\r
2635                 {\r
2636                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2637                         {\r
2638                                 strcpy(TmpString, Pos->File);\r
2639                                 CurWin = Win;\r
2640 #if 0\r
2641                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2642 \r
2643                                 if(Sts == NO_ALL)\r
2644                                         break;\r
2645 #else\r
2646                                 Sts = YES;\r
2647 #endif\r
2648 \r
2649                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2650                                 {\r
2651                                         // パスの設定(local)\r
2652                                         strncpy_s(Old, sizeof(Old), HostDir, _TRUNCATE);\r
2653                                         strncat_s(Old, sizeof(Old), "/", _TRUNCATE);\r
2654                                         strncat_s(Old, sizeof(Old), Pos->File, _TRUNCATE);\r
2655 \r
2656                                         // パスの設定(remote)\r
2657                                         strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2658                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2659                                         strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2660                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2661                                         strncat_s(New, sizeof(New), Pos->File, _TRUNCATE);\r
2662 \r
2663                                         if(Win == WIN_LOCAL)\r
2664                                                 DoLocalRENAME(Old, New);\r
2665                                         else\r
2666                                                 DoRENAME(Old, New);\r
2667                                         RenFlg = YES;\r
2668                                 }\r
2669                         }\r
2670                         Pos = Pos->Next;\r
2671                 }\r
2672                 DeleteFileList(&FileListBase);\r
2673 \r
2674                 if(RenFlg == YES)\r
2675                 {\r
2676                         if(Win == WIN_LOCAL) {\r
2677                                 GetLocalDirForWnd();\r
2678                         } else {\r
2679                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2680 \r
2681                                 strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2682                                 strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2683                                 strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2684                                 DoCWD(New, YES, YES, YES);\r
2685                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2686                         }\r
2687                 }\r
2688 \r
2689                 EnableUserOpe();\r
2690         }\r
2691         return;\r
2692 }\r
2693 \r
2694 \r
2695 \r
2696 /*----- 新ファイル名入力ダイアログのコールバック ------------------------------\r
2697 *\r
2698 *       Parameter\r
2699 *               HWND hDlg : ウインドウハンドル\r
2700 *               UINT message : メッセージ番号\r
2701 *               WPARAM wParam : メッセージの WPARAM 引数\r
2702 *               LPARAM lParam : メッセージの LPARAM 引数\r
2703 *\r
2704 *       Return Value\r
2705 *               BOOL TRUE/FALSE\r
2706 *----------------------------------------------------------------------------*/\r
2707 \r
2708 // 64ビット対応\r
2709 //static BOOL CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2710 static INT_PTR CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2711 {\r
2712         switch (iMessage)\r
2713         {\r
2714                 case WM_INITDIALOG :\r
2715                         if(CurWin == WIN_LOCAL)\r
2716                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN068);\r
2717                         else\r
2718                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN069);\r
2719                         SendDlgItemMessage(hDlg, RENAME_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2720                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2721                         SendDlgItemMessage(hDlg, RENAME_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2722                         return(TRUE);\r
2723 \r
2724                 case WM_COMMAND :\r
2725                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2726                         {\r
2727                                 case IDOK :\r
2728                                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2729                                         EndDialog(hDlg, YES);\r
2730                                         break;\r
2731 \r
2732                                 case IDCANCEL :\r
2733                                         EndDialog(hDlg, NO);\r
2734                                         break;\r
2735 \r
2736                                 case RENAME_STOP :\r
2737                                         EndDialog(hDlg, NO_ALL);\r
2738                                         break;\r
2739                         }\r
2740             return(TRUE);\r
2741         }\r
2742         return(FALSE);\r
2743 }\r
2744 \r
2745 \r
2746 /*----- 新しいディレクトリを作成する ------------------------------------------\r
2747 *\r
2748 *       Parameter\r
2749 *               なし\r
2750 *\r
2751 *       Return Value\r
2752 *               なし\r
2753 *----------------------------------------------------------------------------*/\r
2754 \r
2755 void MkdirProc(void)\r
2756 {\r
2757         int Sts;\r
2758         int Win;\r
2759         char Path[FMAX_PATH+1];\r
2760         char *Title;\r
2761         int Tmp;\r
2762 \r
2763         // 同時接続対応\r
2764         CancelFlg = NO;\r
2765 \r
2766         if(GetFocus() == GetLocalHwnd())\r
2767         {\r
2768                 Win = WIN_LOCAL;\r
2769                 Title = MSGJPN070;\r
2770         }\r
2771         else\r
2772         {\r
2773                 Win = WIN_REMOTE;\r
2774                 Title = MSGJPN071;\r
2775         }\r
2776 \r
2777         strcpy(Path, "");\r
2778         Sts = InputDialogBox(mkdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2779 \r
2780         if((Sts == YES) && (strlen(Path) != 0))\r
2781         {\r
2782                 if(Win == WIN_LOCAL)\r
2783                 {\r
2784                         DisableUserOpe();\r
2785                         DoLocalMKD(Path);\r
2786                         GetLocalDirForWnd();\r
2787                         EnableUserOpe();\r
2788                 }\r
2789                 else\r
2790                 {\r
2791                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2792                         {\r
2793                                 DisableUserOpe();\r
2794                                 DoMKD(Path);\r
2795                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2796                                 EnableUserOpe();\r
2797                         }\r
2798                 }\r
2799         }\r
2800         return;\r
2801 }\r
2802 \r
2803 \r
2804 /*----- ヒストリリストを使ったディレクトリの移動 ------------------------------\r
2805 *\r
2806 *       Parameter\r
2807 *               HWND hWnd : コンボボックスのウインドウハンドル\r
2808 *\r
2809 *       Return Value\r
2810 *               なし\r
2811 *----------------------------------------------------------------------------*/\r
2812 \r
2813 void ChangeDirComboProc(HWND hWnd)\r
2814 {\r
2815         char Tmp[FMAX_PATH+1];\r
2816         int i;\r
2817 \r
2818         // 同時接続対応\r
2819         CancelFlg = NO;\r
2820 \r
2821         if((i = SendMessage(hWnd, CB_GETCURSEL, 0, 0)) != CB_ERR)\r
2822         {\r
2823                 SendMessage(hWnd, CB_GETLBTEXT, i, (LPARAM)Tmp);\r
2824 \r
2825                 if(hWnd == GetLocalHistHwnd())\r
2826                 {\r
2827                         DisableUserOpe();\r
2828                         DoLocalCWD(Tmp);\r
2829                         GetLocalDirForWnd();\r
2830                         EnableUserOpe();\r
2831                 }\r
2832                 else\r
2833                 {\r
2834                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2835                         {\r
2836                                 DisableUserOpe();\r
2837                                 if(DoCWD(Tmp, YES, NO, YES) < FTP_RETRY)\r
2838                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2839                                 EnableUserOpe();\r
2840                         }\r
2841                 }\r
2842         }\r
2843         return;\r
2844 }\r
2845 \r
2846 \r
2847 /*----- ブックマークを使ったディレクトリの移動 --------------------------------\r
2848 *\r
2849 *       Parameter\r
2850 *               int MarkID : ブックマークのメニューID\r
2851 *\r
2852 *       Return Value\r
2853 *               なし\r
2854 *----------------------------------------------------------------------------*/\r
2855 \r
2856 void ChangeDirBmarkProc(int MarkID)\r
2857 {\r
2858         char Local[FMAX_PATH+1];\r
2859         char Remote[FMAX_PATH+1];\r
2860         int Sts;\r
2861 \r
2862         // 同時接続対応\r
2863         CancelFlg = NO;\r
2864 \r
2865         Sts = AskBookMarkText(MarkID, Local, Remote, FMAX_PATH+1);\r
2866         if((Sts == BMARK_TYPE_LOCAL) || (Sts == BMARK_TYPE_BOTH))\r
2867         {\r
2868                 DisableUserOpe();\r
2869                 if(DoLocalCWD(Local) == FFFTP_SUCCESS)\r
2870                         GetLocalDirForWnd();\r
2871                 EnableUserOpe();\r
2872         }\r
2873 \r
2874         if((Sts == BMARK_TYPE_REMOTE) || (Sts == BMARK_TYPE_BOTH))\r
2875         {\r
2876                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2877                 {\r
2878                         DisableUserOpe();\r
2879                         if(DoCWD(Remote, YES, NO, YES) < FTP_RETRY)\r
2880                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2881                         EnableUserOpe();\r
2882                 }\r
2883         }\r
2884         return;\r
2885 }\r
2886 \r
2887 \r
2888 /*----- ディレクトリ名を入力してディレクトリの移動 ----------------------------\r
2889 *\r
2890 *       Parameter\r
2891 *               int Win : ウインドウ番号 (WIN_xxx)\r
2892 *\r
2893 *       Return Value\r
2894 *               なし\r
2895 *----------------------------------------------------------------------------*/\r
2896 \r
2897 void ChangeDirDirectProc(int Win)\r
2898 {\r
2899         int Sts;\r
2900         char Path[FMAX_PATH+1];\r
2901         char *Title;\r
2902         int Tmp;\r
2903 \r
2904         // 同時接続対応\r
2905         CancelFlg = NO;\r
2906 \r
2907         if(Win == WIN_LOCAL)\r
2908                 Title = MSGJPN072;\r
2909         else\r
2910                 Title = MSGJPN073;\r
2911 \r
2912         strcpy(Path, "");\r
2913         if(Win == WIN_LOCAL)\r
2914                 Sts = InputDialogBox(chdir_br_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2915         else\r
2916                 Sts = InputDialogBox(chdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2917 \r
2918         if((Sts == YES) && (strlen(Path) != 0))\r
2919         {\r
2920                 if(Win == WIN_LOCAL)\r
2921                 {\r
2922                         DisableUserOpe();\r
2923                         DoLocalCWD(Path);\r
2924                         GetLocalDirForWnd();\r
2925                         EnableUserOpe();\r
2926                 }\r
2927                 else\r
2928                 {\r
2929                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2930                         {\r
2931                                 DisableUserOpe();\r
2932                                 if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2933                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2934                                 EnableUserOpe();\r
2935                         }\r
2936                 }\r
2937         }\r
2938         return;\r
2939 }\r
2940 \r
2941 \r
2942 /*----- Dropされたファイルによるディレクトリの移動 ----------------------------\r
2943 *\r
2944 *       Parameter\r
2945 *               WPARAM wParam : ドロップされたファイルの情報\r
2946 *\r
2947 *       Return Value\r
2948 *               なし\r
2949 *----------------------------------------------------------------------------*/\r
2950 \r
2951 void ChangeDirDropFileProc(WPARAM wParam)\r
2952 {\r
2953         char Path[FMAX_PATH+1];\r
2954 \r
2955         DisableUserOpe();\r
2956         MakeDroppedDir(wParam, Path);\r
2957         DoLocalCWD(Path);\r
2958         GetLocalDirForWnd();\r
2959         EnableUserOpe();\r
2960         return;\r
2961 }\r
2962 \r
2963 \r
2964 /*----- ファイルの属性変更 ----------------------------------------------------\r
2965 *\r
2966 *       Parameter\r
2967 *               なし\r
2968 *\r
2969 *       Return Value\r
2970 *               なし\r
2971 *----------------------------------------------------------------------------*/\r
2972 \r
2973 void ChmodProc(void)\r
2974 {\r
2975         int ChmodFlg;\r
2976         FILELIST *FileListBase;\r
2977         FILELIST *Pos;\r
2978         char Tmp[5];\r
2979         char *Buf;\r
2980         char *BufTmp;\r
2981         int BufLen;\r
2982 \r
2983         // 同時接続対応\r
2984         CancelFlg = NO;\r
2985 \r
2986         if(GetFocus() == GetRemoteHwnd())\r
2987         {\r
2988                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2989                 {\r
2990                         DisableUserOpe();\r
2991                         FileListBase = NULL;\r
2992                         MakeSelectedFileList(WIN_REMOTE, NO, NO, &FileListBase, &CancelFlg);\r
2993                         if(FileListBase != NULL)\r
2994                         {\r
2995                                 sprintf(Tmp, "%03X", FileListBase->Attr);\r
2996                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(chmod_dlg), GetMainHwnd(), ChmodDialogCallBack, (LPARAM)Tmp) == YES)\r
2997                                 {\r
2998                                         ChmodFlg = NO;\r
2999                                         Pos = FileListBase;\r
3000                                         while(Pos != NULL)\r
3001                                         {\r
3002                                                 if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
3003                                                 {\r
3004                                                         DoCHMOD(Pos->File, Tmp);\r
3005                                                         ChmodFlg = YES;\r
3006                                                 }\r
3007                                                 Pos = Pos->Next;\r
3008                                         }\r
3009                                         if(ChmodFlg == YES)\r
3010                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
3011                                 }\r
3012                         }\r
3013                         DeleteFileList(&FileListBase);\r
3014                         EnableUserOpe();\r
3015                 }\r
3016         }\r
3017         else if(GetFocus() == GetLocalHwnd())\r
3018         {\r
3019                 DisableUserOpe();\r
3020                 FileListBase = NULL;\r
3021                 MakeSelectedFileList(WIN_LOCAL, NO, NO, &FileListBase, &CancelFlg);\r
3022                 if(FileListBase != NULL)\r
3023                 {\r
3024                         if((Buf = malloc(1)) != NULL)\r
3025                         {\r
3026                                 *Buf = NUL;\r
3027                                 BufLen = 0;\r
3028                                 Pos = FileListBase;\r
3029                                 while(Pos != NULL)\r
3030                                 {\r
3031                                         if((BufTmp = realloc(Buf, BufLen + strlen(Pos->File) + 2)) != NULL)\r
3032                                         {\r
3033                                                 Buf = BufTmp;\r
3034                                                 strcpy(Buf+BufLen, Pos->File);\r
3035                                                 BufLen += strlen(Pos->File) + 1;\r
3036                                         }\r
3037                                         Pos = Pos->Next;\r
3038                                 }\r
3039 \r
3040                                 memset(Buf+BufLen, NUL, 1);\r
3041                                 DispFileProperty(Buf);\r
3042                                 free(Buf);\r
3043                         }\r
3044                 }\r
3045                 DeleteFileList(&FileListBase);\r
3046                 EnableUserOpe();\r
3047         }\r
3048         return;\r
3049 }\r
3050 \r
3051 \r
3052 /*----- 属性変更ダイアログのコールバック --------------------------------------\r
3053 *\r
3054 *       Parameter\r
3055 *               HWND hDlg : ウインドウハンドル\r
3056 *               UINT message : メッセージ番号\r
3057 *               WPARAM wParam : メッセージの WPARAM 引数\r
3058 *               LPARAM lParam : メッセージの LPARAM 引数\r
3059 *\r
3060 *       Return Value\r
3061 *               BOOL TRUE/FALSE\r
3062 *----------------------------------------------------------------------------*/\r
3063 \r
3064 // 64ビット対応\r
3065 //BOOL CALLBACK ChmodDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
3066 INT_PTR CALLBACK ChmodDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
3067 {\r
3068         char Str[5];\r
3069         static char *Buf;\r
3070         int Tmp;\r
3071 \r
3072         switch (iMessage)\r
3073         {\r
3074                 case WM_INITDIALOG :\r
3075                         Buf = (char *)lParam;\r
3076                         SendDlgItemMessage(hDlg, PERM_NOW, EM_LIMITTEXT, 4, 0);\r
3077                         SendDlgItemMessage(hDlg, PERM_NOW, WM_SETTEXT, 0, (LPARAM)Buf);\r
3078                         SetAttrToDialog(hDlg, xtoi(Buf));\r
3079                         return(TRUE);\r
3080 \r
3081                 case WM_COMMAND :\r
3082                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
3083                         {\r
3084                                 case IDOK :\r
3085                                         SendDlgItemMessage(hDlg, PERM_NOW, WM_GETTEXT, 5, (LPARAM)Buf);\r
3086                                         EndDialog(hDlg, YES);\r
3087                                         break;\r
3088 \r
3089                                 case IDCANCEL :\r
3090                                         EndDialog(hDlg, NO);\r
3091                                         break;\r
3092 \r
3093                                 case PERM_O_READ :\r
3094                                 case PERM_O_WRITE :\r
3095                                 case PERM_O_EXEC :\r
3096                                 case PERM_G_READ :\r
3097                                 case PERM_G_WRITE :\r
3098                                 case PERM_G_EXEC :\r
3099                                 case PERM_A_READ :\r
3100                                 case PERM_A_WRITE :\r
3101                                 case PERM_A_EXEC :\r
3102                                         Tmp = GetAttrFromDialog(hDlg);\r
3103                                         sprintf(Str, "%03X", Tmp);\r
3104                                         SendDlgItemMessage(hDlg, PERM_NOW, WM_SETTEXT, 0, (LPARAM)Str);\r
3105                                         break;\r
3106 \r
3107                                 case IDHELP :\r
3108                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000017);\r
3109                                         break;\r
3110                         }\r
3111             return(TRUE);\r
3112         }\r
3113         return(FALSE);\r
3114 }\r
3115 \r
3116 \r
3117 /*----- 属性をダイアログボックスに設定 ----------------------------------------\r
3118 *\r
3119 *       Parameter\r
3120 *               HWND hWnd : ダイアログボックスのウインドウハンドル\r
3121 *               int Attr : 属性\r
3122 *\r
3123 *       Return Value\r
3124 *               なし\r
3125 *----------------------------------------------------------------------------*/\r
3126 \r
3127 static void SetAttrToDialog(HWND hDlg, int Attr)\r
3128 {\r
3129         if(Attr & 0x400)\r
3130                 SendDlgItemMessage(hDlg, PERM_O_READ, BM_SETCHECK, 1, 0);\r
3131         if(Attr & 0x200)\r
3132                 SendDlgItemMessage(hDlg, PERM_O_WRITE, BM_SETCHECK, 1, 0);\r
3133         if(Attr & 0x100)\r
3134                 SendDlgItemMessage(hDlg, PERM_O_EXEC, BM_SETCHECK, 1, 0);\r
3135 \r
3136         if(Attr & 0x40)\r
3137                 SendDlgItemMessage(hDlg, PERM_G_READ, BM_SETCHECK, 1, 0);\r
3138         if(Attr & 0x20)\r
3139                 SendDlgItemMessage(hDlg, PERM_G_WRITE, BM_SETCHECK, 1, 0);\r
3140         if(Attr & 0x10)\r
3141                 SendDlgItemMessage(hDlg, PERM_G_EXEC, BM_SETCHECK, 1, 0);\r
3142 \r
3143         if(Attr & 0x4)\r
3144                 SendDlgItemMessage(hDlg, PERM_A_READ, BM_SETCHECK, 1, 0);\r
3145         if(Attr & 0x2)\r
3146                 SendDlgItemMessage(hDlg, PERM_A_WRITE, BM_SETCHECK, 1, 0);\r
3147         if(Attr & 0x1)\r
3148                 SendDlgItemMessage(hDlg, PERM_A_EXEC, BM_SETCHECK, 1, 0);\r
3149 \r
3150         return;\r
3151 }\r
3152 \r
3153 \r
3154 /*----- ダイアログボックスの内容から属性を取得 --------------------------------\r
3155 *\r
3156 *       Parameter\r