本文整理汇总了C++中NS_GetSpecialDirectory函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_GetSpecialDirectory函数的具体用法?C++ NS_GetSpecialDirectory怎么用?C++ NS_GetSpecialDirectory使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_GetSpecialDirectory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
}
示例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"));
}