/* Load a help topic if it isn't already available */ void helploadtopic(char* topic) { helploadmetafile(); /* Make sure the metafile is loaded */ if (findsection(&helplist, topic) == NULL) { stringvector file = helploadfile(topic); if (file.first == NULL) { /* Try loading from the data directory */ char* fullname = fullpath(helpdatapath, topic, SLASH_DEFAULT); file = helploadfile(fullname); free(fullname); } if (file.first == NULL) { /* Try loading from the docs subdirectory */ char* midname = fullpath("docs", topic, SLASH_DEFAULT); char* fullname = fullpath(helpdatapath, midname, SLASH_DEFAULT); file = helploadfile(fullname); free(midname); free(fullname); } /* If we loaded it, add to the list */ if (file.first != NULL) { helpsection* section = (helpsection*) malloc(sizeof(helpsection)); inithelpsection(section); section->title = str_dup(topic); section->sv = file; appendsection(&helplist, section); } } }
static void irc2() { char fname[MAXPATH]; register struct restab *rtp; register char *p; FILE *fp; static char tet_rescodes_file[] = "TET_RESCODES_FILE"; TRACE1(tet_Ttcc, 4, "irc2()"); /* determine the name of the rescode file */ if (tcc_modes & TCC_BUILD) p = getmcfg(tet_rescodes_file, TCC_BUILD); else p = (char *) 0; if ((!p || !*p) && (tcc_modes & TCC_EXEC)) p = getmcfg(tet_rescodes_file, TCC_EXEC); if ((!p || !*p) && (tcc_modes & TCC_CLEAN)) p = getmcfg(tet_rescodes_file, TCC_CLEAN); if (!p || !*p) p = "tet_code"; /* pick up the generic result code file if there is one */ fullpath(tet_root, p, fname, sizeof fname, 0); if (tet_initrestab() < 0 || (tet_eaccess(fname, 04) == 0 && tet_readrescodes(fname) < 0)) tcc_exit(1); /* pick up the testsuite-specific result code file if there is one */ fullpath(tet_tsroot, p, fname, sizeof fname, 0); if (tet_eaccess(fname, 04) == 0 && tet_readrescodes(fname) < 0) tcc_exit(1); /* ** here to install the master rescode file - ** create a temporary file and open it */ if ((rcftmp = tet_mktfname("tcc")) == (char *) 0) tcc_exit(1); if ((fp = fopen(rcftmp, "w")) == (FILE *) 0) fatal(errno, "can't open combined rescode file", rcftmp); /* write out the default results codes */ (void) fprintf(fp, "# master results code file\n\n"); for (rtp = tet_restab; rtp < tet_restab + tet_nrestab; rtp++) if (fprintf(fp, "%d \"%s\" %s\n", rtp->rt_code, rtp->rt_name, rtp->rt_abrt ? "Abort" : "Continue") < 0) fatal(errno, "write error on", rcftmp); if (fclose(fp) < 0) fatal(errno, "close error on", rcftmp); }
int archivefs_rename(const char* old_path, const char* new_path) { char fpath_old[PATH_MAX]; fullpath(fpath_old, old_path); /* pro fyzické soubory je třeba opět rozvinou nové jméno, jinak by byl * soubor vytvořen v pracovním adresáři procesu */ char fpath_new[PATH_MAX]; fullpath(fpath_new, new_path); FileSystem* fs; FileNode* node; int ret; if (!getFile(fpath_old, &fs, &node)) { ret = rename(fpath_old, fpath_new); if (ret) { ret = errno; print_err("RENAME", old_path, ret); } return -ret; } /* Přejmenovává se celý archív */ if (node->type == FileNode::ROOT_NODE) { ret = rename(fpath_old, fpath_new); if (ret) { ret = errno; print_err("RENAME", old_path, ret); return -ret; } FusePrivate* data = PRIVATE_DATA; data->filesystems->erase(fpath_old); free((void*)fs->archive_name); fs->archive_name = strdup(fpath_new); data->filesystems->insert(fs); return 0; } char* new_name; parsePathName(fpath_new, &new_name); ret = fs->rename(node, new_name); if (ret) print_err("RENAME", old_path, ret); return -ret; }
void writeSourceFile(std::ofstream & out_file, std::string & filename, const char * dirname, const char * alignment) { std::string fullpath(dirname); fullpath += "/"; fullpath += alignment; fullpath += "/"; fullpath += filename; std::ifstream in_file(fullpath.c_str()); std::string tmp; if (in_file.is_open()) { //write variable declaration: out_file << "const char * const " << dirname << "_" << alignment << "_" << filename.substr(0, filename.size()-3) << " = " << std::endl; //write source string: while (getline(in_file, tmp, '\n')) { if (tmp.size() > 0) { //out_file << "\"" << tmp.replace(tmp.end()-1, tmp.end(), "\\n\"") << std::endl; if ( *(tmp.end()-1) == '\r') //Windows line delimiter, \r\n out_file << "\"" << tmp.replace(tmp.end()-1, tmp.end(), "\\n\"") << std::endl; else //Unix line delimiter \n out_file << "\"" << tmp.append("\\n\"") << std::endl; } } out_file << "; //" << dirname << "_" << alignment << "_" << filename.substr(0, filename.size()-3) << std::endl << std::endl; } else std::cerr << "Failed to open file " << filename << std::endl; }
int archivefs_create(const char *path, mode_t mode, struct fuse_file_info *info) { char fpath[PATH_MAX]; fullpath(fpath, path); FileSystem* fs; int ret; if (!getFile(fpath, &fs, NULL)) { ret = creat(fpath, mode); if (ret == -1) { ret = errno; print_err("CREATE", path, ret); return -ret; } info->fh = intptr_t(ret); return 0; } FileNode* node; char* file; parsePathName(fpath, &file); struct fuse_context* context = fuse_get_context(); if (fs->parentAccess(file, W_OK|X_OK, context->uid, context->gid)) return -EACCES; ret = fs->create(file, mode, &node); if (ret) print_err("CREATE", path, ret); info->fh = intptr_t(new FileHandle(fs, node)); return -ret; }
int archivefs_mknod(const char* path, mode_t mode, dev_t dev) { char fpath[PATH_MAX]; fullpath(fpath, path); FileSystem* fs; int ret; if (!getFile(fpath, &fs, NULL)) { ret = mknod(fpath, mode, dev); if (ret) { ret = errno; print_err("MKNOD", fpath, ret); } return -ret; } char* file; parsePathName(fpath, &file); struct fuse_context* context = fuse_get_context(); if (fs->parentAccess(file, W_OK|X_OK, context->uid, context->gid)) return -EACCES; ret = fs->mknod(file, mode); if (ret) print_err("MKNOD", path, ret); return -ret; }
void Roms::add_data_roms() { std::string system = get_raw_path("/data/multiboot"); DIR *dp = opendir(system.c_str()); if (!dp ) { return; } auto close_dp = util::finally([&]{ closedir(dp); }); struct stat sb; struct dirent *ent; while ((ent = readdir(dp))) { if (strcmp(ent->d_name, "data-slot-") == 0 || !util::starts_with(ent->d_name, "data-slot-")) { continue; } std::string fullpath(system); fullpath += "/"; fullpath += ent->d_name; if (stat(fullpath.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) { roms.push_back(create_rom_data_slot(ent->d_name + 10)); } } }
void Settings::loadLanguages() { //adding translations search paths QStringList translation_dirs; translation_dirs << QCoreApplication::applicationDirPath(); translation_dirs << QCoreApplication::applicationDirPath()+"/translations"; #ifdef PROGRAM_DATA_DIR translation_dirs << QString(PROGRAM_DATA_DIR)+"/translations"; #endif #ifdef Q_WS_MAC translation_dirs << QCoreApplication::applicationDirPath()+"/../Resources"; #endif //looking for qm-files in translation directories QStringListIterator dir_path(translation_dirs); while(dir_path.hasNext()) { QDir dir(dir_path.next()); QStringList fileNames = dir.entryList(QStringList("znotes_*.qm")); for(int i=0; i < fileNames.size(); ++i) { QString filename(fileNames[i]); QString fullpath(dir.absoluteFilePath(filename)); filename.remove(0, filename.indexOf('_') + 1); filename.chop(3); QLocale locale(filename); if(!translations[locale.language()].contains(locale.country())) { translations[locale.language()][locale.country()]=fullpath; } } } //Setting default(English) translation path if other translation not found if(!translations[QLocale::English].contains(QLocale::UnitedStates)) translations[QLocale::English][QLocale::UnitedStates]=""; }
int archivefs_opendir(const char *path, struct fuse_file_info *info) { char fpath[PATH_MAX]; fullpath(fpath, path); /* Stejná logika jako u archivefs_open. */ DIR* dir; if ((dir = opendir(fpath)) != NULL) { info->fh = intptr_t(dir); return 0; } FileSystem* fs; FileNode* node; if (!getFile(fpath, &fs, &node)) { print_err("OPENDIR", path, ENOENT); return -ENOENT; } struct fuse_context* context = fuse_get_context(); if (fs->access(node, R_OK, context->uid, context->gid)) return -EACCES; info->fh = intptr_t(new FileHandle(fs, node)); return 0; }
void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) { void* handle = FX_OpenFolder(path.c_str()); if (!handle) { return; } CFX_ByteString filename; FX_BOOL bFolder = FALSE; while (FX_GetNextFile(handle, filename, bFolder)) { if (bFolder) { if (filename == "." || filename == "..") { continue; } } else { CFX_ByteString ext = filename.Right(4); ext.MakeLower(); if (ext != ".ttf" && ext != ".ttc" && ext != ".otf") { continue; } } CFX_ByteString fullpath(path); fullpath += "/"; fullpath += filename; if (bFolder) { ScanPath(fullpath); } else { ScanFile(fullpath); } } FX_CloseFolder(handle); }
// Normalize a file path. // remove relative path component (..\ and .\), // replace slashes by backslashes, // convert to long form. // // Returns a pointer to a memory allocated block containing the normalized string. // The caller is responsible for freeing the block. // Returns NULL if the file does not exist or if a memory allocation fails. // // Precondition: the file must exist on the file system. // // Note: // - the case of the root component is preserved // - the case of rest is set to the way it is stored on the file system // // e.g. suppose the a file "C:\foo\Bar.Pdf" exists on the file system then // "c:\foo\bar.pdf" becomes "c:\foo\Bar.Pdf" // "C:\foo\BAR.PDF" becomes "C:\foo\Bar.Pdf" WCHAR *Normalize(const WCHAR *path) { // convert to absolute path, change slashes into backslashes DWORD cch = GetFullPathName(path, 0, NULL, NULL); if (!cch) return str::Dup(path); ScopedMem<WCHAR> fullpath(AllocArray<WCHAR>(cch)); GetFullPathName(path, cch, fullpath, NULL); // convert to long form cch = GetLongPathName(fullpath, NULL, 0); if (!cch) return fullpath.StealData(); ScopedMem<WCHAR> normpath(AllocArray<WCHAR>(cch)); GetLongPathName(fullpath, normpath, cch); if (cch <= MAX_PATH) return normpath.StealData(); // handle overlong paths: first, try to shorten the path cch = GetShortPathName(fullpath, NULL, 0); if (cch && cch <= MAX_PATH) { ScopedMem<WCHAR> shortpath(AllocArray<WCHAR>(cch)); GetShortPathName(fullpath, shortpath, cch); if (str::Len(path::GetBaseName(normpath)) + path::GetBaseName(shortpath) - shortpath < MAX_PATH) { // keep the long filename if possible *(WCHAR *)path::GetBaseName(shortpath) = '\0'; return str::Join(shortpath, path::GetBaseName(normpath)); } return shortpath.StealData(); } // else mark the path as overlong if (str::StartsWith(normpath.Get(), L"\\\\?\\")) return normpath.StealData(); return str::Join(L"\\\\?\\", normpath); }
FILE* fcFileOpener::try_open(const wxString &path, const wxString &name, wxString &filepath) { wxString fullpath ( path + FC_PATH_SEP + name ); wxFileName fn(fullpath); fullpath = fn.GetFullPath(); FILE *fp = wxFopen(fullpath, "rb"); if ( fp ) { _scannedfiles.insert( name ); wxString pathPart = fn.GetPath(); for(size_t i=0; i<_excludePaths.size(); ++i) { if ( pathPart.StartsWith(_excludePaths.at(i) ) ) { ::fclose( fp ); return NULL; } } _matchedfiles.insert( fullpath ); filepath = fullpath; return fp; } return NULL; }
ServletConfigImpl* AppContext::addServlet(const std::string& path, const std::string& name, const std::string& dso, bool hidden, size_t maxRequestSize, size_t maxFileSize) { std::string fullpath("/"); if(!getServletContextName().empty()) { // avoid starting with "//" fullpath.append(getServletContextName()); fullpath+='/'; } fullpath.append(path); ServletDesc* desc = getDesc(fullpath); if(desc) { // Another servlet is already configured for the path in this app... std::cerr<<"Path "<<fullpath<<" is already used"<<std::endl; return 0; } void* dsoHandle=dlopen(dso.c_str(),RTLD_LAZY); if(!dsoHandle) { std::cerr<<"Error loading library \""<<dso<<"\": "<<dlerror()<<std::endl; return 0; } servletcreatefunc_t createFunc=(servletcreatefunc_t)dlsym(dsoHandle,(name + "_createServlet").c_str()); if(!createFunc) { std::cerr<<"Could not locate servlet "<<name<<" in the library "<<dso<<": "<<dlerror()<<std::endl; return 0; } ServletConfigImpl* config=new ServletConfigImpl(this, name); desc=new ServletDesc(createFunc(), config, dsoHandle, fullpath, maxRequestSize, maxFileSize, m_mime, m_enc, m_cache); m_maptop[fullpath]=desc; if(!hidden) { if(!RequestHandler::addServlet(fullpath,getServletContainer(fullpath))) { // Another such URL exists globally unloadServlet(fullpath); delServlet(fullpath); return 0; } } return config; }
void main_pre_dc_init( int, char*[] ) { DC_Skip_Auth_Init(); DC_Skip_Core_Init(); #ifdef WIN32 _setmaxstdio(2048); #endif // Convert the DAGMan log file name to an absolute path if it's // not one already, so that we'll log things to the right file // if we change to a different directory. const char * logFile = GetEnv( "_CONDOR_DAGMAN_LOG" ); if ( logFile && !fullpath( logFile ) ) { MyString currentDir; if ( condor_getcwd( currentDir ) ) { MyString newLogFile(currentDir); newLogFile += DIR_DELIM_STRING; newLogFile += logFile; SetEnv( "_CONDOR_DAGMAN_LOG", newLogFile.Value() ); } else { debug_printf( DEBUG_NORMAL, "ERROR: unable to get cwd: %d, %s\n", errno, strerror(errno) ); } } }
void wxFormBuilder::OnOpenFile(clCommandEvent& e) { e.Skip(); // launch it with the default application wxFileName fullpath(e.GetFileName()); if(fullpath.GetExt().MakeLower() != wxT("fbp")) { return; } #ifdef __WXGTK__ e.Skip(false); // Under Linux, use xdg-open wxString cmd; cmd << wxT("/bin/sh -c 'xdg-open \"") << fullpath.GetFullPath() << wxT("\"' 2> /dev/null"); wxExecute(cmd); return; #else wxMimeTypesManager* mgr = wxTheMimeTypesManager; wxFileType* type = mgr->GetFileTypeFromExtension(fullpath.GetExt()); if(type) { wxString cmd = type->GetOpenCommand(fullpath.GetFullPath()); wxDELETE(type); if(cmd.IsEmpty() == false) { e.Skip(false); wxExecute(cmd); } } #endif }
int archivefs_truncate(const char* path, off_t size) { char fpath[PATH_MAX]; fullpath(fpath, path); FileSystem* fs; FileNode* node; int ret; if (!getFile(fpath, &fs, &node)) { ret = truncate(fpath, size); if (ret) { ret = errno; } } else { struct fuse_context* context = fuse_get_context(); if (fs->access(node, W_OK, context->uid, context->gid)) return -EACCES; ret = fs->truncate(node, size); } if (ret) print_err("TRUNCATE", path, ret); return -ret; }
int archivefs_release(const char *path, struct fuse_file_info *info) { (void)path; FusePrivate* fuse_data = PRIVATE_DATA; FileHandle* fh; /* Zde je stejná logika jako u archivefs_read. */ if (fuse_data->mode == FusePrivate::ARCHIVE_MOUNTED) { fh = reinterpret_cast<FileHandle*>(info->fh); fh->first->close(fh->second); delete fh; } else { char fpath[PATH_MAX]; fullpath(fpath, path); if (access(fpath, F_OK) == 0) { close(info->fh); } else { fh = reinterpret_cast<FileHandle*>(info->fh); fh->first->close(fh->second); delete fh; } } return 0; }
// Recursively deletes the file named path. If path is a file, it will be // removed. If it is a directory, everything in it will also be deleted. // Returns 0 on success, -1 on error, and sets errno appropriately. static int rmtree(const char* path) { // TODO: Handle errors in a more intelligent fashion? DIR* dir = opendir(path); if (dir == NULL) { if (errno == ENOTDIR) { // Not a directory: unlink it instead return unlink(path); } return -1; } assert(dir != NULL); for (struct dirent* entry = readdir(dir); entry != NULL; entry = readdir(dir)) { // Skip special directories if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { continue; } // Recursively delete the directory entry. This handles regular files // and directories. string fullpath(path); fullpath += "/"; fullpath += entry->d_name; rmtree(fullpath.c_str()); } int error = closedir(dir); assert(error == 0); return rmdir(path); }
// check if a file was transferred. // if so, fullname will have full path in working directory. // Otherwise, fullname will be same to file_name bool VMType::isTransferedFile(const char* file_name, MyString& fullname) { if( !file_name || m_initial_working_files.isEmpty() ) { return false; } // check if this file was transferred. MyString tmp_fullname; if( filelist_contains_file(file_name, &m_initial_working_files, true) ) { // this file was transferred. // make full path with workingdir tmp_fullname.formatstr("%s%c%s", m_workingpath.Value(), DIR_DELIM_CHAR, condor_basename(file_name)); fullname = tmp_fullname; return true; }else { // this file is not transferred if( fullpath(file_name) == false ) { vmprintf(D_ALWAYS, "Warning: The file(%s) doesn't have " "full path even though it is not " "transferred\n", file_name); } fullname = file_name; return false; } return false; }
int archivefs_getattr(const char* path, struct stat* info) { char fpath[PATH_MAX]; fullpath(fpath, path); FileSystem* fs = NULL; FileNode* node; int ret; if (!getFile(fpath, &fs, &node)) { /* fs byl nalezen, ale soubor ne */ if (fs != NULL) { print_err("GETATTR", path, ENOENT); return -ENOENT; } if ((ret = stat(fpath, info)) != 0) { ret = errno; print_err("GETATTR", path, ret); } return -ret; } struct stat* node_info = fs->getAttr(node); memcpy(info, node_info, sizeof(struct stat)); // printStat(info); return 0; }
int vpb::mkpath(const char *path, int mode) { if (path==0) return 0; vpb::log(osg::INFO,"mkpath(%s)",path); // first create a list of paths that needs to be checked/created. std::string fullpath(path); typedef std::list<std::string> Directories; Directories directories; int pos_start = 0; for(int pos_current = 0; pos_current<fullpath.size(); ++pos_current) { if (fullpath[pos_current]=='\\' || fullpath[pos_current]=='/') { int size = pos_current-pos_start; if (size>1) { if (pos_current == 2 && fullpath[1]==':') directories.push_back(std::string(fullpath,0, pos_current+1)); else directories.push_back(std::string(fullpath,0, pos_current)); pos_start = pos_current+1; } } } int size = fullpath.size()-pos_start; if (size>1) { directories.push_back(fullpath); } // now check the diretories and create the onces that are required in turn. for(Directories::iterator itr = directories.begin(); itr != directories.end(); ++itr) { std::string& path = (*itr); int result = 0; osgDB::FileType type = osgDB::fileType(path); if (type==osgDB::REGULAR_FILE) { log(osg::NOTICE,"Error cannot create directory %s as a conventional file already exists with that name",path.c_str()); return 1; } else if (type==osgDB::FILE_NOT_FOUND) { // need to create directory. result = vpb::mkdir(path.c_str(), mode); if (result) log(osg::NOTICE,"Error could not create directory %s",path.c_str()); else log(osg::INFO," created directory %s",path.c_str()); if (result) return result; } } return 0; }
int archivefs_write(const char* path, const char* buffer, size_t len, off_t offset, struct fuse_file_info* info) { FusePrivate* fuse_data = PRIVATE_DATA; FileHandle* fh = NULL; int ret = 0; if (fuse_data->mode == FusePrivate::ARCHIVE_MOUNTED) { fh = reinterpret_cast<FileHandle*>(info->fh); ret = (fh->first->write(fh->second, buffer, len, offset)); } else { char fpath[PATH_MAX]; fullpath(fpath, path); if (access(fpath, F_OK) == 0) { ret = pwrite(info->fh, buffer, len, offset); if (ret < 0) { ret = errno; print_err("WRITE", path, ret); return -ret; } } else { fh = reinterpret_cast<FileHandle*>(info->fh); ret = (fh->first->write(fh->second, buffer, len, offset)); if (ret < 0) print_err("WRITE", path, ret); } } return ret; }
std::vector<std::string> signalList(const char* dirName="", const char* pattern="", unsigned int debug=0) { std::vector<std::string> histnames; TIter next(gDirectory->GetListOfKeys()); TKey* iobj; unsigned int idx=0; while((iobj = (TKey*)next())){ if(iobj->IsFolder()) continue; if(debug>2){ std::cout << "[" << ++idx << "] ...Found object: " << iobj->GetName() << " of type: " << iobj->GetClassName() << std::endl; } std::string fullpath(dirName); fullpath += fullpath == std::string("") ? "" : "/"; fullpath += iobj->GetName(); // why does \\w*_\\d+ not work to catch them all?!? if(std::string(pattern).empty()){ std::map<const char*, const char*> dict = httDictionary(); for(std::map<const char*, const char*>::const_iterator name = dict.begin(); name!=dict.end(); ++name){ if(match(iobj->GetName(), (char*)name->first)){ histnames.push_back(fullpath); } } } else if(!std::string(pattern).empty() && match(iobj->GetName(), (char*)pattern)){ histnames.push_back(fullpath); } } return histnames; }
CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAlpha, int width) { CCAssert(path != NULL, "TextureCache: fileimage MUST not be nill"); CCAssert( bpp==2 || bpp==4, "TextureCache: bpp must be either 2 or 4"); CCTexture2D * texture; std::string temp(path); if ( (texture = m_pTextures->objectForKey(temp)) ) { return texture; } // Split up directory and filename std::string fullpath( CCFileUtils::fullPathFromRelativePath(path) ); CCData * data = CCData::dataWithContentsOfFile(fullpath); texture = new CCTexture2D(); texture->initWithPVRTCData(data->bytes(), 0, bpp, hasAlpha, width); if( texture ) { m_pTextures->setObject(texture, temp); texture->autorelease(); } else { CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",path); } CC_SAFE_DELETE(data); return texture; }
PDMBUILDER_API bool getRelyFiles(char *ws,string &ret) { ret.assign("\n<---------------------------Get Dependence File--------------------------->\n"); list<Dependence *> * depList = getDependences(); for (list<Dependence *>::iterator iter=depList->begin();iter != depList->end();++iter) { string flag = (*iter)->GetFlag(); string server = (*iter)->GetServer(); string repository = (*iter)->GetRepository(); string name = (*iter)->GetName(); string version = (*iter)->GetVersion(); string path = (*iter)->GetPath(); string localPath = (*iter)->GetLocalPath(); localPath = changeSeparator(localPath); string pArgument = "Flag="+flag+"&Repository="+repository+"&Name="+name+"&Version="+version+"&Path="+path; string fullpath(ws); fullpath.append("\\").append(localPath); ret += ExeDownLoad((char *)server.c_str(),(char *)pArgument.c_str(),(char *)fullpath.c_str()); //return TRUE; } delete depList; return true; }
char* JICLocal::getJobStdFile( const char* attr_name ) { char* tmp = NULL; MyString filename; // the only magic here is to make sure we have full paths for // these, by prepending the job's iwd if the filename doesn't // start with a '/' job_ad->LookupString( attr_name, &tmp ); if( ! tmp ) { return NULL; } if ( !nullFile(tmp) ) { if( ! fullpath(tmp) ) { filename.formatstr( "%s%c", job_iwd, DIR_DELIM_CHAR ); } filename += tmp; } free( tmp ); if( filename[0] ) { return strdup( filename.Value() ); } return NULL; }
bool MakeDir(const OJString &path) { if (!IsDirExist(path)) { fs::path fullpath(path); sys::error_code err; bool res = fs::create_directory(fullpath, err); if (!(sys::errc::success == err)) { ILogger *logger = LoggerFactory::getLogger(LoggerId::AppInitLoggerId); OJString msg(GetOJString("[filetool] - IMUST::MakeDir - make dir failed: ")); msg += path; msg += GetOJString(" - "); msg += String2OJString(err.message()); logger->logError(msg); return false; } return res; } return true; }
bool RemoveFile(const OJString &filename) { if (IsFileExist(filename)) { fs::path fullpath(filename); sys::error_code err; bool res = fs::remove(fullpath, err); if (!(sys::errc::success == err)) { ILogger *logger = LoggerFactory::getLogger(LoggerId::AppInitLoggerId); OJString msg(GetOJString("[filetool] - IMUST::RemoveFile - remove failed: ")); msg += filename; msg += GetOJString(" - "); msg += String2OJString(err.message()); logger->logError(msg); return false; } return res; } return true; }
void QMakePlugin::OnOpenFile(wxCommandEvent &event) { wxString *fn = (wxString*)event.GetClientData(); if ( fn ) { // launch it with the default application wxFileName fullpath ( *fn ); if ( fullpath.GetExt().MakeLower() != wxT("ui") ) { event.Skip(); return; } wxMimeTypesManager *mgr = wxTheMimeTypesManager; wxFileType *type = mgr->GetFileTypeFromExtension(fullpath.GetExt()); if ( type ) { wxString cmd = type->GetOpenCommand(fullpath.GetFullPath()); delete type; if ( cmd.IsEmpty() == false ) { wxExecute(cmd); return; } } } // we failed, call event.Skip() event.Skip(); }
int archivefs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *info) { (void)offset; (void)path; FusePrivate* fuse_data = PRIVATE_DATA; FileHandle* fh = NULL; int ret; /* Stejná logika jako u archivefs_read. */ if (fuse_data->mode == FusePrivate::ARCHIVE_MOUNTED) { fh = reinterpret_cast<FileHandle*>(info->fh); } else { char fpath[PATH_MAX]; fullpath(fpath, path); struct stat dir_info; if (stat(fpath, &dir_info) == 0 && S_ISDIR(dir_info.st_mode)) { DIR* dir = reinterpret_cast<DIR*>(info->fh); struct dirent* file; // Every directory contains at least two entries: . and .. If my // first call to the system readdir() returns NULL I've got an // error; near as I can tell, that's the only condition under // which I can get an error from readdir() file = readdir(dir); if (file == NULL) { ret = errno; print_err("READDIR", path, ret); return -ret; } else { do { if (filler(buf, file->d_name, NULL, 0) != 0) { return -ENOMEM; } } while ((file = readdir(dir)) != NULL); return 0; } } else { fh = reinterpret_cast<FileHandle*>(info->fh); } } filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); FileList* files = fh->first->readDir(fh->second); for (FileList::const_iterator it = files->begin(); it != files->end(); ++it) { if (filler(buf, (*it)->name_ptr, NULL, 0) != 0) { print_err("READDIR", path, ENOMEM); return -ENOMEM; } } return 0; }