BOOL GetAbsPath(PCHAR FName, int destlen) { int i, j; char Temp[MAXPATHLEN]; if (! GetFileNamePos(FName,&i,&j)) { return FALSE; } if (strlen(FName) > 2 && FName[1] == ':') { // fullpath return TRUE; } else if (FName[0] == '\\' && FName[1] == '\\') { // UNC (\\server\path) return TRUE; } strncpy_s(Temp, sizeof(Temp), FName, _TRUNCATE); strncpy_s(FName,destlen,CurrentDir,_TRUNCATE); if (Temp[0] == '\\' && destlen > 2) { // from drive root (\foo\bar) FName[2] = 0; } else { AppendSlash(FName,destlen); } strncat_s(FName,destlen,Temp,_TRUNCATE); return TRUE; }
FILE * OpenFile( const char * name, bool append ) //----------------------------------------------- { char fileName[ _MAX_PATH ]; char * foundName; FILE * fp; foundName = getenv( name ); if( foundName != NULL ) { strcpy( fileName, foundName ); } else { foundName = getenv( LogDirEnvVar ); if( foundName != NULL ) { strcpy( fileName, foundName ); AppendSlash( fileName ); strncat( fileName, name, _MAX_FNAME - 1 ); strcat( fileName, ".log" ); } else { foundName = getenv( TmpEnvVar ); if( foundName != NULL ) { strcpy( fileName, foundName ); AppendSlash( fileName ); strncat( fileName, name, _MAX_FNAME ); strcat( fileName, ".log" ); } else { strcpy( fileName, name ); // give up, use name } } } if( append ) { fp = fopen( fileName, "at" ); // append to end } else { fp = fopen( fileName, "wt" ); } return fp; }
void subdirectories(const std::string& path, std::vector<std::string>* subdirs) { subdirs->clear(); std::string dir = AppendSlash(path); std::vector<std::string> files; scandir(dir, "", &files); for (const auto& file : files) { if (file == "." || file == "..") continue; auto subpath = dir + file; if (is_dir(subpath)) { subdirs->push_back(file); } } }
void SendFileStart() { if (LoggedOff || InputRequest) { AddEStr("You can't start sending a file when logged off or while pending input request.\n", 0, 0); return; } strcpy(SendFilePath, FRqDir); AppendSlash(SendFilePath); UpdateOptions(); Fl = fopen(SendFileFName, "r"); if (Fl == 0) beep(); if (Fl) { AddCommandToQueue("EXEC EDTS8;", 2); InputRequestHook = SendFileSetup; //NoInputRequestHook = SendFileError; /* > will be here for EXEC EDTS8; */ CancelHook = SendFileCancel; } else { AddEStr("Cannot open the file for sending.\n", 0, 0); } }