X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=ftpproc.c;h=09f376ce1f91b4fb58ff25ea0204556e67068421;hb=cd2b1c2417291460739f120f1f97f08491ed1c61;hp=8963604069ce95c88409d04d778bc8d99005d5c0;hpb=39f0540ffea6b6efa919f16d0560442496af180d;p=ffftp%2Fffftp.git diff --git a/ftpproc.c b/ftpproc.c index 8963604..09f376c 100644 --- a/ftpproc.c +++ b/ftpproc.c @@ -71,7 +71,7 @@ static INT_PTR CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wP static INT_PTR CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam); static void CountMirrorFiles(HWND hDlg, TRANSPACKET *Pkt); static int AskMirrorNoTrn(char *Fname, int Mode); -static int AskUpLoadFileAttr(char *Fname); +static int AskUploadFileAttr(char *Fname); // 64ビット対応 //static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam); @@ -108,6 +108,8 @@ extern SIZE MirrorDlgSize; extern int VaxSemicolon; extern int DebugConsole; extern int CancelFlg; +// ディレクトリ自動作成 +extern int MakeAllDir; /*===== ローカルなワーク =====*/ @@ -136,11 +138,50 @@ static double FileSize; /* ファイル総容量 */ * なし *----------------------------------------------------------------------------*/ -void DownLoadProc(int ChName, int ForceFile, int All) +// ディレクトリ自動作成 +// ローカル側のパスから必要なフォルダを作成 +int MakeDirFromLocalPath(char* LocalFile, char* Old) +{ + TRANSPACKET Pkt; + char* pDelimiter; + char* pNext; + char* Cat; + int Len; + int Make; + pDelimiter = LocalFile; + Make = NO; + while(pNext = strchr(pDelimiter, '\\')) + { + Len = pNext - LocalFile; + strncpy(Pkt.LocalFile, LocalFile, Len); + Pkt.LocalFile[Len] = '\0'; + if(strncmp(LocalFile, Old, Len + 1) != 0) + { + Cat = Pkt.LocalFile + (pDelimiter - LocalFile); + if(FnameCnv == FNAME_LOWER) + _mbslwr(Cat); + else if(FnameCnv == FNAME_UPPER) + _mbsupr(Cat); + ReplaceAll(Pkt.LocalFile, '/', '\\'); + + strcpy(Pkt.Cmd, "MKD "); + strcpy(Pkt.RemoteFile, ""); + AddTransFileList(&Pkt); + + Make = YES; + } + pDelimiter = pNext + 1; + } + return Make; +} + +void DownloadProc(int ChName, int ForceFile, int All) { FILELIST *FileListBase; FILELIST *Pos; TRANSPACKET Pkt; + // ディレクトリ自動作成 + char Tmp[FMAX_PATH+1]; // 同時接続対応 CancelFlg = NO; @@ -244,11 +285,19 @@ void DownLoadProc(int ChName, int ForceFile, int All) Pkt.KanjiCodeDesired = AskLocalKanjiCode(); Pkt.KanaCnv = AskHostKanaCnv(); + // ディレクトリ自動作成 + strcpy(Tmp, Pkt.LocalFile); Pkt.Mode = CheckLocalFile(&Pkt); /* Pkt.ExistSize がセットされる */ if(Pkt.Mode == EXIST_ABORT) break; else if(Pkt.Mode != EXIST_IGNORE) + // ディレクトリ自動作成 +// AddTransFileList(&Pkt); + { + if(MakeAllDir == YES) + MakeDirFromLocalPath(Pkt.LocalFile, Tmp); AddTransFileList(&Pkt); + } } Pos = Pos->Next; } @@ -261,8 +310,12 @@ void DownLoadProc(int ChName, int ForceFile, int All) } DeleteFileList(&FileListBase); - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); + + // バグ対策 + AddNullTransFileList(); GoForwardTransWindow(); // KeepTransferDialog(NO); @@ -282,9 +335,11 @@ void DownLoadProc(int ChName, int ForceFile, int All) * なし *----------------------------------------------------------------------------*/ -void DirectDownLoadProc(char *Fname) +void DirectDownloadProc(char *Fname) { TRANSPACKET Pkt; + // ディレクトリ自動作成 + char Tmp[FMAX_PATH+1]; // 同時接続対応 CancelFlg = NO; @@ -350,9 +405,17 @@ void DirectDownLoadProc(char *Fname) Pkt.KanjiCodeDesired = AskLocalKanjiCode(); Pkt.KanaCnv = AskHostKanaCnv(); + // ディレクトリ自動作成 + strcpy(Tmp, Pkt.LocalFile); Pkt.Mode = CheckLocalFile(&Pkt); /* Pkt.ExistSize がセットされる */ if((Pkt.Mode != EXIST_ABORT) && (Pkt.Mode != EXIST_IGNORE)) + // ディレクトリ自動作成 +// AddTransFileList(&Pkt); + { + if(MakeAllDir == YES) + MakeDirFromLocalPath(Pkt.LocalFile, Tmp); AddTransFileList(&Pkt); + } } } @@ -363,8 +426,12 @@ void DirectDownLoadProc(char *Fname) AddTransFileList(&Pkt); } - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); + + // バグ対策 + AddNullTransFileList(); GoForwardTransWindow(); // KeepTransferDialog(NO); @@ -384,7 +451,7 @@ void DirectDownLoadProc(char *Fname) * なし *----------------------------------------------------------------------------*/ -void InputDownLoadProc(void) +void InputDownloadProc(void) { char Path[FMAX_PATH+1]; int Tmp; @@ -394,7 +461,7 @@ void InputDownLoadProc(void) strcpy(Path, ""); if(InputDialogBox(downname_dlg, GetMainHwnd(), NULL, Path, FMAX_PATH, &Tmp, IDH_HELP_TOPIC_0000001) == YES) { - DirectDownLoadProc(Path); + DirectDownloadProc(Path); } // EnableUserOpe(); @@ -629,12 +696,16 @@ void MirrorDownloadProc(int Notify) AddTransFileList(&Pkt); } - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); } else EraseTmpTransFileList(&Base); + // バグ対策 + AddNullTransFileList(); + DeleteFileList(&LocalListBase); DeleteFileList(&RemoteListBase); @@ -801,6 +872,14 @@ static int CheckLocalFile(TRANSPACKET *Pkt) else Ret = EXIST_IGNORE; } + // 同じ名前のファイルの処理方法追加 + if(Ret == EXIST_LARGE) + { + if(MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow) < Pkt->Size) + Ret = EXIST_OVW; + else + Ret = EXIST_IGNORE; + } } } return(Ret); @@ -824,11 +903,19 @@ static int CheckLocalFile(TRANSPACKET *Pkt) static INT_PTR CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) { static TRANSPACKET *Pkt; + // 同じ名前のファイルの処理方法追加 +// static const RADIOBUTTON DownExistButton[] = { +// { DOWN_EXIST_OVW, EXIST_OVW }, +// { DOWN_EXIST_NEW, EXIST_NEW }, +// { DOWN_EXIST_RESUME, EXIST_RESUME }, +// { DOWN_EXIST_IGNORE, EXIST_IGNORE } +// }; static const RADIOBUTTON DownExistButton[] = { { DOWN_EXIST_OVW, EXIST_OVW }, { DOWN_EXIST_NEW, EXIST_NEW }, { DOWN_EXIST_RESUME, EXIST_RESUME }, - { DOWN_EXIST_IGNORE, EXIST_IGNORE } + { DOWN_EXIST_IGNORE, EXIST_IGNORE }, + { DOWN_EXIST_LARGE, EXIST_LARGE } }; #define DOWNEXISTBUTTONS (sizeof(DownExistButton)/sizeof(RADIOBUTTON)) @@ -887,7 +974,70 @@ static INT_PTR CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM * なし *----------------------------------------------------------------------------*/ -void UpLoadListProc(int ChName, int All) +// ディレクトリ自動作成 +// リモート側のパスから必要なディレクトリを作成 +int MakeDirFromRemotePath(char* RemoteFile, char* Old, int FirstAdd) +{ + TRANSPACKET Pkt; + TRANSPACKET Pkt1; + char* pDelimiter; + char* pNext; + char* Cat; + int Len; + int Make; + pDelimiter = RemoteFile; + Make = NO; + while(pNext = strchr(pDelimiter, '/')) + { + Len = pNext - RemoteFile; + strncpy(Pkt.RemoteFile, RemoteFile, Len); + Pkt.RemoteFile[Len] = '\0'; + if(strncmp(RemoteFile, Old, Len + 1) != 0) + { + Cat = Pkt.RemoteFile + (pDelimiter - RemoteFile); + if(FnameCnv == FNAME_LOWER) + _mbslwr(Cat); + else if(FnameCnv == FNAME_UPPER) + _mbsupr(Cat); +#if defined(HAVE_TANDEM) + Pkt.FileCode = 0; + Pkt.PriExt = DEF_PRIEXT; + Pkt.SecExt = DEF_SECEXT; + Pkt.MaxExt = DEF_MAXEXT; +#endif + ReplaceAll(Pkt.RemoteFile, '\\', '/'); + + if(AskHostType() == HTYPE_ACOS) + { + strcpy(Pkt.RemoteFile, "'"); + strcat(Pkt.RemoteFile, AskHostLsName()); + strcat(Pkt.RemoteFile, "("); + strcat(Pkt.RemoteFile, Cat); + strcat(Pkt.RemoteFile, ")"); + strcat(Pkt.RemoteFile, "'"); + } + else if(AskHostType() == HTYPE_ACOS_4) + strcpy(Pkt.RemoteFile, Cat); + + if((FirstAdd == YES) && (AskNoFullPathMode() == YES)) + { + strcpy(Pkt1.Cmd, "SETCUR"); + AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH); + AddTransFileList(&Pkt1); + } + FirstAdd = NO; + strcpy(Pkt.Cmd, "MKD "); + strcpy(Pkt.LocalFile, ""); + AddTransFileList(&Pkt); + + Make = YES; + } + pDelimiter = pNext + 1; + } + return Make; +} + +void UploadListProc(int ChName, int All) { FILELIST *FileListBase; FILELIST *Pos; @@ -958,6 +1108,16 @@ void UpLoadListProc(int ChName, int All) else break; } + // バグ修正 + AskRemoteCurDir(Tmp, FMAX_PATH); + SetSlashTail(Tmp); + if(strncmp(Pkt.RemoteFile, Tmp, strlen(Tmp)) != 0) + { + if((Cat = strrchr(Pkt.RemoteFile, '/')) != NULL) + Cat++; + else + Cat = Pkt.RemoteFile; + } ReplaceAll(Pkt.RemoteFile, '\\', '/'); if(AskHostType() == HTYPE_ACOS) @@ -1014,9 +1174,11 @@ void UpLoadListProc(int ChName, int All) strcpy(Pkt.Cmd, "STOR "); Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType()); - Pkt.Size = 0; + // バグ修正 +// Pkt.Size = 0; + Pkt.Size = Pos->Size; Pkt.Time = Pos->Time; - Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); + Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile); Pkt.KanjiCode = AskHostKanjiCode(); // UTF-8対応 Pkt.KanjiCodeDesired = AskLocalKanjiCode(); @@ -1026,11 +1188,19 @@ void UpLoadListProc(int ChName, int All) CalcExtentSize(&Pkt, Pos->Size); } #endif + // ディレクトリ自動作成 + strcpy(Tmp, Pkt.RemoteFile); Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList); if(Pkt.Mode == EXIST_ABORT) break; else if(Pkt.Mode != EXIST_IGNORE) { + // ディレクトリ自動作成 + if(MakeAllDir == YES) + { + if(MakeDirFromRemotePath(Pkt.RemoteFile, Tmp, FirstAdd) == YES) + FirstAdd = NO; + } if((FirstAdd == YES) && (AskNoFullPathMode() == YES)) { strcpy(Pkt1.Cmd, "SETCUR"); @@ -1056,8 +1226,12 @@ void UpLoadListProc(int ChName, int All) DeleteFileList(&FileListBase); - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); + + // バグ対策 + AddNullTransFileList(); GoForwardTransWindow(); @@ -1076,7 +1250,7 @@ void UpLoadListProc(int ChName, int All) * なし *----------------------------------------------------------------------------*/ -void UpLoadDragProc(WPARAM wParam) +void UploadDragProc(WPARAM wParam) { FILELIST *FileListBase; FILELIST *Pos; @@ -1180,9 +1354,11 @@ void UpLoadDragProc(WPARAM wParam) strcpy(Pkt.Cmd, "STOR "); Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType()); - Pkt.Size = 0; + // バグ修正 +// Pkt.Size = 0; + Pkt.Size = Pos->Size; Pkt.Time = Pos->Time; - Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); + Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile); Pkt.KanjiCode = AskHostKanjiCode(); // UTF-8対応 Pkt.KanjiCodeDesired = AskLocalKanjiCode(); @@ -1193,11 +1369,19 @@ void UpLoadDragProc(WPARAM wParam) CalcExtentSize(&Pkt, Pos->Size); } #endif + // ディレクトリ自動作成 + strcpy(Tmp, Pkt.RemoteFile); Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList); if(Pkt.Mode == EXIST_ABORT) break; else if(Pkt.Mode != EXIST_IGNORE) { + // ディレクトリ自動作成 + if(MakeAllDir == YES) + { + if(MakeDirFromRemotePath(Pkt.RemoteFile, Tmp, FirstAdd) == YES) + FirstAdd = NO; + } if((FirstAdd == YES) && (AskNoFullPathMode() == YES)) { strcpy(Pkt1.Cmd, "SETCUR"); @@ -1223,8 +1407,12 @@ void UpLoadDragProc(WPARAM wParam) DeleteFileList(&FileListBase); - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); + + // バグ対策 + AddNullTransFileList(); GoForwardTransWindow(); @@ -1457,9 +1645,11 @@ void MirrorUploadProc(int Notify) strcpy(Pkt.Cmd, "STOR "); Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType()); - Pkt.Size = 0; + // バグ修正 +// Pkt.Size = 0; + Pkt.Size = LocalPos->Size; Pkt.Time = LocalPos->Time; - Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); + Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile); Pkt.KanjiCode = AskHostKanjiCode(); // UTF-8対応 Pkt.KanjiCodeDesired = AskLocalKanjiCode(); @@ -1494,12 +1684,16 @@ void MirrorUploadProc(int Notify) AddTransFileList(&Pkt); } - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); } else EraseTmpTransFileList(&Base); + // バグ対策 + AddNullTransFileList(); + DeleteFileList(&LocalListBase); DeleteFileList(&RemoteListBase); @@ -1831,7 +2025,7 @@ static int AskMirrorNoTrn(char *Fname, int Mode) * int 属性 (-1=設定なし) *----------------------------------------------------------------------------*/ -static int AskUpLoadFileAttr(char *Fname) +static int AskUploadFileAttr(char *Fname) { int Ret; int Sts; @@ -1915,6 +2109,14 @@ static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList) else Ret = EXIST_IGNORE; } + // 同じ名前のファイルの処理方法追加 + if(Ret == EXIST_LARGE) + { + if(Exist->Size < Pkt->Size) + Ret = EXIST_OVW; + else + Ret = EXIST_IGNORE; + } } } return(Ret); @@ -1938,12 +2140,21 @@ static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList) static INT_PTR CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) { static TRANSPACKET *Pkt; + // 同じ名前のファイルの処理方法追加 +// static const RADIOBUTTON UpExistButton[] = { +// { UP_EXIST_OVW, EXIST_OVW }, +// { UP_EXIST_NEW, EXIST_NEW }, +// { UP_EXIST_RESUME, EXIST_RESUME }, +// { UP_EXIST_UNIQUE, EXIST_UNIQUE }, +// { UP_EXIST_IGNORE, EXIST_IGNORE } +// }; static const RADIOBUTTON UpExistButton[] = { { UP_EXIST_OVW, EXIST_OVW }, { UP_EXIST_NEW, EXIST_NEW }, { UP_EXIST_RESUME, EXIST_RESUME }, { UP_EXIST_UNIQUE, EXIST_UNIQUE }, - { UP_EXIST_IGNORE, EXIST_IGNORE } + { UP_EXIST_IGNORE, EXIST_IGNORE }, + { UP_EXIST_LARGE, EXIST_LARGE } }; #define UPEXISTBUTTONS (sizeof(UpExistButton)/sizeof(RADIOBUTTON)) @@ -2443,7 +2654,12 @@ void MoveRemoteFileProc(int drop_index) AskRemoteCurDir(HostDir, FMAX_PATH); // ドロップ先のフォルダ名を得る - GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH); + // 上位のディレクトリへ移動対応 +// GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH); + if(drop_index >= 0) + GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH); + else + strcpy(Pkt.File, ".."); if(MoveMode == MOVE_DLG) { @@ -2757,7 +2973,12 @@ void ChangeDirDirectProc(int Win) strcpy(Path, ""); if(Win == WIN_LOCAL) - Sts = InputDialogBox(chdir_br_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001); + // フォルダ選択ダイアログを直接表示 +// Sts = InputDialogBox(chdir_br_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001); + { + if(SelectDir(GetMainHwnd(), Path, FMAX_PATH) == TRUE) + Sts = YES; + } else Sts = InputDialogBox(chdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001); @@ -3073,7 +3294,9 @@ void SomeCmdProc(void) if(InputDialogBox(somecmd_dlg, GetMainHwnd(), NULL, Cmd, 81, &Tmp, IDH_HELP_TOPIC_0000023) == YES) { - DoQUOTE(Cmd); + // 同時接続対応 + //DoQUOTE(Cmd); + DoQUOTE(AskCmdCtrlSkt(), Cmd, &CancelFlg); } EnableUserOpe(); } @@ -3513,13 +3736,13 @@ static int RenameUnuseableName(char *Fname) // 自動切断対策 // NOOPコマンドでは効果が無いホストが多いためLISTコマンドを使用 -void NoopProc(void) +void NoopProc(int Force) { int CancelCheckWork; CancelCheckWork = NO; - if(AskConnecting() == YES && AskUserOpeDisabled() == NO) + if(Force == YES || (AskConnecting() == YES && AskUserOpeDisabled() == NO)) { - if(AskReuseCmdSkt() == NO || AskShareProh() == YES) + if(AskReuseCmdSkt() == NO || AskShareProh() == YES || AskTransferNow() == NO) { DisableUserOpe(); DoDirListCmdSkt("", "", 999, &CancelCheckWork);