本文整理汇总了C++中NS_GetSpecialDirectory函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_GetSpecialDirectory函数的具体用法?C++ NS_GetSpecialDirectory怎么用?C++ NS_GetSpecialDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_GetSpecialDirectory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Run
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIFile> tmpFile;
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
tmpFile->GetPath(mPath);
return NS_OK;
}
开发者ID:L2-D2,项目名称:gecko-dev,代码行数:12,代码来源:GMPStorageParent.cpp
示例2: NS_GetSpecialDirectory
void
nsDogbertProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
{
nsresult rv;
nsCOMPtr<nsIFile> regFile;
rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile));
if (NS_FAILED(rv)) return;
regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME));
nsCAutoString path;
rv = regFile->GetNativePath(path);
if (NS_FAILED(rv)) return;
if (NR_StartupRegistry())
return;
HREG reg = nsnull;
RKEY profile = nsnull;
if (NR_RegOpen(path.get(), ®))
goto cleanup;
{
// on macos, registry entries are UTF8 encoded
NS_ConvertUTF16toUTF8 profileName(aProfile);
if (NR_RegGetKey(reg, ROOTKEY_USERS, profileName.get(), &profile))
goto cleanup;
}
char profilePath[MAXPATHLEN];
if (NR_RegGetEntryString(reg, profile, "ProfileLocation", profilePath, MAXPATHLEN))
goto cleanup;
mSourceProfile = do_CreateInstance("@mozilla.org/file/local;1");
if (!mSourceProfile) goto cleanup;
{
// the string is UTF8 encoded, which forces us to do some strange string-do
rv = mSourceProfile->InitWithPath(NS_ConvertUTF8toUTF16(profilePath));
}
if (NS_FAILED(rv))
mSourceProfile = nsnull;
cleanup:
if (reg)
NR_RegClose(reg);
NR_ShutdownRegistry();
}
开发者ID:AllenDou,项目名称:firefox,代码行数:52,代码来源:nsDogbertProfileMigrator.cpp
示例3: NS_GetSpecialDirectory
/* void Load (); */
NS_IMETHODIMP mozPersonalDictionary::Load()
{
//FIXME Deinst -- get dictionary name from prefs;
nsresult res;
nsCOMPtr<nsIFile> theFile;
PRBool dictExists;
res = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(theFile));
if(NS_FAILED(res)) return res;
if(!theFile)return NS_ERROR_FAILURE;
res = theFile->Append(NS_LITERAL_STRING(MOZ_PERSONAL_DICT_NAME));
if(NS_FAILED(res)) return res;
res = theFile->Exists(&dictExists);
if(NS_FAILED(res)) return res;
if (!dictExists) {
// Nothing is really wrong...
return NS_OK;
}
nsCOMPtr<nsIInputStream> inStream;
NS_NewLocalFileInputStream(getter_AddRefs(inStream), theFile);
nsCOMPtr<nsIUnicharInputStream> convStream;
res = nsSimpleUnicharStreamFactory::GetInstance()->
CreateInstanceFromUTF8Stream(inStream, getter_AddRefs(convStream));
if(NS_FAILED(res)) return res;
// we're rereading to get rid of the old data -- we shouldn't have any, but...
mDictionaryTable.Clear();
PRUnichar c;
PRUint32 nRead;
PRBool done = PR_FALSE;
do{ // read each line of text into the string array.
if( (NS_OK != convStream->Read(&c, 1, &nRead)) || (nRead != 1)) break;
while(!done && ((c == '\n') || (c == '\r'))){
if( (NS_OK != convStream->Read(&c, 1, &nRead)) || (nRead != 1)) done = PR_TRUE;
}
if (!done){
nsAutoString word;
while((c != '\n') && (c != '\r') && !done){
word.Append(c);
if( (NS_OK != convStream->Read(&c, 1, &nRead)) || (nRead != 1)) done = PR_TRUE;
}
mDictionaryTable.PutEntry(word.get());
}
} while(!done);
mDirty = PR_FALSE;
return res;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:53,代码来源:mozPersonalDictionary.cpp
示例4: NS_GetSpecialDirectory
nsresult
nsResProtocolHandler::AddSpecialDir(const char* aSpecialDir, const nsACString& aSubstitution)
{
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(aSpecialDir, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> uri;
rv = mIOService->NewFileURI(file, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
return SetSubstitution(aSubstitution, uri);
}
开发者ID:mmmulani,项目名称:v8monkey,代码行数:13,代码来源:nsResProtocolHandler.cpp
示例5: GetEMEVoucherPath
bool
GetEMEVoucherPath(nsIFile** aPath)
{
nsCOMPtr<nsIFile> path;
NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(path));
if (!path) {
NS_WARNING("GetEMEVoucherPath can't get NS_GRE_DIR!");
return false;
}
path->AppendNative(NS_LITERAL_CSTRING("voucher.bin"));
path.forget(aPath);
return true;
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:13,代码来源:GMPUtils.cpp
示例6: InitLateWriteChecks
void
InitLateWriteChecks()
{
nsCOMPtr<nsIFile> mozFile;
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mozFile));
if (mozFile) {
nsAutoCString nativePath;
nsresult rv = mozFile->GetNativePath(nativePath);
if (NS_SUCCEEDED(rv) && nativePath.get()) {
sLateWriteObserver = new LateWriteObserver(nativePath.get());
}
}
}
开发者ID:RobertJGabriel,项目名称:Waterfox,代码行数:13,代码来源:LateWriteChecks.cpp
示例7: NS_GetSpecialDirectory
/* readonly attribute nsILocalFile binDir; */
NS_IMETHODIMP nsXPCToolsCompiler::GetBinDir(nsILocalFile * *aBinDir)
{
*aBinDir = nsnull;
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, getter_AddRefs(file));
if(NS_FAILED(rv))
return rv;
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(file);
NS_ADDREF(*aBinDir = lfile);
return NS_OK;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:14,代码来源:nsXPCToolsCompiler.cpp
示例8: NS_GetSpecialDirectory
nsresult
LocalStoreImpl::LoadData()
{
nsresult rv;
// Look for localstore.rdf in the current profile
// directory. Bomb if we can't find it.
nsCOMPtr<nsIFile> aFile;
rv = NS_GetSpecialDirectory(NS_APP_LOCALSTORE_50_FILE, getter_AddRefs(aFile));
if (NS_FAILED(rv)) return rv;
bool fileExistsFlag = false;
(void)aFile->Exists(&fileExistsFlag);
if (!fileExistsFlag) {
// if file doesn't exist, create it
rv = CreateLocalStore(aFile);
if (NS_FAILED(rv)) return rv;
}
mInner = do_CreateInstance(NS_RDF_DATASOURCE_CONTRACTID_PREFIX "xml-datasource", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> aURI;
rv = NS_NewFileURI(getter_AddRefs(aURI), aFile);
if (NS_FAILED(rv)) return rv;
nsCAutoString spec;
rv = aURI->GetSpec(spec);
if (NS_FAILED(rv)) return rv;
rv = remote->Init(spec.get());
if (NS_FAILED(rv)) return rv;
// Read the datasource synchronously.
rv = remote->Refresh(true);
if (NS_FAILED(rv)) {
// Load failed, delete and recreate a fresh localstore
aFile->Remove(true);
rv = CreateLocalStore(aFile);
if (NS_FAILED(rv)) return rv;
rv = remote->Refresh(true);
}
return rv;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:51,代码来源:nsLocalStore.cpp
示例9: do_GetService
nsresult
sbTemporaryFileService::Initialize()
{
nsresult rv;
// Add observers.
if (!mObserverService) {
mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = mObserverService->AddObserver(this, "profile-after-change", PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
rv = mObserverService->AddObserver(this, "quit-application", PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
}
// Wait for the user profile to be available.
if (!mProfileAvailable)
return NS_OK;
// Set up the root temporary directory residing in the OS temporary directory.
nsCOMPtr<nsIFile> rootTemporaryDirectory;
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR,
getter_AddRefs(rootTemporaryDirectory));
NS_ENSURE_SUCCESS(rv, rv);
// Ensure the root temporary directory exists.
bool exists;
rv = rootTemporaryDirectory->Append
(NS_LITERAL_STRING(SB_TEMPORARY_FILE_SERVICE_ROOT_DIR_NAME));
NS_ENSURE_SUCCESS(rv, rv);
rv = rootTemporaryDirectory->Exists(&exists);
NS_ENSURE_SUCCESS(rv, rv);
if (!exists) {
rv = rootTemporaryDirectory->Create(nsIFile::DIRECTORY_TYPE,
SB_DEFAULT_DIRECTORY_PERMISSIONS);
NS_ENSURE_SUCCESS(rv, rv);
}
// Create the root temporary file factory.
mRootTemporaryFileFactory =
do_CreateInstance("@songbirdnest.com/Songbird/TemporaryFileFactory;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = mRootTemporaryFileFactory->SetRootTemporaryDirectory
(rootTemporaryDirectory);
NS_ENSURE_SUCCESS(rv, rv);
// Services are now initialized.
mInitialized = PR_TRUE;
return NS_OK;
}
开发者ID:Brijen,项目名称:nightingale-hacking,代码行数:51,代码来源:sbTemporaryFileService.cpp
示例10: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsAbManager::GetUserProfileDirectory(nsILocalFile **userDir)
{
NS_ENSURE_ARG_POINTER(userDir);
*userDir = nsnull;
nsresult rv;
nsCOMPtr<nsIFile> profileDir;
nsCAutoString pathBuf;
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(profileDir, userDir);
}
开发者ID:mikeconley,项目名称:comm-central,代码行数:14,代码来源:nsAbManager.cpp
示例11: NS_GetSpecialDirectory
nsresult
nsSafariProfileMigrator::CopyOtherData(bool aReplace)
{
// Get the Safari user style sheet and copy it into the active profile's
// chrome folder
nsCOMPtr<nsILocalFile> stylesheetFile;
if (NS_SUCCEEDED(GetSafariUserStyleSheet(getter_AddRefs(stylesheetFile)))) {
nsCOMPtr<nsIFile> userChromeDir;
NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR,
getter_AddRefs(userChromeDir));
stylesheetFile->CopyTo(userChromeDir, NS_LITERAL_STRING("userContent.css"));
}
return NS_OK;
}
开发者ID:anuragbhatnagar,项目名称:mozilla-central,代码行数:15,代码来源:nsSafariProfileMigrator.cpp
示例12: NS_GetSpecialDirectory
void
nsSuiteDirectoryProvider::EnsureProfileFile(const nsACString& aLeafName,
nsIFile* aParentDir,
nsIFile* aTarget)
{
nsCOMPtr<nsIFile> defaults;
NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR,
getter_AddRefs(defaults));
if (!defaults)
return;
defaults->AppendNative(aLeafName);
defaults->CopyToNative(aParentDir, aLeafName);
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:15,代码来源:nsSuiteDirectoryProvider.cpp
示例13: if
NS_IMETHODIMP
nsMailDirProvider::GetFile(const char *aKey, bool *aPersist,
nsIFile **aResult)
{
// NOTE: This function can be reentrant through the NS_GetSpecialDirectory
// call, so be careful not to cause infinite recursion.
// i.e. the check for supported files must come first.
const char* leafName = nullptr;
bool isDirectory = true;
if (!strcmp(aKey, NS_APP_MAIL_50_DIR))
leafName = MAIL_DIR_50_NAME;
else if (!strcmp(aKey, NS_APP_IMAP_MAIL_50_DIR))
leafName = IMAP_MAIL_DIR_50_NAME;
else if (!strcmp(aKey, NS_APP_NEWS_50_DIR))
leafName = NEWS_DIR_50_NAME;
else if (!strcmp(aKey, NS_APP_MESSENGER_FOLDER_CACHE_50_FILE)) {
isDirectory = false;
leafName = MSG_FOLDER_CACHE_DIR_50_NAME;
}
else
return NS_ERROR_FAILURE;
nsCOMPtr<nsIFile> parentDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(parentDir));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIFile> file;
rv = parentDir->Clone(getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
nsDependentCString leafStr(leafName);
rv = file->AppendNative(leafStr);
if (NS_FAILED(rv))
return rv;
bool exists;
if (isDirectory && NS_SUCCEEDED(file->Exists(&exists)) && !exists)
rv = EnsureDirectory(file);
*aPersist = true;
file.forget(aResult);
return rv;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:48,代码来源:nsMailDirProvider.cpp
示例14: InitWritePoisoning
void InitWritePoisoning()
{
// Stdout and Stderr are OK.
MozillaRegisterDebugFD(1);
MozillaRegisterDebugFD(2);
nsCOMPtr<nsIFile> mozFile;
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mozFile));
if (mozFile) {
nsAutoCString nativePath;
nsresult rv = mozFile->GetNativePath(nativePath);
if (NS_SUCCEEDED(rv)) {
sProfileDirectory = PL_strdup(nativePath.get());
}
}
}
开发者ID:gdestuynder,项目名称:mozilla-central,代码行数:16,代码来源:mozPoisonWriteBase.cpp
示例15: NS_GetSpecialDirectory
nsSpamSettings::nsSpamSettings()
{
mLevel = 0;
mMoveOnSpam = false;
mMoveTargetMode = nsISpamSettings::MOVE_TARGET_MODE_ACCOUNT;
mPurge = false;
mPurgeInterval = 14; // 14 days
mServerFilterTrustFlags = 0;
mUseWhiteList = false;
mUseServerFilter = false;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mLogFile));
if (NS_SUCCEEDED(rv))
mLogFile->Append(NS_LITERAL_STRING("junklog.html"));
}
开发者ID:vanto,项目名称:comm-central,代码行数:17,代码来源:nsSpamSettings.cpp
示例16: LoadLibraryForEGLOnWindows
// see the comment in GLLibraryEGL::EnsureInitialized() for the rationale here.
static PRLibrary*
LoadLibraryForEGLOnWindows(const nsAString& filename)
{
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file));
if (NS_FAILED(rv))
return nullptr;
file->Append(filename);
PRLibrary* lib = nullptr;
rv = file->Load(&lib);
if (NS_FAILED(rv)) {
nsPrintfCString msg("Failed to load %s - Expect EGL initialization to fail",
NS_LossyConvertUTF16toASCII(filename).get());
NS_WARNING(msg.get());
}
return lib;
}
开发者ID:hoosteeno,项目名称:gecko-dev,代码行数:19,代码来源:GLLibraryEGL.cpp
示例17: do_CreateInstance
NS_IMETHODIMP
nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{
if (!mProfiles) {
nsresult rv;
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> regFile;
rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile));
NS_ENSURE_SUCCESS(rv, rv);
regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME));
nsCAutoString path;
rv = regFile->GetNativePath(path);
NS_ENSURE_SUCCESS(rv, rv);
if (NR_StartupRegistry())
return NS_ERROR_FAILURE;
HREG reg = nsnull;
REGENUM enumstate = 0;
if (NR_RegOpen(path.get(), ®)) {
NR_ShutdownRegistry();
return NS_ERROR_FAILURE;
}
char profileName[MAXREGNAMELEN];
while (!NR_RegEnumSubkeys(reg, ROOTKEY_USERS, &enumstate,
profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) {
nsCOMPtr<nsISupportsString> nameString
(do_CreateInstance("@mozilla.org/supports-string;1"));
if (nameString) {
nameString->SetData(NS_ConvertUTF8toUTF16(profileName));
mProfiles->AppendElement(nameString);
}
}
}
NS_IF_ADDREF(*aResult = mProfiles);
return NS_OK;
}
开发者ID:AllenDou,项目名称:firefox,代码行数:44,代码来源:nsDogbertProfileMigrator.cpp
示例18: PR_GetEnv
nsresult
nsGNOMEShellService::Init()
{
nsresult rv;
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
// the locale encoding. If it's not set, they use UTF-8.
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nullptr;
nsCOMPtr<nsIFile> appPath;
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
getter_AddRefs(appPath));
NS_ENSURE_SUCCESS(rv, rv);
rv = appPath->AppendNative(NS_LITERAL_CSTRING(MOZ_APP_NAME));
NS_ENSURE_SUCCESS(rv, rv);
return appPath->GetNativePath(mAppPath);
}
开发者ID:rickysarraf,项目名称:icedove,代码行数:19,代码来源:nsGNOMEShellService.cpp
示例19: NS_GetSpecialDirectory
void
nsSuiteDirectoryProvider::EnsureProfileFile(const nsACString& aLeafName,
nsIFile* aParentDir,
nsIFile* aTarget)
{
nsCOMPtr<nsIFile> defaultsDir;
NS_GetSpecialDirectory(NS_APP_DEFAULTS_50_DIR,
getter_AddRefs(defaultsDir));
if (!defaultsDir)
return;
nsresult rv = defaultsDir->AppendNative(NS_LITERAL_CSTRING("profile"));
NS_ENSURE_SUCCESS_VOID(rv);
defaultsDir->AppendNative(aLeafName);
defaultsDir->CopyToNative(aParentDir, aLeafName);
}
开发者ID:SphereWeb,项目名称:releases-comm-central,代码行数:19,代码来源:nsSuiteDirectoryProvider.cpp
示例20: NS_GetSpecialDirectory
nsresult nsPrefService::UseDefaultPrefFile()
{
nsresult rv, rv2;
nsCOMPtr<nsIFile> aFile;
rv = NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE, getter_AddRefs(aFile));
if (NS_SUCCEEDED(rv)) {
rv = ReadAndOwnUserPrefFile(aFile);
// Most likely cause of failure here is that the file didn't
// exist, so save a new one. mUserPrefReadFailed will be
// used to catch an error in actually reading the file.
if (NS_FAILED(rv)) {
rv2 = SavePrefFileInternal(aFile);
NS_ASSERTION(NS_SUCCEEDED(rv2), "Failed to save new shared pref file");
}
}
return rv;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:19,代码来源:nsPrefService.cpp
注:本文中的NS_GetSpecialDirectory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论