X-Git-Url: http://git.sourceforge.jp/view?p=ffftp%2Fffftp.git;a=blobdiff_plain;f=ftpproc.c;h=e13bc7d639703f09069119285c77e9f098f25b04;hp=8963604069ce95c88409d04d778bc8d99005d5c0;hb=eb4bba58018c0bb08e8564600c2c66257c3a3077;hpb=2ee418d5d0095069672ab0de6c01ae07336756e0 diff --git a/ftpproc.c b/ftpproc.c index 8963604..e13bc7d 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,9 @@ void DownLoadProc(int ChName, int ForceFile, int All) } DeleteFileList(&FileListBase); - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); GoForwardTransWindow(); // KeepTransferDialog(NO); @@ -282,7 +332,7 @@ void DownLoadProc(int ChName, int ForceFile, int All) * なし *----------------------------------------------------------------------------*/ -void DirectDownLoadProc(char *Fname) +void DirectDownloadProc(char *Fname) { TRANSPACKET Pkt; @@ -363,8 +413,9 @@ void DirectDownLoadProc(char *Fname) AddTransFileList(&Pkt); } - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); GoForwardTransWindow(); // KeepTransferDialog(NO); @@ -384,7 +435,7 @@ void DirectDownLoadProc(char *Fname) * なし *----------------------------------------------------------------------------*/ -void InputDownLoadProc(void) +void InputDownloadProc(void) { char Path[FMAX_PATH+1]; int Tmp; @@ -394,7 +445,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,8 +680,9 @@ void MirrorDownloadProc(int Notify) AddTransFileList(&Pkt); } - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); } else EraseTmpTransFileList(&Base); @@ -887,7 +939,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 +1073,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) @@ -1016,7 +1141,7 @@ void UpLoadListProc(int ChName, int All) Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType()); Pkt.Size = 0; Pkt.Time = Pos->Time; - Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); + Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile); Pkt.KanjiCode = AskHostKanjiCode(); // UTF-8対応 Pkt.KanjiCodeDesired = AskLocalKanjiCode(); @@ -1026,11 +1151,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 +1189,9 @@ void UpLoadListProc(int ChName, int All) DeleteFileList(&FileListBase); - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); GoForwardTransWindow(); @@ -1076,7 +1210,7 @@ void UpLoadListProc(int ChName, int All) * なし *----------------------------------------------------------------------------*/ -void UpLoadDragProc(WPARAM wParam) +void UploadDragProc(WPARAM wParam) { FILELIST *FileListBase; FILELIST *Pos; @@ -1182,7 +1316,7 @@ void UpLoadDragProc(WPARAM wParam) Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType()); Pkt.Size = 0; Pkt.Time = Pos->Time; - Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); + Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile); Pkt.KanjiCode = AskHostKanjiCode(); // UTF-8対応 Pkt.KanjiCodeDesired = AskLocalKanjiCode(); @@ -1193,11 +1327,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 +1365,9 @@ void UpLoadDragProc(WPARAM wParam) DeleteFileList(&FileListBase); - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); GoForwardTransWindow(); @@ -1459,7 +1602,7 @@ void MirrorUploadProc(int Notify) Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType()); Pkt.Size = 0; Pkt.Time = LocalPos->Time; - Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile); + Pkt.Attr = AskUploadFileAttr(Pkt.RemoteFile); Pkt.KanjiCode = AskHostKanjiCode(); // UTF-8対応 Pkt.KanjiCodeDesired = AskLocalKanjiCode(); @@ -1494,8 +1637,9 @@ void MirrorUploadProc(int Notify) AddTransFileList(&Pkt); } - strcpy(Pkt.Cmd, "GOQUIT"); - AddTransFileList(&Pkt); + // 同時接続対応 +// strcpy(Pkt.Cmd, "GOQUIT"); +// AddTransFileList(&Pkt); } else EraseTmpTransFileList(&Base); @@ -1831,7 +1975,7 @@ static int AskMirrorNoTrn(char *Fname, int Mode) * int 属性 (-1=設定なし) *----------------------------------------------------------------------------*/ -static int AskUpLoadFileAttr(char *Fname) +static int AskUploadFileAttr(char *Fname) { int Ret; int Sts; @@ -3073,7 +3217,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(); }