void WINAPI QuoteStr(String& str) { String buff; if(str.Chr(quotes) == -1) return; buff.Add('\"'); for(int n = 0; n < str.Length(); n++) if(str[n] == '\"') { buff.Add('\"'); buff.Add('\"'); } else buff.Add(str[n]); buff.Add('\"'); str = buff; }
BOOL FTP::FTPCreateDirectory(LPCSTR dir,int OpMode) { String Command; int len = (int)strlen(dir); if(!len) return FALSE; len--; Assert(hConnect && "FtpCreateDirectory"); do { //Try relative path if(!isspace(dir[len])) { hConnect->CacheReset(); Command.printf("mkdir \x1%s\x1", dir); if(hConnect->ProcessCommand(Command)) break; } //Try relative path with end slash hConnect->CacheReset(); Command.printf("mkdir \x1%s/\x1", dir); if(hConnect->ProcessCommand(Command)) break; //Try absolute path if(!isspace(dir[len])) { Command.printf("mkdir \x1%s/%s\x1", hConnect->SToOEM(hConnect->CurDir).c_str(), dir + (dir[0] == '/')); if(hConnect->ProcessCommand(Command)) break; } //Try absolute path with end slash Command.printf("mkdir \x1%s/%s/\x1", hConnect->SToOEM(hConnect->CurDir).c_str(), dir + (dir[0] == '/')); if(hConnect->ProcessCommand(Command)) break; //Noone work return FALSE; } while(0); if(!IS_SILENT(OpMode)) { int b = Command.Chr('\x1'), e = Command.Chr('\x1', b+1); if(b == -1) SelectFile = ""; else if(e == -1) SelectFile.Set(Command.c_str(), b+1, -1); else SelectFile.Set(Command.c_str(), b+1, e); } return TRUE; }
void FTP::AddToQueque(FAR_FIND_DATA* FileName, LPCSTR Path, BOOL Download) { String str; char *m; int num; FTPUrl* p = new FTPUrl; memcpy(&p->Host, &Host, sizeof(Host)); p->Download = Download; p->Next = NULL; p->FileName = *FileName; p->Error.Null(); p->DestPath = Path; if(Download) m = strrchr(FileName->cFileName, '/'); else m = strrchr(FileName->cFileName, '\\'); if(m) { *m = 0; p->DestPath.Add(m); memmove(FileName->cFileName, m+1, m-FileName->cFileName); } if(Download) { GetCurPath(p->SrcPath); AddEndSlash(p->SrcPath, '/'); str.printf("%s%s", p->SrcPath.c_str(), FileName->cFileName); FixLocalSlash(p->DestPath); AddEndSlash(p->DestPath, '\\'); num = str.Chr('/'); } else { PanelInfo pi; FP_Info->Control(this, FCTL_GETANOTHERPANELINFO, &pi); p->SrcPath = pi.CurDir; AddEndSlash(p->SrcPath, '\\'); str.printf("%s%s", p->SrcPath.c_str(), FileName->cFileName); FixLocalSlash(str); AddEndSlash(p->DestPath, '/'); num = str.Chr('\\'); } if(num != -1) { StrCpy(p->FileName.cFileName, str.c_str()+num+1, ARRAYSIZE(p->FileName.cFileName)); str.SetLength(num); p->SrcPath = str; } else { StrCpy(p->FileName.cFileName, str.c_str(), ARRAYSIZE(p->FileName.cFileName)); p->SrcPath.Null(); } if(!UrlsList) UrlsList = p; if(UrlsTail) UrlsTail->Next = p; UrlsTail = p; QuequeSize++; }