OSDN Git Service

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