OSDN Git Service

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