OSDN Git Service

Fix bugs of corruption on resuming downloading files larger than 4GB.
[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         // デッドロック対策\r
1964         DisableUserOpe();\r
1965         Sts = YES;\r
1966         AskRemoteCurDir(CurDir, FMAX_PATH);\r
1967         FileListBase = NULL;\r
1968         if(GetFocus() == GetLocalHwnd())\r
1969         {\r
1970                 Win = WIN_LOCAL;\r
1971                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
1972         }\r
1973         else\r
1974         {\r
1975                 Win = WIN_REMOTE;\r
1976                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1977                         MakeSelectedFileList(Win, YES, NO, &FileListBase, &CancelFlg);\r
1978                 else\r
1979                         Sts = NO;\r
1980         }\r
1981 \r
1982         if(Sts == YES)\r
1983         {\r
1984                 // デッドロック対策\r
1985 //              DisableUserOpe();\r
1986 \r
1987                 DelFlg = NO;\r
1988                 Sts = NO;\r
1989                 Pos = FileListBase;\r
1990                 while(Pos != NULL)\r
1991                 {\r
1992                         if(Pos->Node == NODE_FILE)\r
1993                         {\r
1994                                 DelNotifyAndDo(Pos, Win, &Sts, &DelFlg, CurDir);\r
1995                                 if(Sts == NO_ALL)\r
1996                                         break;\r
1997                         }\r
1998                         Pos = Pos->Next;\r
1999                 }\r
2000 \r
2001                 if(Sts != NO_ALL)\r
2002                         DeleteAllDir(FileListBase, Win, &Sts, &DelFlg, CurDir);\r
2003 \r
2004                 if(Win == WIN_REMOTE)\r
2005                 {\r
2006                         AskRemoteCurDir(Tmp, FMAX_PATH);\r
2007                         if(strcmp(Tmp, CurDir) != 0)\r
2008                                 DoCWD(Tmp, NO, NO, NO);\r
2009                 }\r
2010 \r
2011                 DeleteFileList(&FileListBase);\r
2012 \r
2013                 if(DelFlg == YES)\r
2014                 {\r
2015                         if(Win == WIN_LOCAL)\r
2016                                 GetLocalDirForWnd();\r
2017                         else\r
2018                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2019                 }\r
2020 \r
2021                 // デッドロック対策\r
2022 //              EnableUserOpe();\r
2023         }\r
2024         // デッドロック対策\r
2025         EnableUserOpe();\r
2026         return;\r
2027 }\r
2028 \r
2029 \r
2030 /*----- サブディレクトリ以下を全て削除する ------------------------------------\r
2031 *\r
2032 *       Parameter\r
2033 *               FILELIST *Dt : 削除するファイルのリスト\r
2034 *               int Win : ウインドウ番号 (WIN_xxx)\r
2035 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2036 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2037 *               char *CurDir : カレントディレクトリ\r
2038 *\r
2039 *       Return Value\r
2040 *               なし\r
2041 *----------------------------------------------------------------------------*/\r
2042 \r
2043 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2044 {\r
2045         while(Dt != NULL)\r
2046         {\r
2047                 if(Dt->Node == NODE_DIR)\r
2048                 {\r
2049                         DeleteAllDir(Dt->Next, Win, Sw, Flg, CurDir);\r
2050                         if(*Sw == NO_ALL)\r
2051                                 break;\r
2052 \r
2053                         DelNotifyAndDo(Dt, Win, Sw, Flg, CurDir);\r
2054                         break;\r
2055                 }\r
2056                 Dt = Dt->Next;\r
2057         }\r
2058         return;\r
2059 }\r
2060 \r
2061 \r
2062 /*----- 削除するかどうかの確認と削除実行 --------------------------------------\r
2063 *\r
2064 *       Parameter\r
2065 *               FILELIST *Dt : 削除するファイルのリスト\r
2066 *               int Win : ウインドウ番号 (WIN_xxx)\r
2067 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2068 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2069 *               char *CurDir : カレントディレクトリ\r
2070 *\r
2071 *       Return Value\r
2072 *               なし\r
2073 *----------------------------------------------------------------------------*/\r
2074 \r
2075 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2076 {\r
2077         char Path[FMAX_PATH+1];\r
2078 \r
2079         if(Win == WIN_LOCAL)\r
2080         {\r
2081                 AskLocalCurDir(Path, FMAX_PATH);\r
2082                 SetYenTail(Path);\r
2083                 strcat(Path, Dt->File);\r
2084                 ReplaceAll(Path, '/', '\\');\r
2085         }\r
2086         else\r
2087         {\r
2088                 AskRemoteCurDir(Path, FMAX_PATH);\r
2089                 SetSlashTail(Path);\r
2090                 strcat(Path, Dt->File);\r
2091                 ReplaceAll(Path, '\\', '/');\r
2092         }\r
2093 \r
2094         if(*Sw != YES_ALL)\r
2095         {\r
2096                 sprintf(TmpString, "%s", Path);\r
2097 \r
2098                 if(AskHostType() == HTYPE_VMS)\r
2099                         ReformToVMSstylePathName(TmpString);\r
2100 \r
2101                 CurWin = Win;\r
2102                 *Sw = DialogBox(GetFtpInst(), MAKEINTRESOURCE(delete_dlg), GetMainHwnd(), DeleteDialogCallBack);\r
2103         }\r
2104 \r
2105         if((*Sw == YES) || (*Sw == YES_ALL))\r
2106         {\r
2107                 if(Win == WIN_LOCAL)\r
2108                 {\r
2109                         if(Dt->Node == NODE_FILE)\r
2110                                 DoLocalDELE(Path);\r
2111                         else\r
2112                                 DoLocalRMD(Path);\r
2113                         *Flg = YES;\r
2114                 }\r
2115                 else\r
2116                 {\r
2117                         /* フルパスを使わない時のための処理 */\r
2118                         if(ProcForNonFullpath(Path, CurDir, GetMainHwnd(), 0) == FFFTP_FAIL)\r
2119                                 *Sw = NO_ALL;\r
2120 \r
2121                         if(*Sw != NO_ALL)\r
2122                         {\r
2123                                 if(Dt->Node == NODE_FILE)\r
2124                                         DoDELE(Path);\r
2125                                 else\r
2126                                         DoRMD(Path);\r
2127                                 *Flg = YES;\r
2128                         }\r
2129                 }\r
2130         }\r
2131         return;\r
2132 }\r
2133 \r
2134 \r
2135 /*----- ファイル削除ダイアログのコールバック ----------------------------------\r
2136 *\r
2137 *       Parameter\r
2138 *               HWND hDlg : ウインドウハンドル\r
2139 *               UINT message : メッセージ番号\r
2140 *               WPARAM wParam : メッセージの WPARAM 引数\r
2141 *               LPARAM lParam : メッセージの LPARAM 引数\r
2142 *\r
2143 *       Return Value\r
2144 *               BOOL TRUE/FALSE\r
2145 *----------------------------------------------------------------------------*/\r
2146 \r
2147 static BOOL CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2148 {\r
2149         switch (iMessage)\r
2150         {\r
2151                 case WM_INITDIALOG :\r
2152                         if(CurWin == WIN_LOCAL)\r
2153                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN066);\r
2154                         else\r
2155                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN067);\r
2156                         SendDlgItemMessage(hDlg, DELETE_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2157                         return(TRUE);\r
2158 \r
2159                 case WM_COMMAND :\r
2160                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2161                         {\r
2162                                 case IDOK :\r
2163                                         EndDialog(hDlg, YES);\r
2164                                         break;\r
2165 \r
2166                                 case DELETE_NO :\r
2167                                         EndDialog(hDlg, NO);\r
2168                                         break;\r
2169 \r
2170                                 case DELETE_ALL :\r
2171                                         EndDialog(hDlg, YES_ALL);\r
2172                                         break;\r
2173 \r
2174                                 case IDCANCEL :\r
2175                                         EndDialog(hDlg, NO_ALL);\r
2176                                         break;\r
2177                         }\r
2178             return(TRUE);\r
2179         }\r
2180         return(FALSE);\r
2181 }\r
2182 \r
2183 \r
2184 /*----- ファイル一覧で指定されたファイルの名前を変更する ----------------------\r
2185 *\r
2186 *       Parameter\r
2187 *               なし\r
2188 *\r
2189 *       Return Value\r
2190 *               なし\r
2191 *----------------------------------------------------------------------------*/\r
2192 \r
2193 void RenameProc(void)\r
2194 {\r
2195         int Win;\r
2196         FILELIST *FileListBase;\r
2197         FILELIST *Pos;\r
2198         char New[FMAX_PATH+1];\r
2199         int RenFlg;\r
2200         int Sts;\r
2201 \r
2202         Sts = FFFTP_SUCCESS;\r
2203         if(GetFocus() == GetLocalHwnd())\r
2204                 Win = WIN_LOCAL;\r
2205         else\r
2206         {\r
2207                 Win = WIN_REMOTE;\r
2208                 Sts = CheckClosedAndReconnect();\r
2209         }\r
2210 \r
2211         if(Sts == FFFTP_SUCCESS)\r
2212         {\r
2213                 DisableUserOpe();\r
2214 \r
2215                 FileListBase = NULL;\r
2216                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2217 \r
2218                 RenFlg = NO;\r
2219                 Sts = NO;\r
2220                 Pos = FileListBase;\r
2221                 while(Pos != NULL)\r
2222                 {\r
2223                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2224                         {\r
2225                                 strcpy(TmpString, Pos->File);\r
2226                                 CurWin = Win;\r
2227                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2228 \r
2229                                 if(Sts == NO_ALL)\r
2230                                         break;\r
2231 \r
2232                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2233                                 {\r
2234                                         strcpy(New, TmpString);\r
2235                                         if(Win == WIN_LOCAL)\r
2236                                                 DoLocalRENAME(Pos->File, New);\r
2237                                         else\r
2238                                                 DoRENAME(Pos->File, New);\r
2239                                         RenFlg = YES;\r
2240                                 }\r
2241                         }\r
2242                         Pos = Pos->Next;\r
2243                 }\r
2244                 DeleteFileList(&FileListBase);\r
2245 \r
2246                 if(RenFlg == YES)\r
2247                 {\r
2248                         if(Win == WIN_LOCAL)\r
2249                                 GetLocalDirForWnd();\r
2250                         else\r
2251                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2252                 }\r
2253 \r
2254                 EnableUserOpe();\r
2255         }\r
2256         return;\r
2257 }\r
2258 \r
2259 \r
2260 //\r
2261 // リモート側でのファイルの移動(リネーム)を行う\r
2262 //  \r
2263 // RenameProc()をベースに改造。(2007.9.5 yutaka)\r
2264 //\r
2265 void MoveRemoteFileProc(int drop_index)\r
2266 {\r
2267         int Win;\r
2268         FILELIST *FileListBase;\r
2269         FILELIST *Pos;\r
2270         FILELIST Pkt;\r
2271         char New[FMAX_PATH+1];\r
2272         char Old[FMAX_PATH+1];\r
2273         char HostDir[FMAX_PATH+1];\r
2274         int RenFlg;\r
2275         int Sts;\r
2276 \r
2277         if(MoveMode == MOVE_DISABLE)\r
2278         {\r
2279                 return;\r
2280         }\r
2281 \r
2282         AskRemoteCurDir(HostDir, FMAX_PATH);\r
2283 \r
2284         // ドロップ先のフォルダ名を得る\r
2285         GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH);\r
2286 \r
2287         if(MoveMode == MOVE_DLG)\r
2288         {\r
2289                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(move_notify_dlg), GetRemoteHwnd(), ExeEscTextDialogProc, (LPARAM)Pkt.File) == NO)\r
2290                 {\r
2291                         return;\r
2292                 }\r
2293         }\r
2294 \r
2295         Sts = FFFTP_SUCCESS;\r
2296 #if 0\r
2297         if(GetFocus() == GetLocalHwnd())\r
2298                 Win = WIN_LOCAL;\r
2299         else\r
2300         {\r
2301                 Win = WIN_REMOTE;\r
2302                 Sts = CheckClosedAndReconnect();\r
2303         }\r
2304 #else\r
2305                 Win = WIN_REMOTE;\r
2306                 Sts = CheckClosedAndReconnect();\r
2307 #endif\r
2308 \r
2309         if(Sts == FFFTP_SUCCESS)\r
2310         {\r
2311                 DisableUserOpe();\r
2312 \r
2313                 FileListBase = NULL;\r
2314                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2315 \r
2316                 RenFlg = NO;\r
2317                 Sts = NO;\r
2318                 Pos = FileListBase;\r
2319                 while(Pos != NULL)\r
2320                 {\r
2321                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2322                         {\r
2323                                 strcpy(TmpString, Pos->File);\r
2324                                 CurWin = Win;\r
2325 #if 0\r
2326                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2327 \r
2328                                 if(Sts == NO_ALL)\r
2329                                         break;\r
2330 #else\r
2331                                 Sts = YES;\r
2332 #endif\r
2333 \r
2334                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2335                                 {\r
2336                                         // パスの設定(local)\r
2337                                         strncpy_s(Old, sizeof(Old), HostDir, _TRUNCATE);\r
2338                                         strncat_s(Old, sizeof(Old), "/", _TRUNCATE);\r
2339                                         strncat_s(Old, sizeof(Old), Pos->File, _TRUNCATE);\r
2340 \r
2341                                         // パスの設定(remote)\r
2342                                         strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2343                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2344                                         strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2345                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2346                                         strncat_s(New, sizeof(New), Pos->File, _TRUNCATE);\r
2347 \r
2348                                         if(Win == WIN_LOCAL)\r
2349                                                 DoLocalRENAME(Old, New);\r
2350                                         else\r
2351                                                 DoRENAME(Old, New);\r
2352                                         RenFlg = YES;\r
2353                                 }\r
2354                         }\r
2355                         Pos = Pos->Next;\r
2356                 }\r
2357                 DeleteFileList(&FileListBase);\r
2358 \r
2359                 if(RenFlg == YES)\r
2360                 {\r
2361                         if(Win == WIN_LOCAL) {\r
2362                                 GetLocalDirForWnd();\r
2363                         } else {\r
2364                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2365 \r
2366                                 strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2367                                 strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2368                                 strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2369                                 DoCWD(New, YES, YES, YES);\r
2370                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2371                         }\r
2372                 }\r
2373 \r
2374                 EnableUserOpe();\r
2375         }\r
2376         return;\r
2377 }\r
2378 \r
2379 \r
2380 \r
2381 /*----- 新ファイル名入力ダイアログのコールバック ------------------------------\r
2382 *\r
2383 *       Parameter\r
2384 *               HWND hDlg : ウインドウハンドル\r
2385 *               UINT message : メッセージ番号\r
2386 *               WPARAM wParam : メッセージの WPARAM 引数\r
2387 *               LPARAM lParam : メッセージの LPARAM 引数\r
2388 *\r
2389 *       Return Value\r
2390 *               BOOL TRUE/FALSE\r
2391 *----------------------------------------------------------------------------*/\r
2392 \r
2393 static BOOL CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2394 {\r
2395         switch (iMessage)\r
2396         {\r
2397                 case WM_INITDIALOG :\r
2398                         if(CurWin == WIN_LOCAL)\r
2399                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN068);\r
2400                         else\r
2401                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN069);\r
2402                         SendDlgItemMessage(hDlg, RENAME_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2403                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2404                         SendDlgItemMessage(hDlg, RENAME_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2405                         return(TRUE);\r
2406 \r
2407                 case WM_COMMAND :\r
2408                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2409                         {\r
2410                                 case IDOK :\r
2411                                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2412                                         EndDialog(hDlg, YES);\r
2413                                         break;\r
2414 \r
2415                                 case IDCANCEL :\r
2416                                         EndDialog(hDlg, NO);\r
2417                                         break;\r
2418 \r
2419                                 case RENAME_STOP :\r
2420                                         EndDialog(hDlg, NO_ALL);\r
2421                                         break;\r
2422                         }\r
2423             return(TRUE);\r
2424         }\r
2425         return(FALSE);\r
2426 }\r
2427 \r
2428 \r
2429 /*----- 新しいディレクトリを作成する ------------------------------------------\r
2430 *\r
2431 *       Parameter\r
2432 *               なし\r
2433 *\r
2434 *       Return Value\r
2435 *               なし\r
2436 *----------------------------------------------------------------------------*/\r
2437 \r
2438 void MkdirProc(void)\r
2439 {\r
2440         int Sts;\r
2441         int Win;\r
2442         char Path[FMAX_PATH+1];\r
2443         char *Title;\r
2444         int Tmp;\r
2445 \r
2446         if(GetFocus() == GetLocalHwnd())\r
2447         {\r
2448                 Win = WIN_LOCAL;\r
2449                 Title = MSGJPN070;\r
2450         }\r
2451         else\r
2452         {\r
2453                 Win = WIN_REMOTE;\r
2454                 Title = MSGJPN071;\r
2455         }\r
2456 \r
2457         strcpy(Path, "");\r
2458         Sts = InputDialogBox(mkdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2459 \r
2460         if((Sts == YES) && (strlen(Path) != 0))\r
2461         {\r
2462                 if(Win == WIN_LOCAL)\r
2463                 {\r
2464                         DisableUserOpe();\r
2465                         DoLocalMKD(Path);\r
2466                         GetLocalDirForWnd();\r
2467                         EnableUserOpe();\r
2468                 }\r
2469                 else\r
2470                 {\r
2471                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2472                         {\r
2473                                 DisableUserOpe();\r
2474                                 DoMKD(Path);\r
2475                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2476                                 EnableUserOpe();\r
2477                         }\r
2478                 }\r
2479         }\r
2480         return;\r
2481 }\r
2482 \r
2483 \r
2484 /*----- ヒストリリストを使ったディレクトリの移動 ------------------------------\r
2485 *\r
2486 *       Parameter\r
2487 *               HWND hWnd : コンボボックスのウインドウハンドル\r
2488 *\r
2489 *       Return Value\r
2490 *               なし\r
2491 *----------------------------------------------------------------------------*/\r
2492 \r
2493 void ChangeDirComboProc(HWND hWnd)\r
2494 {\r
2495         char Tmp[FMAX_PATH+1];\r
2496         int i;\r
2497 \r
2498         if((i = SendMessage(hWnd, CB_GETCURSEL, 0, 0)) != CB_ERR)\r
2499         {\r
2500                 SendMessage(hWnd, CB_GETLBTEXT, i, (LPARAM)Tmp);\r
2501 \r
2502                 if(hWnd == GetLocalHistHwnd())\r
2503                 {\r
2504                         DisableUserOpe();\r
2505                         DoLocalCWD(Tmp);\r
2506                         GetLocalDirForWnd();\r
2507                         EnableUserOpe();\r
2508                 }\r
2509                 else\r
2510                 {\r
2511                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2512                         {\r
2513                                 DisableUserOpe();\r
2514                                 if(DoCWD(Tmp, YES, NO, YES) < FTP_RETRY)\r
2515                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2516                                 EnableUserOpe();\r
2517                         }\r
2518                 }\r
2519         }\r
2520         return;\r
2521 }\r
2522 \r
2523 \r
2524 /*----- ブックマークを使ったディレクトリの移動 --------------------------------\r
2525 *\r
2526 *       Parameter\r
2527 *               int MarkID : ブックマークのメニューID\r
2528 *\r
2529 *       Return Value\r
2530 *               なし\r
2531 *----------------------------------------------------------------------------*/\r
2532 \r
2533 void ChangeDirBmarkProc(int MarkID)\r
2534 {\r
2535         char Local[FMAX_PATH+1];\r
2536         char Remote[FMAX_PATH+1];\r
2537         int Sts;\r
2538 \r
2539         Sts = AskBookMarkText(MarkID, Local, Remote, FMAX_PATH+1);\r
2540         if((Sts == BMARK_TYPE_LOCAL) || (Sts == BMARK_TYPE_BOTH))\r
2541         {\r
2542                 DisableUserOpe();\r
2543                 if(DoLocalCWD(Local) == FFFTP_SUCCESS)\r
2544                         GetLocalDirForWnd();\r
2545                 EnableUserOpe();\r
2546         }\r
2547 \r
2548         if((Sts == BMARK_TYPE_REMOTE) || (Sts == BMARK_TYPE_BOTH))\r
2549         {\r
2550                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2551                 {\r
2552                         DisableUserOpe();\r
2553                         if(DoCWD(Remote, YES, NO, YES) < FTP_RETRY)\r
2554                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2555                         EnableUserOpe();\r
2556                 }\r
2557         }\r
2558         return;\r
2559 }\r
2560 \r
2561 \r
2562 /*----- ディレクトリ名を入力してディレクトリの移動 ----------------------------\r
2563 *\r
2564 *       Parameter\r
2565 *               int Win : ウインドウ番号 (WIN_xxx)\r
2566 *\r
2567 *       Return Value\r
2568 *               なし\r
2569 *----------------------------------------------------------------------------*/\r
2570 \r
2571 void ChangeDirDirectProc(int Win)\r
2572 {\r
2573         int Sts;\r
2574         char Path[FMAX_PATH+1];\r
2575         char *Title;\r
2576         int Tmp;\r
2577 \r
2578         if(Win == WIN_LOCAL)\r
2579                 Title = MSGJPN072;\r
2580         else\r
2581                 Title = MSGJPN073;\r
2582 \r
2583         strcpy(Path, "");\r
2584         if(Win == WIN_LOCAL)\r
2585                 Sts = InputDialogBox(chdir_br_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2586         else\r
2587                 Sts = InputDialogBox(chdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2588 \r
2589         if((Sts == YES) && (strlen(Path) != 0))\r
2590         {\r
2591                 if(Win == WIN_LOCAL)\r
2592                 {\r
2593                         DisableUserOpe();\r
2594                         DoLocalCWD(Path);\r
2595                         GetLocalDirForWnd();\r
2596                         EnableUserOpe();\r
2597                 }\r
2598                 else\r
2599                 {\r
2600                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2601                         {\r
2602                                 DisableUserOpe();\r
2603                                 if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2604                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2605                                 EnableUserOpe();\r
2606                         }\r
2607                 }\r
2608         }\r
2609         return;\r
2610 }\r
2611 \r
2612 \r
2613 /*----- Dropされたファイルによるディレクトリの移動 ----------------------------\r
2614 *\r
2615 *       Parameter\r
2616 *               WPARAM wParam : ドロップされたファイルの情報\r
2617 *\r
2618 *       Return Value\r
2619 *               なし\r
2620 *----------------------------------------------------------------------------*/\r
2621 \r
2622 void ChangeDirDropFileProc(WPARAM wParam)\r
2623 {\r
2624         char Path[FMAX_PATH+1];\r
2625 \r
2626         DisableUserOpe();\r
2627         MakeDroppedDir(wParam, Path);\r
2628         DoLocalCWD(Path);\r
2629         GetLocalDirForWnd();\r
2630         EnableUserOpe();\r
2631         return;\r
2632 }\r
2633 \r
2634 \r
2635 /*----- ファイルの属性変更 ----------------------------------------------------\r
2636 *\r
2637 *       Parameter\r
2638 *               なし\r
2639 *\r
2640 *       Return Value\r
2641 *               なし\r
2642 *----------------------------------------------------------------------------*/\r
2643 \r
2644 void ChmodProc(void)\r
2645 {\r
2646         int ChmodFlg;\r
2647         FILELIST *FileListBase;\r
2648         FILELIST *Pos;\r
2649         char Tmp[5];\r
2650         char *Buf;\r
2651         char *BufTmp;\r
2652         int BufLen;\r
2653 \r
2654         if(GetFocus() == GetRemoteHwnd())\r
2655         {\r
2656                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2657                 {\r
2658                         DisableUserOpe();\r
2659                         FileListBase = NULL;\r
2660                         MakeSelectedFileList(WIN_REMOTE, NO, NO, &FileListBase, &CancelFlg);\r
2661                         if(FileListBase != NULL)\r
2662                         {\r
2663                                 sprintf(Tmp, "%03X", FileListBase->Attr);\r
2664                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(chmod_dlg), GetMainHwnd(), ChmodDialogCallBack, (LPARAM)Tmp) == YES)\r
2665                                 {\r
2666                                         ChmodFlg = NO;\r
2667                                         Pos = FileListBase;\r
2668                                         while(Pos != NULL)\r
2669                                         {\r
2670                                                 if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2671                                                 {\r
2672                                                         DoCHMOD(Pos->File, Tmp);\r
2673                                                         ChmodFlg = YES;\r
2674                                                 }\r
2675                                                 Pos = Pos->Next;\r
2676                                         }\r
2677                                         if(ChmodFlg == YES)\r
2678                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2679                                 }\r
2680                         }\r
2681                         DeleteFileList(&FileListBase);\r
2682                         EnableUserOpe();\r
2683                 }\r
2684         }\r
2685         else if(GetFocus() == GetLocalHwnd())\r
2686         {\r
2687                 DisableUserOpe();\r
2688                 FileListBase = NULL;\r
2689                 MakeSelectedFileList(WIN_LOCAL, NO, NO, &FileListBase, &CancelFlg);\r
2690                 if(FileListBase != NULL)\r
2691                 {\r
2692                         if((Buf = malloc(1)) != NULL)\r
2693                         {\r
2694                                 *Buf = NUL;\r
2695                                 BufLen = 0;\r
2696                                 Pos = FileListBase;\r
2697                                 while(Pos != NULL)\r
2698                                 {\r
2699                                         if((BufTmp = realloc(Buf, BufLen + strlen(Pos->File) + 2)) != NULL)\r
2700                                         {\r
2701                                                 Buf = BufTmp;\r
2702                                                 strcpy(Buf+BufLen, Pos->File);\r
2703                                                 BufLen += strlen(Pos->File) + 1;\r
2704                                         }\r
2705                                         Pos = Pos->Next;\r
2706                                 }\r
2707 \r
2708                                 memset(Buf+BufLen, NUL, 1);\r
2709                                 DispFileProperty(Buf);\r
2710                                 free(Buf);\r
2711                         }\r
2712                 }\r
2713                 DeleteFileList(&FileListBase);\r
2714                 EnableUserOpe();\r
2715         }\r
2716         return;\r
2717 }\r
2718 \r
2719 \r
2720 /*----- 属性変更ダイアログのコールバック --------------------------------------\r
2721 *\r
2722 *       Parameter\r
2723 *               HWND hDlg : ウインドウハンドル\r
2724 *               UINT message : メッセージ番号\r
2725 *               WPARAM wParam : メッセージの WPARAM 引数\r
2726 *               LPARAM lParam : メッセージの LPARAM 引数\r
2727 *\r
2728 *       Return Value\r
2729 *               BOOL TRUE/FALSE\r
2730 *----------------------------------------------------------------------------*/\r
2731 \r
2732 BOOL CALLBACK ChmodDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2733 {\r
2734         char Str[5];\r
2735         static char *Buf;\r
2736         int Tmp;\r
2737 \r
2738         switch (iMessage)\r
2739         {\r
2740                 case WM_INITDIALOG :\r
2741                         Buf = (char *)lParam;\r
2742                         SendDlgItemMessage(hDlg, PERM_NOW, EM_LIMITTEXT, 4, 0);\r
2743                         SendDlgItemMessage(hDlg, PERM_NOW, WM_SETTEXT, 0, (LPARAM)Buf);\r
2744                         SetAttrToDialog(hDlg, xtoi(Buf));\r
2745                         return(TRUE);\r
2746 \r
2747                 case WM_COMMAND :\r
2748                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2749                         {\r
2750                                 case IDOK :\r
2751                                         SendDlgItemMessage(hDlg, PERM_NOW, WM_GETTEXT, 5, (LPARAM)Buf);\r
2752                                         EndDialog(hDlg, YES);\r
2753                                         break;\r
2754 \r
2755                                 case IDCANCEL :\r
2756                                         EndDialog(hDlg, NO);\r
2757                                         break;\r
2758 \r
2759                                 case PERM_O_READ :\r
2760                                 case PERM_O_WRITE :\r
2761                                 case PERM_O_EXEC :\r
2762                                 case PERM_G_READ :\r
2763                                 case PERM_G_WRITE :\r
2764                                 case PERM_G_EXEC :\r
2765                                 case PERM_A_READ :\r
2766                                 case PERM_A_WRITE :\r
2767                                 case PERM_A_EXEC :\r
2768                                         Tmp = GetAttrFromDialog(hDlg);\r
2769                                         sprintf(Str, "%03X", Tmp);\r
2770                                         SendDlgItemMessage(hDlg, PERM_NOW, WM_SETTEXT, 0, (LPARAM)Str);\r
2771                                         break;\r
2772 \r
2773                                 case IDHELP :\r
2774                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000017);\r
2775                                         break;\r
2776                         }\r
2777             return(TRUE);\r
2778         }\r
2779         return(FALSE);\r
2780 }\r
2781 \r
2782 \r
2783 /*----- 属性をダイアログボックスに設定 ----------------------------------------\r
2784 *\r
2785 *       Parameter\r
2786 *               HWND hWnd : ダイアログボックスのウインドウハンドル\r
2787 *               int Attr : 属