这篇教程C++ IsDirectory函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IsDirectory函数的典型用法代码示例。如果您正苦于以下问题:C++ IsDirectory函数的具体用法?C++ IsDirectory怎么用?C++ IsDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IsDirectory函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetSize// Returns the size of filename (64bit)u64 GetSize(const std::string &filename){ struct stat64 file_info;#if defined(_WIN32) && defined(UNICODE) int result = _wstat64(ConvertUTF8ToWString(filename).c_str(), &file_info);#else int result = stat64(filename.c_str(), &file_info);#endif if (result != 0) { WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.c_str()); return 0; } if (IsDirectory(file_info)) { WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str()); return 0; } DEBUG_LOG(COMMON, "GetSize: %s: %lld", filename.c_str(), (long long)file_info.st_size); return file_info.st_size;}
开发者ID:BrainDamage,项目名称:libretro-ppsspp,代码行数:24,
示例2: CtdlDirectoryLookup/* * Look up an Internet e-mail address in the directory. * On success: returns 0, and Citadel address stored in 'target' * On failure: returns nonzero */int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen) { struct cdbdata *cdbrec; char key[SIZ]; /* Dump it in there unchanged, just for kicks */ safestrncpy(target, internet_addr, targbuflen); /* Only do lookups for addresses with hostnames in them */ if (num_tokens(internet_addr, '@') != 2) return(-1); /* Only do lookups for domains in the directory */ if (IsDirectory(internet_addr, 0) == 0) return(-1); directory_key(key, internet_addr); cdbrec = cdb_fetch(CDB_DIRECTORY, key, strlen(key) ); if (cdbrec != NULL) { safestrncpy(target, cdbrec->ptr, targbuflen); cdb_free(cdbrec); return(0); } return(-1);}
开发者ID:zcw159357,项目名称:citadel,代码行数:28,
示例3: CopyDir// Create directory and copy contents (does not overwrite existing files)void CopyDir(const std::string &source_path, const std::string &dest_path){#ifndef _WIN32 if (source_path == dest_path) return; if (!File::Exists(source_path)) return; if (!File::Exists(dest_path)) File::CreateFullPath(dest_path); struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; }; struct dirent_large diren; struct dirent *result = NULL; DIR *dirp = opendir(source_path.c_str()); if (!dirp) return; while (!readdir_r(dirp, (dirent*) &diren, &result) && result) { const std::string virtualName(result->d_name); // check for "." and ".." if (((virtualName[0] == '.') && (virtualName[1] == '/0')) || ((virtualName[0] == '.') && (virtualName[1] == '.') && (virtualName[2] == '/0'))) continue; std::string source, dest; source = source_path + virtualName; dest = dest_path + virtualName; if (IsDirectory(source)) { source += '/'; dest += '/'; if (!File::Exists(dest)) File::CreateFullPath(dest); CopyDir(source, dest); } else if (!File::Exists(dest)) File::Copy(source, dest); } closedir(dirp);#endif}
开发者ID:AdmiralCurtiss,项目名称:ppsspp,代码行数:38,
示例4: CopyDir// Create directory and copy contents (does not overwrite existing files)void CopyDir(const std::string &source_path, const std::string &dest_path){#ifndef _WIN32 if (source_path == dest_path) return; if (!File::Exists(source_path)) return; if (!File::Exists(dest_path)) File::CreateFullPath(dest_path); struct dirent *result = NULL; DIR *dirp = opendir(source_path.c_str()); if (!dirp) return; while ((result = readdir(dirp))) { const std::string virtualName(result->d_name); // check for "." and ".." if (((virtualName[0] == '.') && (virtualName[1] == '/0')) || ((virtualName[0] == '.') && (virtualName[1] == '.') && (virtualName[2] == '/0'))) continue; std::string source, dest; source = source_path + virtualName; dest = dest_path + virtualName; if (IsDirectory(source)) { source += '/'; dest += '/'; if (!File::Exists(dest)) File::CreateFullPath(dest); CopyDir(source, dest); } else if (!File::Exists(dest)) File::Copy(source, dest); } closedir(dirp);#else ERROR_LOG(COMMON, "CopyDir not supported on this platform");#endif}
开发者ID:mailwl,项目名称:ppsspp,代码行数:38,
示例5: opendirvoid UserTable::GetDirectoryTree(const std::string& sPath, TPathList& rResults){ struct dirent* ent; DIR* dir; dir = opendir(sPath.c_str()); if (!dir) { syslog(LOG_WARNING, "could not open directory %s: %s", sPath.c_str(), strerror(errno)); return; } rResults.push_back(sPath); ent = readdir(dir); while (ent) { std::string sFullPath = sPath + "/" + ent->d_name; std::string sEntry(ent->d_name); if ("." != sEntry && ".." != sEntry && IsDirectory(sFullPath)) { GetDirectoryTree(sFullPath, rResults); } ent = readdir(dir); } closedir(dir);}
开发者ID:danfruehauf,项目名称:incron,代码行数:24,
示例6: set/*Removes a single directory passed in.Returns true on success, false on failure.On a failure, errno will be set (but may be of dubious quality)and an error logged.If the path does not exist, return immediately as success.if the path exists, but is not a directory, the behavior is currentlyto return immediately as success, but in the future might fail witherrno==ENOTDIR.This assumes that the top level directory requires an euid of condor toremove.*/static boolremove_spool_directory(const char * dir){ if ( ! IsDirectory(dir) ) { return true; } Directory spool_dir(dir); if( ! spool_dir.Remove_Entire_Directory() ) { dprintf(D_ALWAYS,"Failed to remove %s/n", dir); errno = EPERM; // Wild guess. return false; } TemporaryPrivSentry tps(PRIV_CONDOR); if( rmdir(dir) == 0 ) { return true; } // Save errno in case dprintf mangles. int tmp_errno = errno; if( errno != ENOENT ) { dprintf(D_ALWAYS,"Failed to remove %s: %s (errno %d)/n", dir, strerror(errno), errno ); } errno = tmp_errno; return false;}
开发者ID:AlanDeSmet,项目名称:htcondor,代码行数:37,
示例7: ValidatePath/*---------------------------------------------------------------------*/BOOL ValidatePath(CHAR * path, H_ARCHIVE harchive){ _archive[harchive].last_error = ARC_NO_ERROR; _archive_error = ARC_NO_ERROR; /* Check out the path */ if (path == NULL) _archive_error = ARC_BAD_PATH; if (strlen(path) > MAX_PATH_LEN - ARC_PATH_LEN) _archive_error = ARC_BAD_PATH; if (!IsDirectory(path)) _archive_error = ARC_BAD_PATH; if (_archive_error != ARC_NO_ERROR) return (FALSE); /* Fully qualify the path */ QualifyPath(_archive[harchive].path, path); return (TRUE);}
开发者ID:Fran89,项目名称:seiscomp3,代码行数:25,
示例8: EnsureBackslashPathSetbool CTGitPath::Delete(bool bTrash) const{ EnsureBackslashPathSet(); ::SetFileAttributes(m_sBackslashPath, FILE_ATTRIBUTE_NORMAL); bool bRet = false; if (Exists()) { if ((bTrash)||(IsDirectory())) { std::unique_ptr<TCHAR[]> buf(new TCHAR[m_sBackslashPath.GetLength() + 2]); _tcscpy_s(buf.get(), m_sBackslashPath.GetLength() + 2, m_sBackslashPath); buf[m_sBackslashPath.GetLength()] = 0; buf[m_sBackslashPath.GetLength()+1] = 0; bRet = CTGitPathList::DeleteViaShell(buf.get(), bTrash); } else { bRet = !!::DeleteFile(m_sBackslashPath); } } m_bExists = false; m_bExistsKnown = true; return bRet;}
开发者ID:KristinaTaylor,项目名称:TortoiseSI,代码行数:24,
示例9: CreateFullPath// Creates the full path of fullPath returns true on successbool CreateFullPath(const std::string& fullPath){ int panicCounter = 100; INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); if (Exists(fullPath)) { INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str()); return true; } size_t position = 0; while (true) { // Find next sub path position = fullPath.find(DIR_SEP_CHR, position); // we're done, yay! if (position == fullPath.npos) return true; // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") std::string const subPath(fullPath.substr(0, position + 1)); if (!IsDirectory(subPath)) File::CreateDir(subPath); // A safety check panicCounter--; if (panicCounter <= 0) { ERROR_LOG(COMMON, "CreateFullPath: directory structure is too deep"); return false; } position++; }}
开发者ID:Anti-Ultimate,项目名称:dolphin,代码行数:37,
示例10: Delete// Deletes a given filename, return true on success// Doesn't supports deleting a directorybool Delete(const std::string &filename){ INFO_LOG(COMMON, "Delete: file %s", filename.c_str()); // Return true because we care about the file no // being there, not the actual delete. if (!Exists(filename)) { WARN_LOG(COMMON, "Delete: %s does not exists", filename.c_str()); return true; } // We can't delete a directory if (IsDirectory(filename)) { WARN_LOG(COMMON, "Delete failed: %s is a directory", filename.c_str()); return false; }#ifdef _WIN32 if (!DeleteFile(ConvertUTF8ToWString(filename).c_str())) { WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg()); return false; }#else if (unlink(filename.c_str()) == -1) { WARN_LOG(COMMON, "Delete: unlink failed on %s: %s", filename.c_str(), GetLastErrorMsg()); return false; }#endif return true;}
开发者ID:AdmiralCurtiss,项目名称:ppsspp,代码行数:38,
示例11: MoveToDir//----------------------------------------------------------------------------------------nsresult nsFileSpec::MoveToDir(const nsFileSpec& inNewParentDirectory)//----------------------------------------------------------------------------------------{ // We can only copy into a directory, and (for now) can not copy entire directories if (inNewParentDirectory.IsDirectory() && (! IsDirectory() ) ) { char *leafname = GetLeafName(); nsSimpleCharString destPath(inNewParentDirectory.GetCString()); destPath += "//"; destPath += leafname; nsCRT::free(leafname); // MoveFile returns non-zero if succeeds int copyOK = MoveFile(GetCString(), destPath); if (copyOK) { *this = inNewParentDirectory + GetLeafName(); return NS_OK; } } return NS_FILE_FAILURE;} // nsFileSpec::MoveToDir
开发者ID:bringhurst,项目名称:vbox,代码行数:25,
示例12: InitHomeDirvoid InitHomeDir(void){ const std::string & home = Settings::GetHomeDir(); if(! home.empty()) { const std::string home_maps = home + SEPARATOR + std::string("maps"); const std::string home_files = home + SEPARATOR + std::string("files"); const std::string home_files_save = home_files + SEPARATOR + std::string("save"); if(! IsDirectory(home)) MKDIR(home.c_str()); if(IsDirectory(home, true) && ! IsDirectory(home_maps)) MKDIR(home_maps.c_str()); if(IsDirectory(home, true) && ! IsDirectory(home_files)) MKDIR(home_files.c_str()); if(IsDirectory(home_files, true) && ! IsDirectory(home_files_save)) MKDIR(home_files_save.c_str()); }}
开发者ID:asimonov-im,项目名称:fheroes2,代码行数:23,
示例13: ScanDirectoryTree// Scans the directory tree gets, starting from _Directory and adds the// results into parentEntry. Returns the number of files+directories foundu32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry){ INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str()); // How many files + directories we found u32 foundEntries = 0;#ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "//*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); return foundEntries; } // windows loop do { FSTEntry entry; const std::string virtualName(TStrToUTF8(ffd.cFileName));#else struct dirent dirent, *result = NULL; DIR *dirp = opendir(directory.c_str()); if (!dirp) return 0; // non windows loop while (!readdir_r(dirp, &dirent, &result) && result) { FSTEntry entry; const std::string virtualName(result->d_name);#endif // check for "." and ".." if (((virtualName[0] == '.') && (virtualName[1] == '/0')) || ((virtualName[0] == '.') && (virtualName[1] == '.') && (virtualName[2] == '/0'))) continue; entry.virtualName = virtualName; entry.physicalName = directory; entry.physicalName += DIR_SEP + entry.virtualName; if (IsDirectory(entry.physicalName.c_str())) { entry.isDirectory = true; // is a directory, lets go inside entry.size = ScanDirectoryTree(entry.physicalName, entry); foundEntries += (u32)entry.size; } else { // is a file entry.isDirectory = false; entry.size = GetSize(entry.physicalName.c_str()); } ++foundEntries; // Push into the tree parentEntry.children.push_back(entry); #ifdef _WIN32 } while (FindNextFile(hFind, &ffd) != 0); FindClose(hFind);#else } closedir(dirp);#endif // Return number of entries found. return foundEntries;}
开发者ID:john-peterson,项目名称:dolphin-emu,代码行数:69,
示例14: EditFile/* * EditFile - read a file into text */vi_rc EditFile( char *name, bool dammit ){ char *fn, **list, *currfn; int i, cnt, ocnt; int j, len; window_id wn = NO_WINDOW; char cdir[FILENAME_MAX]; info *ci, *il; bool usedir = false; char mask[FILENAME_MAX]; bool reset_dir; int index; char *altname = NULL; vi_rc rc; fn = MemAlloc( FILENAME_MAX ); /* * get file name */ strcpy( cdir, CurrentDirectory ); reset_dir = false; RemoveLeadingSpaces( name ); if( name[0] == '$' ) { EliminateFirstN( name, 1 ); usedir = true; } fn[0] = 0;// if( NextWord1( name, fn ) <= 0 ) if( GetStringWithPossibleQuote2( name, fn, false ) != ERR_NO_ERR ) { usedir = true; mask[0] = '*'; mask[1] = 0; } if( usedir ) { if( EditFlags.ExMode ) { MemFree( fn ); return( ERR_INVALID_IN_EX_MODE ); } len = strlen( fn ); if( len > 0 ) { i = len - 1; strcpy( mask, fn ); cnt = 0; while( i >= 0 ) { if( fn[i] == FILE_SEP ) { for( j = i + 1; j <= len; j++ ) { mask[j - (i + 1)] = fn[j]; } cnt = i; break; } i--; } fn[cnt] = 0; } if( fn[0] != 0 ) { rc = SelectFileOpen( fn, &fn, mask, true ); } else {#ifdef __WIN__ if( name[0] == '/0' ) { altname = MemAlloc( 1000 ); rc = SelectFileOpen( CurrentDirectory, &altname, mask, true ); NextWord1( altname, fn ); // if multiple, kill path if( isMultipleFiles( altname ) ) { NextWord1( altname, fn ); // get 1st name } } else { rc = SelectFileOpen( CurrentDirectory, &fn, mask, true ); }#else rc = SelectFileOpen( CurrentDirectory, &fn, mask, true );#endif } if( altname ) { name = altname; } if( rc != ERR_NO_ERR || fn[0] == 0 ) { MemFree( fn ); SetCWD( cdir ); return( rc ); } } /* * loop through all files */ rc = ERR_NO_ERR; EditFlags.WatchForBreak = true;#ifdef __WIN__ ToggleHourglass( true );#endif do { if( IsDirectory( fn ) ) { if( EditFlags.ExMode ) { rc = ERR_INVALID_IN_EX_MODE;//.........这里部分代码省略.........
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:101,
示例15: TEST_NFILEUTILITIES};//============================================================================// Test case//----------------------------------------------------------------------------TEST_NFILEUTILITIES("Directories"){ // Perform the test theFile = NFileUtilities::GetDirectory(kNLocationHome); REQUIRE(theFile.IsDirectory()); theFile = NFileUtilities::GetDirectory(kNLocationDesktop); REQUIRE(theFile.IsDirectory()); theFile = NFileUtilities::GetDirectory(kNLocationPreferences); REQUIRE(theFile.IsDirectory()); theFile = NFileUtilities::GetCWD(); REQUIRE(theFile.IsDirectory());}
开发者ID:x414e54,项目名称:nano,代码行数:26,
示例16: CompletePathint CompletePath(const char *Base, char *Match, int Count) { char Name[MAXPATH]; const char *dirp; char *namep; int len, count = 0; char cname[MAXPATH]; int hascname = 0; RxMatchRes RM; FileFind *ff; FileInfo *fi; int rc; if (strcmp(Base, "") == 0) { if (ExpandPath(".", Name, sizeof(Name)) != 0) return -1; } else { if (ExpandPath(Base, Name, sizeof(Name)) != 0) return -1; }// SlashDir(Name); dirp = Name; namep = SepRChr(Name); if (namep == Name) { dirp = SSLASH; namep = Name + 1; } else if (namep == NULL) { namep = Name; dirp = SDOT; } else { *namep = 0; namep++; } len = strlen(namep); strcpy(Match, dirp); SlashDir(Match); cname[0] = 0; ff = new FileFind(dirp, "*", ffDIRECTORY | ffHIDDEN#if defined(USE_DIRENT) | ffFAST // for SPEED#endif ); if (ff == 0) return 0; rc = ff->FindFirst(&fi); while (rc == 0) { const char *dname = fi->Name(); // filter out unwanted files if ((strcmp(dname, ".") != 0) && (strcmp(dname, "..") != 0) && (!CompletionFilter || RxExec(CompletionFilter, dname, strlen(dname), dname, &RM) != 1)) { if ((#if defined(UNIX) strncmp#else // os2, nt, ... strnicmp#endif (namep, dname, len) == 0) && (dname[0] != '.' || namep[0] == '.')) { count++; if (Count == count) { Slash(Match, 1); strcat(Match, dname); if (#if defined(USE_DIRENT) // for SPEED IsDirectory(Match)#else fi->Type() == fiDIRECTORY#endif ) Slash(Match, 1); } else if (Count == -1) { if (!hascname) { strcpy(cname, dname); hascname = 1; } else { int o = 0;#ifdef UNIX while (cname[o] && dname[o] && (cname[o] == dname[o])) o++;#endif#if defined(OS2) || defined(NT) while (cname[o] && dname[o] && (toupper(cname[o]) == toupper(dname[o]))) o++;#endif cname[o] = 0; } } } } delete fi; rc = ff->FindNext(&fi); } delete ff; if (Count == -1) { Slash(Match, 1); strcat(Match, cname); if (count == 1) SlashDir(Match); } return count;//.........这里部分代码省略.........
开发者ID:dmcbride,项目名称:efte,代码行数:101,
示例17: DVASSERTFileList::FileList(const FilePath & filepath){ DVASSERT(filepath.IsDirectoryPathname()); path = filepath;// Windows version#if defined(__DAVAENGINE_WIN32__) //char tmp[_MAX_PATH]; //_getcwd(tmp, _MAX_PATH); //Path = tmp; FilePath prevDir = FileSystem::Instance()->GetCurrentWorkingDirectory(); BOOL res = SetCurrentDirectoryA(path.GetAbsolutePathname().c_str()); if (res) { struct _finddata_t c_file; intptr_t hFile; FileEntry entry; if( (hFile = _findfirst( "*", &c_file )) != -1L ) { do { //TODO: need to check for Win32 entry.path = filepath + c_file.name; entry.name = c_file.name; entry.size = c_file.size; entry.isDirectory = (_A_SUBDIR & c_file.attrib) != 0; if(entry.isDirectory) { entry.path.MakeDirectoryPathname(); } fileList.push_back(entry); //Logger::FrameworkDebug("filelist: %s %s", filepath.c_str(), entry.name.c_str()); } while( _findnext( hFile, &c_file ) == 0 ); _findclose( hFile ); } } FileSystem::Instance()->SetCurrentWorkingDirectory(prevDir); //TODO add drives //entry.Name = "E://"; //entry.isDirectory = true; //Files.push_back(entry);#elif defined(__DAVAENGINE_MACOS__) || defined(__DAVAENGINE_IPHONE__) || defined (__DAVAENGINE_ANDROID__) struct dirent **namelist; FileEntry entry;#if defined (__DAVAENGINE_ANDROID__) int32 n = scandir(path.GetAbsolutePathname().c_str(), &namelist, 0, alphasortAndroid);#else //#if defined (__DAVAENGINE_ANDROID__) int32 n = scandir(path.GetAbsolutePathname().c_str(), &namelist, 0, alphasort);#endif //#if defined (__DAVAENGINE_ANDROID__) if (n >= 0) { while(n--) { entry.path = path + namelist[n]->d_name; entry.name = namelist[n]->d_name; entry.size = 0; entry.isDirectory = namelist[n]->d_type == DT_DIR; if(entry.isDirectory) { entry.path.MakeDirectoryPathname(); } fileList.push_back(entry); free(namelist[n]); } free(namelist); }#endif //PLATFORMS directoryCount = 0; fileCount = 0; for (int fi = 0; fi < GetCount(); ++fi) { if (IsDirectory(fi)) { if (!IsNavigationDirectory(fi)) directoryCount++; }else fileCount++; }}
开发者ID:droidenko,项目名称:dava.framework,代码行数:90,
示例18: recurse_compilevoid recurse_compile( string basedir, vector<string>* files ){ long s_compiled, s_uptodate, s_errors; clock_t start, finish; if ( !IsDirectory( basedir.c_str() ) ) return; s_compiled = s_uptodate = s_errors = 0; start = clock(); for( DirList dl( basedir.c_str() ); !dl.at_end(); dl.next() ) { string name = dl.name(), ext; if (name[0] == '.') continue; string::size_type pos = name.rfind("."); if (pos != string::npos) ext = name.substr(pos); try { if ( pos != string::npos && (!ext.compare(".src") || !ext.compare(".hsr") || (compilercfg.CompileAspPages && !ext.compare(".asp"))) ) { s_compiled++; if (files==NULL) { if (compile_file( (basedir + name).c_str() )) { ++summary.CompiledScripts; } else { ++s_uptodate; ++summary.UpToDateScripts; } } else files->push_back((basedir + name)); } else { recurse_compile( basedir + name + "/", files ); } } catch( std::exception& ) { ++summary.CompiledScripts; ++summary.ScriptsWithCompileErrors; if (!keep_building) throw; s_errors++; } } if (files==NULL) return; finish = clock(); if ( (!quiet || timing_quiet_override) && show_timing_details && s_compiled > 0 && files==NULL) { cout << "Compiled " << s_compiled << " script" << (s_compiled==1?"":"s") << " in " << basedir << " in " << (long)((finish-start)/CLOCKS_PER_SEC) << " second(s)" << endl; if ( s_uptodate > 0 ) cout << " " << s_uptodate << " script" << (s_uptodate==1?" was":"s were") << " already up-to-date." << endl; if ( s_errors > 0 ) cout << " " << s_errors << " script" << (s_errors==1?"":"s") << " had errors." << endl; }}
开发者ID:alucardxlx,项目名称:polserver-zulu,代码行数:73,
示例19: main//.........这里部分代码省略......... std::cerr << "There should be a positive number after -d option." << std::endl; PrintInfo(); return 1; } } break; case 'q': std::cout.setstate(std::ios::failbit); is_verbose = false; break; case 'v': std::cout.clear(); is_verbose = true; break; case '-': if (STRCMP(argv[i] + j + 1, "fastmode") == 0) { j += 7; argv[i][j + 1] = 'f'; } else if (STRCMP(argv[i] + j + 1, "iteration") == 0) { j += 8; argv[i][j + 1] = 'i'; } else if (STRCMP(argv[i] + j + 1, "max_depth") == 0) { j += 8; argv[i][j + 1] = 'd'; } else if (STRCMP(argv[i] + j + 1, "quiet") == 0) { j += 4; argv[i][j + 1] = 'q'; } else if (STRCMP(argv[i] + j + 1, "verbose") == 0) { j += 6; argv[i][j + 1] = 'v'; } else if (STRCMP(argv[i] + j + 1, "keep-exif") == 0) { j += 9; Jpeg::keep_exif = true; } else {#ifdef _WIN32 char mbs[64] = { 0 }; WideCharToMultiByte(CP_ACP, 0, argv[i] + j + 1, -1, mbs, sizeof(mbs) - 1, nullptr, nullptr); std::cerr << "Unknown option: " << mbs << std::endl;#else std::cerr << "Unknown option: " << argv[i] + j + 1 << std::endl;#endif // _WIN32 PrintInfo(); return 1; } break; default: std::cerr << "Unknown option: " << (char)argv[i][j] << std::endl; PrintInfo(); return 1; } } i += num_optargs; } if (i == argc) { std::cerr << "No file path provided." << std::endl; PrintInfo(); return 1; } std::cout << std::fixed; std::cout.precision(2); // support multiple input file do { if (IsDirectory(argv[i])) { // directory TraverseDirectory(argv[i], ProcessFile); } else { // file ProcessFile(argv[i]); } } while (++i < argc); PauseIfNotTerminal(); return 0;}
开发者ID:MohammedRaji,项目名称:Leanify,代码行数:101,
示例20: ATLASSERTCString CTSVNPath::GetFilename() const{ ATLASSERT(!IsDirectory()); return GetFileOrDirectoryName();}
开发者ID:yuexiaoyun,项目名称:tortoisesvn,代码行数:5,
示例21: dprintf//.........这里部分代码省略......... ASSERT (cgroup != NULL); fi.cgroup = cgroup; dprintf(D_FULLDEBUG, "Requesting cgroup %s for job./n", cgroup); }#endif// The chroot stuff really only works on linux#ifdef LINUX { // Have Condor manage a chroot std::string requested_chroot_name; JobAd->EvalString("RequestedChroot", NULL, requested_chroot_name); const char * allowed_root_dirs = param("NAMED_CHROOT"); if (requested_chroot_name.size()) { dprintf(D_FULLDEBUG, "Checking for chroot: %s/n", requested_chroot_name.c_str()); StringList chroot_list(allowed_root_dirs); chroot_list.rewind(); const char * next_chroot; bool acceptable_chroot = false; std::string requested_chroot; while ( (next_chroot=chroot_list.next()) ) { MyString chroot_spec(next_chroot); chroot_spec.Tokenize(); const char * chroot_name = chroot_spec.GetNextToken("=", false); if (chroot_name == NULL) { dprintf(D_ALWAYS, "Invalid named chroot: %s/n", chroot_spec.Value()); } const char * next_dir = chroot_spec.GetNextToken("=", false); if (chroot_name == NULL) { dprintf(D_ALWAYS, "Invalid named chroot: %s/n", chroot_spec.Value()); } dprintf(D_FULLDEBUG, "Considering directory %s for chroot %s./n", next_dir, chroot_spec.Value()); if (IsDirectory(next_dir) && chroot_name && (strcmp(requested_chroot_name.c_str(), chroot_name) == 0)) { acceptable_chroot = true; requested_chroot = next_dir; } } // TODO: path to chroot MUST be all root-owned, or we have a nice security exploit. // Is this the responsibility of Condor to check, or the sysadmin who set it up? if (!acceptable_chroot) { return FALSE; } dprintf(D_FULLDEBUG, "Will attempt to set the chroot to %s./n", requested_chroot.c_str()); std::stringstream ss; std::stringstream ss2; ss2 << Starter->GetExecuteDir() << DIR_DELIM_CHAR << "dir_" << getpid(); std::string execute_dir = ss2.str(); ss << requested_chroot << DIR_DELIM_CHAR << ss2.str(); std::string full_dir_str = ss.str(); if (is_trivial_rootdir(requested_chroot)) { dprintf(D_FULLDEBUG, "Requested a trivial chroot %s; this is a no-op./n", requested_chroot.c_str()); } else if (IsDirectory(execute_dir.c_str())) { { TemporaryPrivSentry sentry(PRIV_ROOT); if( mkdir(full_dir_str.c_str(), S_IRWXU) < 0 ) { dprintf( D_FAILURE|D_ALWAYS, "Failed to create sandbox directory in chroot (%s): %s/n", full_dir_str.c_str(), strerror(errno) ); return FALSE; } if (chown(full_dir_str.c_str(), get_user_uid(), get_user_gid()) == -1)
开发者ID:AlainRoy,项目名称:htcondor,代码行数:67,
示例22: find_depsvoid find_deps(const string& loc, GLEInterface* iface) { vector<GLEFindEntry*> tofind; vector<string*> result; string gle_paths = ";"; ConfigCollection* collection = iface->getConfig()->getRCFile();#ifdef __WIN32__ GLEFindEntry* findGLE = new GLEFindEntry(&gle_paths); findGLE->addToFind("gle.exe"); findGLE->addToFind("gle_ps.exe"); tofind.push_back(findGLE);#endif // Create GLEFindEntry for each tool (ghostscript, pdflatex, ...) ConfigSection* tools = collection->getSection(GLE_CONFIG_TOOLS); for (int j = 0; j <= GLE_TOOL_GHOSTSCRIPT_LIB; j++) { CmdLineArgString* strarg = (CmdLineArgString*)tools->getOption(j)->getArg(0); GLEFindEntry* findTool = new GLEFindEntry(strarg->getValuePtr()); char_separator separator(",", ";"); tokenizer<char_separator> tokens(strarg->getDefault(), separator); while (tokens.has_more()) { const string& toolName = tokens.next_token(); if (toolName == ";") { if (tokens.has_more() && strarg->isDefault()) { findTool->setNotFound(tokens.next_token()); } break; } else { if (!IsAbsPath(toolName)) { findTool->addToFind(toolName); } } } if (findTool->getNbFind() != 0) tofind.push_back(findTool); else delete findTool; } // Initialize output and progress indicator GLEOutputStream* output = iface->getOutput(); ostringstream out1; out1 << "Running GLE -finddeps /""; out1 << loc; out1 << ("/" to locate installed software (e.g., Ghostscript and LaTeX): "); output->println(out1.str().c_str()); GLEProgressIndicatorInterface progress(iface); // Perform search at specified location if (loc != "") { if (IsDirectory(loc, true)) { GLEFindFiles(loc, tofind, &progress); for (unsigned int i = 0; i < tofind.size(); i++) { tofind[i]->updateResult(false); } } else { // Name of old GLERC file given if (try_load_config(loc)) { // Override old version number collection->setStringValue(GLE_CONFIG_GLE, GLE_CONFIG_GLE_VERSION, GLEVN); } else { ostringstream err; err << "Can't load configuration from '" << loc << "'" << endl; output->println(err.str().c_str()); } } } #ifdef __UNIX__ // Find programs in search path on Unix GLEFindPrograms(tofind, &progress); #endif #ifdef __MACOS__ // Search for frameworks on Mac GLEFindFiles(string("/Library/Frameworks"), tofind, &progress); string home = GetHomeDir(); if (home != "") { home += "Library/Frameworks"; GLEFindFiles(home, tofind, &progress); } #endif for (unsigned int i = 0; i < tofind.size(); i++) { tofind[i]->updateResult(true); } #ifdef __UNIX__ // Search for libraries in typical directories and in LD_LIBRARY_PATH string gslibloc = GLEFindLibrary("libgs", &progress); if (gslibloc != "") { CmdLineArgString* gslib_stra = (CmdLineArgString*)tools->getOption(GLE_TOOL_GHOSTSCRIPT_LIB)->getArg(0); gslib_stra->setValue(gslibloc.c_str()); } #endif output->println(); // Write installed GLE's to config section ConfigSection* gle = collection->getSection(GLE_CONFIG_GLE); CmdLineArgSPairList* installs = (CmdLineArgSPairList*)gle->getOption(GLE_CONFIG_GLE_INSTALL)->getArg(0); char_separator separator(";", ""); tokenizer<char_separator> tokens(gle_paths, separator); while (tokens.has_more()) { string path = tokens.next_token(); if (path.length() > 0 && !installs->hasValue2(path)) { installs->addPair("?", path); } } // Find versions of installed GLEs and set value of gleexe ostringstream out; string gle_version = GLEVN;//.........这里部分代码省略.........
开发者ID:pnkfelix,项目名称:glx-gle,代码行数:101,
示例23: _T/* Determine where data folder is situated and store it's path into DataFolder member*/void CSettings::FindDataFolder(){ AppParams* params = AppParams::instance(); if (IsDirectory(WinUtils::GetAppFolder() + _T("Data"))) { DataFolder = WinUtils::GetAppFolder() + _T("Data//"); SettingsFolder = IuCoreUtils::WstringToUtf8(static_cast<LPCTSTR>(DataFolder)); params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "//", "/")); params->setSettingsDirectory(IuStringUtils::Replace(SettingsFolder, "//", "/")); IsPortable = true; return; } SettingsFolder = IuCoreUtils::WstringToUtf8(static_cast<LPCTSTR>(GetApplicationDataPath() + _T("Image Uploader//"))); params->setSettingsDirectory(IuStringUtils::Replace(SettingsFolder, "//", "/")); #if !defined(IU_SERVERLISTTOOL) && !defined (IU_CLI) && !defined(IU_SHELLEXT) { CRegistry Reg; CString lang; Reg.SetRootKey(HKEY_CURRENT_USER); if (Reg.SetKey("Software//Zenden.ws//Image Uploader", false)) { CString dir = Reg.ReadString("DataPath"); if (!dir.IsEmpty() && IsDirectory(dir)) { DataFolder = dir; params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "//", "/")); return; } } } { CRegistry Reg; Reg.SetRootKey(HKEY_LOCAL_MACHINE); if (Reg.SetKey("Software//Zenden.ws//Image Uploader", false)) { CString dir = Reg.ReadString("DataPath"); if (!dir.IsEmpty() && IsDirectory(dir)) { DataFolder = dir; params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "//", "/")); return; } } } if (FileExists(GetCommonApplicationDataPath() + SETTINGS_FILE_NAME)) { DataFolder = GetCommonApplicationDataPath() + _T("Image Uploader//"); params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "//", "/")); } else #endif { DataFolder = GetApplicationDataPath() + _T("Image Uploader//"); params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "//", "/")); }}
开发者ID:vladios13,项目名称:image-uploader,代码行数:66,
示例24: FindDataFolderCSettings::CSettings(){#if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) IsPortable = false; FindDataFolder(); if (!IsDirectory(DataFolder)) { CreateDirectory(DataFolder, 0); } if (!IsDirectory(IuCoreUtils::Utf8ToWstring(SettingsFolder).c_str())) { CreateDirectory(IuCoreUtils::Utf8ToWstring(SettingsFolder).c_str(), 0); } BOOL isElevated = false; IsElevated(&isElevated); if ( isElevated || CmdLine.IsOption(L"afterupdate")) { WinUtils::MakeDirectoryWritable(DataFolder); }#endif#if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) CString copyFrom = WinUtils::GetAppFolder() + SETTINGS_FILE_NAME; CString copyTo = DataFolder + SETTINGS_FILE_NAME; if (FileExists(copyFrom) && !FileExists(copyTo)) { MoveFile(copyFrom, copyTo); } // Default values of settings ExplorerCascadedMenu = true; ConnectionSettings.UseProxy = FALSE; ConnectionSettings.ProxyPort = 0; ConnectionSettings.NeedsAuth = false; ConnectionSettings.ProxyType = 0; #endif LastUpdateTime = 0; UploadBufferSize = /*65536*/1024*1024; FileRetryLimit = 3; ActionRetryLimit = 2;#if !defined(IU_SHELLEXT) && !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) if ( !IsFFmpegAvailable() ){ VideoSettings.Engine = VideoEngineDirectshow; } WatchClipboard = true; ShowTrayIcon = false; ShowTrayIcon_changed = false; *m_Directory = 0; UseTxtTemplate = false; UseDirectLinks = true; CodeLang = 0; ConfirmOnExit = 1; ExplorerContextMenu = false; ExplorerVideoContextMenu = true; ExplorerContextMenu_changed = false; ThumbsPerLine = 4; SendToContextMenu_changed = false; SendToContextMenu = 0; QuickUpload = 1; ParseSubDirs = 1; UseNewIcon = false; RememberImageServer = true; RememberFileServer = true; ShowUploadErrorDialog = true; ImageEditorPath = _T("mspaint.exe /"%1/""); AutoCopyToClipboard = false; AutoShowLog = true; // StringToFont(_T("Tahoma,7,b,204"), &ThumbSettings.ThumbFont); StringToFont(_T("Tahoma,8,,204"), &VideoSettings.Font); /*ThumbSettings.CreateThumbs = true; ThumbSettings.ThumbWidth = 180; ThumbSettings.ThumbHeight = 140; ThumbSettings.DrawFrame = true; ThumbSettings.ThumbAddImageSize = true; ThumbSettings.FrameColor = RGB( 0, 74, 111); ThumbSettings.BackgroundColor = RGB( 255, 255, 255);f ThumbSettings.ThumbColor1 = RGB( 13, 86, 125); ThumbSettings.ThumbColor2 = RGB( 6, 174, 255); ThumbSettings.UseServerThumbs = false; ThumbSettings.ScaleByHeight = false; ThumbSettings.ThumbTextColor = RGB( 255, 255, 255); ThumbSettings.ThumbAlpha = 120; ThumbSettings.Text = _T("%width%x%height% (%size%)"); ThumbSettings.Format = ThumbCreatingParams::tfJPEG; ThumbSettings.FileName = "default"; ThumbSettings.Quality = 85;*/ VideoSettings.Columns = 3; VideoSettings.TileWidth = 200; VideoSettings.GapWidth = 5; VideoSettings.GapHeight = 7; VideoSettings.NumOfFrames = 8; VideoSettings.JPEGQuality = 100; VideoSettings.UseAviInfo = TRUE;//.........这里部分代码省略.........
开发者ID:vladios13,项目名称:image-uploader,代码行数:101,
示例25: RfsdCleanup//.........这里部分代码省略......... } Ccb = (PRFSD_CCB) FileObject->FsContext2; if (!Ccb) { Status = STATUS_SUCCESS; _SEH2_LEAVE; } if (IsFlagOn(FileObject->Flags, FO_CLEANUP_COMPLETE)) { if ( IsFlagOn(FileObject->Flags, FO_FILE_MODIFIED) && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK) && !IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED) ) { Status = RfsdFlushFile(Fcb); } _SEH2_LEAVE; } ASSERT((Ccb->Identifier.Type == RFSDCCB) && (Ccb->Identifier.Size == sizeof(RFSD_CCB))); Irp = IrpContext->Irp; Fcb->OpenHandleCount--; if (!IsFlagOn(FileObject->Flags, FO_CACHE_SUPPORTED )) { Fcb->NonCachedOpenCount--; } Vcb->OpenFileHandleCount--; if (IsFlagOn(Fcb->Flags, FCB_DELETE_ON_CLOSE)) { SetFlag(Fcb->Flags, FCB_DELETE_PENDING); if (IsDirectory(Fcb)) { FsRtlNotifyFullChangeDirectory( Vcb->NotifySync, &Vcb->NotifyList, Fcb, NULL, FALSE, FALSE, 0, NULL, NULL, NULL ); } } if (IsDirectory(Fcb)) { FsRtlNotifyCleanup( Vcb->NotifySync, &Vcb->NotifyList, Ccb ); } else { // // Drop any byte range locks this process may have on the file. // FsRtlFastUnlockAll( &Fcb->FileLockAnchor, FileObject, IoGetRequestorProcess(Irp), NULL );
开发者ID:GYGit,项目名称:reactos,代码行数:67,
示例26: DeleteDirRecursively// Deletes the given directory and anything under it. Returns true on success.bool DeleteDirRecursively(const std::string &directory){ INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str());#ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "//*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); return false; } // windows loop do { const std::string virtualName(TStrToUTF8(ffd.cFileName));#else struct dirent dirent, *result = NULL; DIR *dirp = opendir(directory.c_str()); if (!dirp) return false; // non windows loop while (!readdir_r(dirp, &dirent, &result) && result) { const std::string virtualName = result->d_name;#endif // check for "." and ".." if (((virtualName[0] == '.') && (virtualName[1] == '/0')) || ((virtualName[0] == '.') && (virtualName[1] == '.') && (virtualName[2] == '/0'))) continue; std::string newPath = directory + DIR_SEP_CHR + virtualName; if (IsDirectory(newPath)) { if (!DeleteDirRecursively(newPath)) { #ifndef _WIN32 closedir(dirp); #endif return false; } } else { if (!File::Delete(newPath)) { #ifndef _WIN32 closedir(dirp); #endif return false; } }#ifdef _WIN32 } while (FindNextFile(hFind, &ffd) != 0); FindClose(hFind);#else } closedir(dirp);#endif File::DeleteDir(directory); return true;}
开发者ID:john-peterson,项目名称:dolphin-emu,代码行数:72,
示例27: IsDirectory//--------------------------------------------------------------------------------bool CDirectory::Exists() { return IsDirectory(GetPath()); }
开发者ID:richschonthal,项目名称:Security-Server,代码行数:5,
示例28: RemoveNewShadowDroppingsvoid RemoveNewShadowDroppings(char *cluster, char *proc){ char names[2][1024]; int j; char *ckpt_name; char *myspool; struct stat buf; int clusternum, procnum; memset(&names[0], 0, 1024); memset(&names[1], 0, 1024); /* XXX I'm sorry. There are some incompatibilities between the new shadow and the old shadow. The new shadow now makes a _directory_ with the usual ckeckpoint name because there might eventually be more than one file that has to get checkpointed with a job. The old shadow is dumb, and it only makes a _file_ named the usual checkpoint name. So a contention happens when we are using opsys/arch to choose an executable name for both NT and UNIX between vanilla only jobs and standard universe jobs. What happens is that the old shadow gets back a correct stat() on the new shadow created directory but misinterprets it as a file and hilarity ensues. So, my nasty hack is to make the old shadow determine if the file it found is actually a directory and if so, then remove it and everything underneath it. I somehow feel that this might bite us in the ass in the future, so each time the shadow does this, it logs it so a human can figure out what happened. I don't have to worry about the converse issue of a new shadow starting up with an old file-based checkpoint because whomever adds standard universe support to the new shadow will have to do something intelligent, and our submit program places expressions into the requirements attribute in the job forcing a checkpointed job to always run on the architecture it checkpointed on. -psilord 7/30/01 */ myspool = param("SPOOL"); if (myspool == NULL) { EXCEPT ("RemoveNewShadowDroppings(): No Spool directory!?!/n"); } clusternum = atoi(cluster); procnum = atoi(proc); if (clusternum < 0 || procnum < 0) /* sanity checks */ { dprintf(D_ALWAYS, "RemoveNewShadowDroppings(): Asked to deal with " "negative cluster or proc numbers. Ignoring./n"); free(myspool); return; } ckpt_name = gen_ckpt_name( myspool, clusternum, procnum, 0 ); strcpy(names[0], ckpt_name); strcpy(names[1], ckpt_name); strcat(names[1], ".tmp"); free(ckpt_name); ckpt_name = NULL; for (j = 0; j < 2; j++) { if (stat(names[j], &buf) == 0) { /* ok, we have a hit, let's see if it is a directory... */ if (IsDirectory(names[j]) == true) { /* it is, so blow away everything inside it */ { Directory todd_droppings(names[j]); if (todd_droppings.Remove_Entire_Directory() == false) { dprintf(D_ALWAYS, "RemoveNewShadowDroppings(): Old " "shadow failed to remove new shadow ckpt directory " "contents: %s/n", names[j]); } } /* now delete the directory itself */ if (rmdir(names[j]) < 0 && errno != ENOENT) { dprintf(D_ALWAYS, "RemoveNewShadowDroppings(): Old shadow " "failed to remove new shadow ckpt directory: %s (%s)/n", names[j], strerror(errno)); } else { dprintf(D_ALWAYS, "RemoveNewShadowDroppings(): Old shadow " "removed new shadow ckpt directory: %s/n", names[j]); } } } } free(myspool);}
开发者ID:zhangzhehust,项目名称:htcondor,代码行数:92,
示例29: Ext2ReadFile//.........这里部分代码省略......... __leave; } MainResourceAcquired = TRUE; } else { if (!ExAcquireResourceSharedLite( &Fcb->MainResource, IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) { Status = STATUS_PENDING; __leave; } MainResourceAcquired = TRUE; } if (!FsRtlCheckLockForReadAccess( &Fcb->FileLockAnchor, Irp )) { Status = STATUS_FILE_LOCK_CONFLICT; __leave; } } if ((ByteOffset.QuadPart + (LONGLONG)Length) > Fcb->Header.FileSize.QuadPart) { if (ByteOffset.QuadPart >= Fcb->Header.FileSize.QuadPart) { Irp->IoStatus.Information = 0; Status = STATUS_END_OF_FILE; __leave; } ReturnedLength = (ULONG)(Fcb->Header.FileSize.QuadPart - ByteOffset.QuadPart); } if (!IsDirectory(Fcb) && Ccb != NULL) { Status = FsRtlCheckOplock( &Fcb->Oplock, Irp, IrpContext, Ext2OplockComplete, Ext2LockIrp ); if (Status != STATUS_SUCCESS) { OpPostIrp = TRUE; __leave; } // // Set the flag indicating if Fast I/O is possible // Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb); } if (!Nocache) { if (IsDirectory(Fcb)) { __leave; } if (FileObject->PrivateCacheMap == NULL) { CcInitializeCacheMap( FileObject, (PCC_FILE_SIZES)(&Fcb->Header.AllocationSize), FALSE, &Ext2Global->CacheManagerCallbacks, Fcb );
开发者ID:jrfl,项目名称:ext2fsd,代码行数:67,
注:本文中的IsDirectory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ IsDisabled函数代码示例 C++ IsDir函数代码示例 |