这篇教程C++ EnsureDirectoryExists函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EnsureDirectoryExists函数的典型用法代码示例。如果您正苦于以下问题:C++ EnsureDirectoryExists函数的具体用法?C++ EnsureDirectoryExists怎么用?C++ EnsureDirectoryExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EnsureDirectoryExists函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: NS_ASSERTIONnsresultnsXREDirProvider::SetProfile(nsIFile* aDir, nsIFile* aLocalDir){ NS_ASSERTION(aDir && aLocalDir, "We don't support no-profile apps yet!"); nsresult rv; rv = EnsureDirectoryExists(aDir); if (NS_FAILED(rv)) return rv; rv = EnsureDirectoryExists(aLocalDir); if (NS_FAILED(rv)) return rv;#ifdef XP_MACOSX bool same; if (NS_SUCCEEDED(aDir->Equals(aLocalDir, &same)) && !same) { // Ensure that the cache directory is not indexed by Spotlight // (bug 718910). At least on OS X, the cache directory (under // ~/Library/Caches/) is always the "local" user profile // directory. This is confusing, since *both* user profile // directories are "local" (they both exist under the user's // home directory). But this usage dates back at least as far // as the patch for bug 291033, where "local" seems to mean // "suitable for temporary storage". Don't hide the cache // directory if by some chance it and the "non-local" profile // directory are the same -- there are bad side effects from // hiding a profile directory under /Library/Application Support/ // (see bug 801883). nsAutoCString cacheDir; if (NS_SUCCEEDED(aLocalDir->GetNativePath(cacheDir))) { if (chflags(cacheDir.get(), UF_HIDDEN)) { NS_WARNING("Failed to set Cache directory to HIDDEN."); } } }#endif mProfileDir = aDir; mProfileLocalDir = aLocalDir; return NS_OK;}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:43,
示例2: NS_ASSERTIONnsresultnsXREDirProvider::SetProfile(nsIFile* aDir, nsIFile* aLocalDir){ NS_ASSERTION(aDir && aLocalDir, "We don't support no-profile apps yet!"); nsresult rv; rv = EnsureDirectoryExists(aDir); if (NS_FAILED(rv)) return rv; rv = EnsureDirectoryExists(aLocalDir); if (NS_FAILED(rv)) return rv; mProfileDir = aDir; mProfileLocalDir = aLocalDir; return NS_OK;}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:19,
示例3: EnsureDirectoryExists // This takes all the names of all the files in baseFilenames and places each // in a FilenameTriple with inputSuffix appended as the input filename, with // placeholderSuffix appended as the placeholder filename, replacing the // directory path with placeholderDirectory, and with outputSuffix appended // as the output file, replacing the directory path with outputDirectory. inline void FilePlaceholderManager::PrepareFilenames( std::vector< std::string > const& baseFilenames, std::string const inputDirectory, std::string const& placeholderDirectory, std::string const& outputDirectory ) { filenameTriples.clear(); EnsureDirectoryExists( placeholderDirectory ); EnsureDirectoryExists( outputDirectory ); for( std::vector< std::string >::const_iterator baseFilename( baseFilenames.begin() ); baseFilenames.end() > baseFilename; ++baseFilename ) { currentTriple.inputFile.assign( inputDirectory + "/" + (*baseFilename) + inputSuffix ); currentTriple.placeholderFile.assign( placeholderDirectory + "/" + (*baseFilename) + placeholderSuffix ); currentTriple.outputFile.assign( outputDirectory + "/" + (*baseFilename) + outputSuffix ); filenameTriples.push_back( currentTriple ); } whichTriple = filenameTriples.begin(); }
开发者ID:benoleary,项目名称:VevaciousPlusPlus,代码行数:29,
示例4: GetUserDataDirectoryHomensresultnsXREDirProvider::GetSysUserExtensionsDirectory(nsIFile** aFile){ nsCOMPtr<nsIFile> localDir; nsresult rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), false); NS_ENSURE_SUCCESS(rv, rv); rv = AppendSysUserExtensionPath(localDir); NS_ENSURE_SUCCESS(rv, rv); rv = EnsureDirectoryExists(localDir); NS_ENSURE_SUCCESS(rv, rv); localDir.forget(aFile); return NS_OK;}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:16,
示例5: GetUserDataDirectoryHomensresultnsXREDirProvider::GetUserDataDirectory(nsILocalFile** aFile, bool aLocal){ nsCOMPtr<nsILocalFile> localDir; nsresult rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), aLocal); NS_ENSURE_SUCCESS(rv, rv); rv = AppendProfilePath(localDir); NS_ENSURE_SUCCESS(rv, rv);#ifdef DEBUG_jungshik nsCAutoString cwd; localDir->GetNativePath(cwd); printf("nsXREDirProvider::GetUserDataDirectory: %s/n", cwd.get());#endif rv = EnsureDirectoryExists(localDir); NS_ENSURE_SUCCESS(rv, rv); NS_ADDREF(*aFile = localDir); return NS_OK;}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:21,
示例6: GetOutputDirstatic FileOutputStream *InitialiseIO (const HashTable * const config_p, const char * const key_s, const char * const suffix_s){ FileOutputStream *stream_p = NULL; const char * const output_dir_s = GetOutputDir (); /* Make sure that the output directory exists */ if (EnsureDirectoryExists (output_dir_s)) { char *output_filename_s = (char *) GetFromHashTable (config_p, "OutputFilename"); /* Adapt the streams to be relative to our output directory */ char *name_s = GetStreamName (output_dir_s, output_filename_s, (char *) GetFromHashTable (config_p, key_s), suffix_s); stream_p = AllocateFileOutputStream (name_s); if (name_s) { FreeCopiedString (name_s); } } /* if (CreateNewDirectory (output_dir_s)) */ return stream_p;}
开发者ID:TGAC,项目名称:grassroots-api,代码行数:23,
示例7: GetUserDataDirectorynsresultnsXREDirProvider::GetUserProfilesLocalDir(nsIFile** aResult, const nsACString* aProfileName, const nsACString* aAppName, const nsACString* aVendorName){ nsCOMPtr<nsIFile> file; nsresult rv = GetUserDataDirectory(getter_AddRefs(file), true, aProfileName, aAppName, aVendorName); if (NS_SUCCEEDED(rv)) {#if !defined(XP_UNIX) || defined(XP_MACOSX) rv = file->AppendNative(NS_LITERAL_CSTRING("Profiles"));#endif // We must create the profile directory here if it does not exist. nsresult tmp = EnsureDirectoryExists(file); if (NS_FAILED(tmp)) { rv = tmp; } } file.swap(*aResult); return NS_OK;}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:24,
示例8: if//.........这里部分代码省略......... return NS_NewNativeLocalFile(nsDependentCString(sysLExtDir), false, aFile);#else return NS_ERROR_FAILURE;#endif }#endif else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DIR)) {#ifdef ENABLE_SYSTEM_EXTENSION_DIRS return GetSysUserExtensionsDirectory(aFile);#else return NS_ERROR_FAILURE;#endif } else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) { bool persistent = false; rv = GetFile(NS_GRE_DIR, &persistent, getter_AddRefs(file)); if (NS_SUCCEEDED(rv)) rv = file->AppendNative(NS_LITERAL_CSTRING("distribution")); } else if (!strcmp(aProperty, XRE_APP_FEATURES_DIR)) { rv = GetAppDir()->Clone(getter_AddRefs(file)); if (NS_SUCCEEDED(rv)) rv = file->AppendNative(NS_LITERAL_CSTRING("features")); } else if (NS_SUCCEEDED(GetProfileStartupDir(getter_AddRefs(file)))) { // We need to allow component, xpt, and chrome registration to // occur prior to the profile-after-change notification. if (!strcmp(aProperty, NS_APP_USER_CHROME_DIR)) { rv = file->AppendNative(NS_LITERAL_CSTRING("chrome")); } } if (NS_SUCCEEDED(rv) && file) { file.forget(aFile); return NS_OK; } bool ensureFilePermissions = false; if (NS_SUCCEEDED(GetProfileDir(getter_AddRefs(file)))) { if (!strcmp(aProperty, NS_APP_PREFS_50_DIR)) { rv = NS_OK; } else if (!strcmp(aProperty, NS_APP_PREFS_50_FILE)) { rv = file->AppendNative(NS_LITERAL_CSTRING("prefs.js")); } else if (!strcmp(aProperty, NS_LOCALSTORE_UNSAFE_FILE)) { rv = file->AppendNative(NS_LITERAL_CSTRING("localstore.rdf")); } else if (!strcmp(aProperty, NS_APP_LOCALSTORE_50_FILE)) { if (gSafeMode) { rv = file->AppendNative(NS_LITERAL_CSTRING("localstore-safe.rdf")); file->Remove(false); } else { rv = file->AppendNative(NS_LITERAL_CSTRING("localstore.rdf")); EnsureProfileFileExists(file); ensureFilePermissions = true; } } else if (!strcmp(aProperty, NS_APP_USER_MIMETYPES_50_FILE)) { rv = file->AppendNative(NS_LITERAL_CSTRING("mimeTypes.rdf")); EnsureProfileFileExists(file); ensureFilePermissions = true; } else if (!strcmp(aProperty, NS_APP_DOWNLOADS_50_FILE)) { rv = file->AppendNative(NS_LITERAL_CSTRING("downloads.rdf")); } else if (!strcmp(aProperty, NS_APP_PREFS_OVERRIDE_DIR)) { rv = mProfileDir->Clone(getter_AddRefs(file)); nsresult tmp = file->AppendNative(NS_LITERAL_CSTRING(PREF_OVERRIDE_DIRNAME)); if (NS_FAILED(tmp)) { rv = tmp; } tmp = EnsureDirectoryExists(file); if (NS_FAILED(tmp)) { rv = tmp; } } } if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE; if (ensureFilePermissions) { bool fileToEnsureExists; bool isWritable; if (NS_SUCCEEDED(file->Exists(&fileToEnsureExists)) && fileToEnsureExists && NS_SUCCEEDED(file->IsWritable(&isWritable)) && !isWritable) { uint32_t permissions; if (NS_SUCCEEDED(file->GetPermissions(&permissions))) { rv = file->SetPermissions(permissions | 0600); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to ensure file permissions"); } } } file.forget(aFile); return NS_OK;}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:101,
注:本文中的EnsureDirectoryExists函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ EnsureInit函数代码示例 C++ EnsureActive函数代码示例 |