BOOL FtpSetCurrentDirectory(Connection *hConnect, LPCSTR dir) { String Command; Assert(hConnect && "FtpSetCurrentDirectory"); if(*dir == 0) return FALSE; do { if(StrCmp(dir, "..") == 0) { Command.printf("cdup"); } else { Command.printf("cd \x1%s\x1",dir); } if(hConnect->ProcessCommand(Command)) break; return FALSE; } while(0); FtpGetFtpDirectory(hConnect); return TRUE; }
BOOL FtpGetCurrentDirectory(Connection *hConnect,String& s) { s.Null(); if(!hConnect) return TRUE; if(!hConnect->CurDir.Length()) { if(!FtpGetFtpDirectory(hConnect)) return FALSE; } s = hConnect->CurDir; // hConnect->ToOEM(s); return s.Length() != 0; }
BOOL FtpFindFirstFile(Connection *hConnect, LPCSTR lpszSearchFile,FTPFileInfo* lpFindFileData, BOOL *ResetCache) { Assert(hConnect && "FtpFindFirstFile"); String Command; int AllFiles = StrCmp(lpszSearchFile,"*")==0 || StrCmp(lpszSearchFile,"*.*")==0; int FromCache = 0; if(ResetCache && *ResetCache == TRUE) { hConnect->CacheReset(); FtpGetFtpDirectory(hConnect); *ResetCache = FALSE; } if(AllFiles) Command = "dir"; else { if(*lpszSearchFile=='/') lpszSearchFile = PointToName((char *)lpszSearchFile); Command.printf("dir \x1%s\x1", lpszSearchFile); } WINPORT(SetLastError)(ERROR_SUCCESS); if(!AllFiles || (FromCache=hConnect->CacheGet()) == 0) { if(AllFiles && !IS_SILENT(FP_LastOpMode) && hConnect->CmdVisible && hConnect->CurrentState != fcsExpandList) hConnect->ConnectMessage(MRequestingFolder, hConnect->CurDir.c_str()); // hConnect->ToOEMDup(hConnect->CurDir.c_str())); int pc = hConnect->ProcessCommand(Command); if(!pc) { if(hConnect->Host.ServerType==FTP_TYPE_MVS) { if(hConnect->code==550) { pc = 1; //550 No members found. } if(hConnect->code==501&&AllFiles) { Command="dir *"; pc = hConnect->ProcessCommand(Command); } } if(!pc) { WINPORT(SetLastError)(hConnect->ErrorCode); return FALSE; } } } if(AllFiles && !FromCache) hConnect->CacheAdd(); return ParseDirLine(hConnect,AllFiles,lpFindFileData); }