From: s_kawamoto Date: Tue, 14 Feb 2012 17:18:04 +0000 (+0900) Subject: Add support for automatic directory creation. X-Git-Url: http://git.osdn.net/view?p=ffftp%2Fffftp.git;a=commitdiff_plain;h=24d1bc42635bcba06b0330864341db64fcf50b13 Add support for automatic directory creation. --- diff --git a/FFFTP_Eng_Release/FFFTP.exe b/FFFTP_Eng_Release/FFFTP.exe index c5c1e1e..6f1a87c 100644 Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ diff --git a/Release/FFFTP.exe b/Release/FFFTP.exe index eca661c..384adbc 100644 Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ diff --git a/ftpproc.c b/ftpproc.c index af6e2b0..8639482 100644 --- a/ftpproc.c +++ b/ftpproc.c @@ -108,6 +108,8 @@ extern SIZE MirrorDlgSize; extern int VaxSemicolon; extern int DebugConsole; extern int CancelFlg; +// ディレクトリ自動作成 +extern int MakeAllDir; /*===== ローカルなワーク =====*/ @@ -136,6 +138,46 @@ static double FileSize; /* ファイル総容量 */ * なし *----------------------------------------------------------------------------*/ +// ディレクトリ自動作成 +// ローカル側のパスから必要なフォルダを作成 +int MakeDirFromLocalPath(char* LocalFile) +{ + TRANSPACKET Pkt; + char* pDelimiter; + char* pNext; + char* Cat; + int Len; + char Tmp[FMAX_PATH+1]; + int Make; + pDelimiter = LocalFile; + Make = NO; + while(pNext = strchr(pDelimiter, '\\')) + { + Len = pNext - LocalFile; + strncpy(Pkt.LocalFile, LocalFile, Len); + Pkt.LocalFile[Len] = '\0'; + AskLocalCurDir(Tmp, FMAX_PATH); + SetYenTail(Tmp); + if(strncmp(LocalFile, Tmp, 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; @@ -248,7 +290,13 @@ void DownLoadProc(int ChName, int ForceFile, int All) if(Pkt.Mode == EXIST_ABORT) break; else if(Pkt.Mode != EXIST_IGNORE) + // ディレクトリ自動作成 +// AddTransFileList(&Pkt); + { + if(MakeAllDir == YES) + MakeDirFromLocalPath(Pkt.LocalFile); AddTransFileList(&Pkt); + } } Pos = Pos->Next; } @@ -890,6 +938,72 @@ static INT_PTR CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM * なし *----------------------------------------------------------------------------*/ +// ディレクトリ自動作成 +// リモート側のパスから必要なディレクトリを作成 +int MakeDirFromRemotePath(char* RemoteFile, int FirstAdd) +{ + TRANSPACKET Pkt; + TRANSPACKET Pkt1; + char* pDelimiter; + char* pNext; + char* Cat; + int Len; + char Tmp[FMAX_PATH+1]; + int Make; + pDelimiter = RemoteFile; + Make = NO; + while(pNext = strchr(pDelimiter, '/')) + { + Len = pNext - RemoteFile; + strncpy(Pkt.RemoteFile, RemoteFile, Len); + Pkt.RemoteFile[Len] = '\0'; + AskRemoteCurDir(Tmp, FMAX_PATH); + SetSlashTail(Tmp); + if(strncmp(RemoteFile, Tmp, 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; @@ -961,6 +1075,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) @@ -1034,6 +1158,12 @@ void UpLoadListProc(int ChName, int All) break; else if(Pkt.Mode != EXIST_IGNORE) { + // ディレクトリ自動作成 + if(MakeAllDir == YES) + { + if(MakeDirFromRemotePath(Pkt.RemoteFile, FirstAdd) == YES) + FirstAdd = NO; + } if((FirstAdd == YES) && (AskNoFullPathMode() == YES)) { strcpy(Pkt1.Cmd, "SETCUR"); @@ -1202,6 +1332,12 @@ void UpLoadDragProc(WPARAM wParam) break; else if(Pkt.Mode != EXIST_IGNORE) { + // ディレクトリ自動作成 + if(MakeAllDir == YES) + { + if(MakeDirFromRemotePath(Pkt.RemoteFile, FirstAdd) == YES) + FirstAdd = NO; + } if((FirstAdd == YES) && (AskNoFullPathMode() == YES)) { strcpy(Pkt1.Cmd, "SETCUR"); diff --git a/main.c b/main.c index 8f6272e..c2723e0 100644 --- a/main.c +++ b/main.c @@ -233,6 +233,8 @@ BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20]; BYTE SSLRootCAFileHash[20]; // ファイルアイコン表示対応 int DispFileIcon = NO; +// ディレクトリ自動作成 +int MakeAllDir = YES;