OSDN Git Service

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