nsresult  rv;  if (setDefault) { rv = mDefaultBranch->SetComplexValue(pref, NS_GET_IID(nsIFileSpec), value); } else { nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mPrefService, &rv); if (NS_SUCCEEDED(rv)) rv = prefBranch->SetComplexValue(pref, NS_GET_IID(nsIFileSpec), value); } return rv;
if (!value) return NS_ERROR_NULL_POINTER; if (NS_FAILED(SecurePrefCheck(pref_name))) return NS_ERROR_FAILURE; nsresult rv = NS_OK; if (!Exists(value)) {   nsIFileSpec* tmp = nsnull; rv = nsComponentManager::CreateInstance( (const char*)NS_FILESPEC_CONTRACTID, (nsISupports*)nsnull, (const nsID&)NS_GET_IID(nsIFileSpec), (void**)&tmp); NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a file spec."); if (!tmp) return NS_ERROR_FAILURE; tmp->FromFileSpec(value); tmp->CreateDir(); NS_RELEASE(tmp); } char* encodedString = nsnull; value->GetPersistentDescriptorString(&encodedString); if (encodedString && *encodedString) { if (set_default) rv = PREF_SetDefaultCharPref(pref_name, encodedString); else rv = PREF_SetCharPref(pref_name, encodedString); } PR_FREEIF(encodedString); return _convertRes(rv);
NS_IMETHODIMP nsPref::SetFilePref(const char *pref, nsIFileSpec *value, PRBool setDefault){  nsresult  rv;  if (setDefault) {    rv = mDefaultBranch->SetComplexValue(pref, NS_GET_IID(nsIFileSpec), value);  } else {    nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mPrefService, &rv);    if (NS_SUCCEEDED(rv))      rv = prefBranch->SetComplexValue(pref, NS_GET_IID(nsIFileSpec), value);  }    return rv;}