mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1925866 - NS_NewLocalFile's aFollowSymlinks arg is unused. r=xpcom-reviewers,necko-reviewers,valentin,media-playback-reviewers,win-reviewers,karlt,nika,rkraesig
Remove it and related functions, and update the callers. Differential Revision: https://phabricator.services.mozilla.com/D226261
This commit is contained in:
parent
6c0b4b7b4f
commit
b5d2263c26
@ -162,7 +162,7 @@ static bool GetInstantiatorExecutable(const DWORD aPid,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(buf.get(), bufLen), false,
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(buf.get(), bufLen),
|
||||
getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
|
@ -224,8 +224,7 @@ nsMacShellService::OnStateChange(nsIWebProgress* aWebProgress,
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::ShowDesktopPreferences() {
|
||||
nsCOMPtr<nsIFile> lf;
|
||||
nsresult rv =
|
||||
NS_NewNativeLocalFile(DESKTOP_PREFPANE, true, getter_AddRefs(lf));
|
||||
nsresult rv = NS_NewNativeLocalFile(DESKTOP_PREFPANE, getter_AddRefs(lf));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
bool exists;
|
||||
lf->Exists(&exists);
|
||||
|
@ -1734,7 +1734,7 @@ static nsresult PinCurrentAppToTaskbarImpl(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAutoString exeStr(exePath);
|
||||
nsresult rv = NS_NewLocalFile(exeStr, true, getter_AddRefs(exeFile));
|
||||
nsresult rv = NS_NewLocalFile(exeStr, getter_AddRefs(exeFile));
|
||||
if (!NS_SUCCEEDED(rv)) {
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ already_AddRefed<Directory> ReadDirectoryInternal(
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(path, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(path, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -392,8 +392,7 @@ already_AddRefed<FileSystemEntry> DataTransferItem::GetAsEntry(
|
||||
nsCOMPtr<nsIFile> directoryFile;
|
||||
// fullPath is already in unicode, we don't have to use
|
||||
// NS_NewNativeLocalFile.
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(fullpath, true, getter_AddRefs(directoryFile));
|
||||
nsresult rv = NS_NewLocalFile(fullpath, getter_AddRefs(directoryFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ already_AddRefed<Promise> File::CreateFromFileName(
|
||||
const ChromeFilePropertyBag& aBag, SystemCallerGuarantee aGuarantee,
|
||||
ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aRv = NS_NewLocalFile(aPath, false, getter_AddRefs(file));
|
||||
aRv = NS_NewLocalFile(aPath, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ nsresult FileCreatorParent::CreateBlobImpl(
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(aPath, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(aPath, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ already_AddRefed<Directory> Directory::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aRealPath,
|
||||
ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIFile> path;
|
||||
aRv = NS_NewLocalFile(aRealPath, true, getter_AddRefs(path));
|
||||
aRv = NS_NewLocalFile(aRealPath, getter_AddRefs(path));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ bool FileSystemBase::GetRealPath(BlobImpl* aFile, nsIFile** aPath) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
rv = NS_NewLocalFile(filePath, true, aPath);
|
||||
rv = NS_NewLocalFile(filePath, aPath);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
rv.SuppressException();
|
||||
return false;
|
||||
@ -77,7 +77,7 @@ void FileSystemBase::GetDOMPath(nsIFile* aFile, nsAString& aRetval,
|
||||
aRetval.Truncate();
|
||||
|
||||
nsCOMPtr<nsIFile> fileSystemPath;
|
||||
aRv = NS_NewLocalFile(LocalRootPath(), true, getter_AddRefs(fileSystemPath));
|
||||
aRv = NS_NewLocalFile(LocalRootPath(), getter_AddRefs(fileSystemPath));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ void GetDirectoryListingTaskChild::SetSuccessRequestResult(
|
||||
data.get_FileSystemDirectoryListingResponseDirectory();
|
||||
|
||||
nsCOMPtr<nsIFile> path;
|
||||
aRv = NS_NewLocalFile(d.directoryRealPath(), true, getter_AddRefs(path));
|
||||
aRv = NS_NewLocalFile(d.directoryRealPath(), getter_AddRefs(path));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
@ -184,8 +184,7 @@ GetDirectoryListingTaskParent::Create(
|
||||
RefPtr<GetDirectoryListingTaskParent> task =
|
||||
new GetDirectoryListingTaskParent(aFileSystem, aParam, aParent);
|
||||
|
||||
aRv = NS_NewLocalFile(aParam.realPath(), true,
|
||||
getter_AddRefs(task->mTargetPath));
|
||||
aRv = NS_NewLocalFile(aParam.realPath(), getter_AddRefs(task->mTargetPath));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -214,8 +213,7 @@ FileSystemResponseValue GetDirectoryListingTaskParent::GetSuccessRequestResult(
|
||||
for (unsigned i = 0; i < mTargetData.Length(); i++) {
|
||||
if (mTargetData[i].mType == FileOrDirectoryPath::eFilePath) {
|
||||
nsCOMPtr<nsIFile> path;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(mTargetData[i].mPath, true, getter_AddRefs(path));
|
||||
nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, getter_AddRefs(path));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
continue;
|
||||
}
|
||||
@ -393,8 +391,7 @@ nsresult GetDirectoryListingTaskParent::MainThreadWork() {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(mTargetData[i].mPath, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
continue;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void GetFileOrDirectoryTaskChild::SetSuccessRequestResult(
|
||||
FileSystemDirectoryResponse r = aValue;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(file));
|
||||
aRv = NS_NewLocalFile(r.realPath(), getter_AddRefs(file));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
@ -163,8 +163,7 @@ GetFileOrDirectoryTaskParent::Create(
|
||||
RefPtr<GetFileOrDirectoryTaskParent> task =
|
||||
new GetFileOrDirectoryTaskParent(aFileSystem, aParam, aParent);
|
||||
|
||||
aRv = NS_NewLocalFile(aParam.realPath(), true,
|
||||
getter_AddRefs(task->mTargetPath));
|
||||
aRv = NS_NewLocalFile(aParam.realPath(), getter_AddRefs(task->mTargetPath));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ void GetFilesHelper::RunIO() {
|
||||
MOZ_ASSERT(!mListingCompleted);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
mErrorResult = NS_NewLocalFile(mDirectoryPath, true, getter_AddRefs(file));
|
||||
mErrorResult = NS_NewLocalFile(mDirectoryPath, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
|
||||
return;
|
||||
}
|
||||
|
@ -155,8 +155,7 @@ already_AddRefed<GetFilesTaskParent> GetFilesTaskParent::Create(
|
||||
RefPtr<GetFilesTaskParent> task =
|
||||
new GetFilesTaskParent(aFileSystem, aParam, aParent);
|
||||
|
||||
aRv = NS_NewLocalFile(aParam.realPath(), true,
|
||||
getter_AddRefs(task->mTargetPath));
|
||||
aRv = NS_NewLocalFile(aParam.realPath(), getter_AddRefs(task->mTargetPath));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ static already_AddRefed<nsIFile> LastUsedDirectory(
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
nsresult rv = NS_NewLocalFile(path, true, getter_AddRefs(localFile));
|
||||
nsresult rv = NS_NewLocalFile(path, getter_AddRefs(localFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -2164,7 +2164,7 @@ void HTMLInputElement::MozSetFileNameArray(const Sequence<nsString>& aFileNames,
|
||||
|
||||
if (!file) {
|
||||
// this is no "file://", try as local file
|
||||
NS_NewLocalFile(aFileNames[i], false, getter_AddRefs(file));
|
||||
NS_NewLocalFile(aFileNames[i], getter_AddRefs(file));
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
@ -2197,7 +2197,7 @@ void HTMLInputElement::MozSetDirectory(const nsAString& aDirectoryPath,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aRv = NS_NewLocalFile(aDirectoryPath, true, getter_AddRefs(file));
|
||||
aRv = NS_NewLocalFile(aDirectoryPath, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
@ -6285,8 +6285,7 @@ static nsTArray<OwningFileOrDirectory> RestoreFileContentData(
|
||||
} else {
|
||||
MOZ_ASSERT(it.type() == FileContentData::TnsString);
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(it.get_nsString(), true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(it.get_nsString(), getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
continue;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ bool GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) {
|
||||
MOZ_CRASH(explain); \
|
||||
} while (false)
|
||||
|
||||
nsresult rv = NS_NewLocalFile(mPluginPath, true, getter_AddRefs(libFile));
|
||||
nsresult rv = NS_NewLocalFile(mPluginPath, getter_AddRefs(libFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
GMP_PATH_CRASH("Failed to create file for plugin path");
|
||||
return false;
|
||||
@ -310,7 +310,7 @@ bool GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) {
|
||||
bool GMPChild::GetPluginName(nsACString& aPluginName) const {
|
||||
// Extract the plugin directory name if possible.
|
||||
nsCOMPtr<nsIFile> libFile;
|
||||
nsresult rv = NS_NewLocalFile(mPluginPath, true, getter_AddRefs(libFile));
|
||||
nsresult rv = NS_NewLocalFile(mPluginPath, getter_AddRefs(libFile));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
@ -463,8 +463,7 @@ GMPChild::MakeCDMHostVerificationPaths(const nsACString& aPluginLibPath) {
|
||||
|
||||
CopyUTF8toUTF16(nsDependentCString(pluginContainer.c_str()), str);
|
||||
nsCOMPtr<nsIFile> path;
|
||||
if (NS_FAILED(NS_NewLocalFile(str, true, /* aFollowLinks */
|
||||
getter_AddRefs(path))) ||
|
||||
if (NS_FAILED(NS_NewLocalFile(str, getter_AddRefs(path))) ||
|
||||
!AppendHostPath(path, paths)) {
|
||||
// Without successfully determining plugin-container's path, we can't
|
||||
// determine libxul's or Firefox's. So give up.
|
||||
|
@ -277,7 +277,7 @@ bool GMPProcessParent::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
|
||||
"plugin dir path: %s",
|
||||
mGMPPath.c_str());
|
||||
nsCOMPtr<nsIFile> pluginDir;
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(mGMPPath.c_str()), true,
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(mGMPPath.c_str()),
|
||||
getter_AddRefs(pluginDir));
|
||||
if (NS_FAILED(rv)) {
|
||||
GMP_LOG_DEBUG(
|
||||
@ -347,8 +347,8 @@ bool GMPProcessParent::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
|
||||
nsresult GMPProcessParent::NormalizePath(const char* aPath,
|
||||
PathString& aNormalizedPath) {
|
||||
nsCOMPtr<nsIFile> fileOrDir;
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(aPath), true,
|
||||
getter_AddRefs(fileOrDir));
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(aPath), getter_AddRefs(fileOrDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = fileOrDir->Normalize();
|
||||
|
@ -1068,7 +1068,7 @@ RefPtr<GenericPromise> GeckoMediaPluginServiceParent::AddOnGMPThread(
|
||||
GMP_LOG_DEBUG("%s::%s: %s", __CLASS__, __FUNCTION__, dir.get());
|
||||
|
||||
nsCOMPtr<nsIFile> directory;
|
||||
nsresult rv = NS_NewLocalFile(aDirectory, false, getter_AddRefs(directory));
|
||||
nsresult rv = NS_NewLocalFile(aDirectory, getter_AddRefs(directory));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
GMP_LOG_DEBUG("%s::%s: failed to create nsIFile for dir=%s rv=%" PRIx32,
|
||||
__CLASS__, __FUNCTION__, dir.get(),
|
||||
@ -1110,7 +1110,7 @@ void GeckoMediaPluginServiceParent::RemoveOnGMPThread(
|
||||
NS_LossyConvertUTF16toASCII(aDirectory).get());
|
||||
|
||||
nsCOMPtr<nsIFile> directory;
|
||||
nsresult rv = NS_NewLocalFile(aDirectory, false, getter_AddRefs(directory));
|
||||
nsresult rv = NS_NewLocalFile(aDirectory, getter_AddRefs(directory));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -135,8 +135,7 @@ void CacheUseDOSDevicePathSyntaxPrefValue() {
|
||||
Result<nsCOMPtr<nsIFile>, nsresult> QM_NewLocalFile(const nsAString& aPath) {
|
||||
QM_TRY_UNWRAP(
|
||||
auto file,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, NS_NewLocalFile, aPath,
|
||||
/* aFollowLinks */ false),
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, NS_NewLocalFile, aPath),
|
||||
QM_PROPAGATE, [&aPath](const nsresult rv) {
|
||||
QM_WARNING("Failed to construct a file for path (%s)",
|
||||
NS_ConvertUTF16toUTF8(aPath).get());
|
||||
|
@ -243,7 +243,7 @@ void mozHunspell::LoadDictionaryList(bool aNotifyChildProcesses) {
|
||||
rv = prefs->GetCharPref("spellchecker.dictionary_path", extDictPath);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// set the spellchecker.dictionary_path
|
||||
rv = NS_NewNativeLocalFile(extDictPath, true, getter_AddRefs(dictDir));
|
||||
rv = NS_NewNativeLocalFile(extDictPath, getter_AddRefs(dictDir));
|
||||
}
|
||||
if (dictDir) {
|
||||
LoadDictionariesFromDir(dictDir);
|
||||
@ -262,8 +262,7 @@ void mozHunspell::LoadDictionaryList(bool aNotifyChildProcesses) {
|
||||
char* nextPaths = env.BeginWriting();
|
||||
while ((currPath = NS_strtok(":", &nextPaths))) {
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
rv =
|
||||
NS_NewNativeLocalFile(nsCString(currPath), true, getter_AddRefs(dir));
|
||||
rv = NS_NewNativeLocalFile(nsCString(currPath), getter_AddRefs(dir));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
dirs.AppendElement(dir);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ mozilla::BinPathType BaseProcessLauncher::GetPathToBinary(
|
||||
exePath = FilePath(char16ptr_t(gGREBinPath));
|
||||
#elif MOZ_WIDGET_COCOA
|
||||
nsCOMPtr<nsIFile> childProcPath;
|
||||
NS_NewLocalFile(nsDependentString(gGREBinPath), false,
|
||||
NS_NewLocalFile(nsDependentString(gGREBinPath),
|
||||
getter_AddRefs(childProcPath));
|
||||
|
||||
// We need to use an App Bundle on OS X so that we can hide
|
||||
|
@ -630,8 +630,8 @@ size_t URLPreloader::ShallowSizeOfIncludingThis(
|
||||
Result<FileLocation, nsresult> URLPreloader::CacheKey::ToFileLocation() {
|
||||
if (mType == TypeFile) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
MOZ_TRY(NS_NewLocalFile(NS_ConvertUTF8toUTF16(mPath), false,
|
||||
getter_AddRefs(file)));
|
||||
MOZ_TRY(
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(mPath), getter_AddRefs(file)));
|
||||
return FileLocation(file);
|
||||
}
|
||||
|
||||
|
@ -181,8 +181,7 @@ static bool GetLocationProperty(JSContext* cx, unsigned argc, Value* vp) {
|
||||
# endif
|
||||
|
||||
nsCOMPtr<nsIFile> location;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(filenameString, false, getter_AddRefs(location));
|
||||
nsresult rv = NS_NewLocalFile(filenameString, getter_AddRefs(location));
|
||||
|
||||
if (!location && gWorkingDirectory) {
|
||||
// could be a relative path, try appending it to the cwd
|
||||
@ -190,7 +189,7 @@ static bool GetLocationProperty(JSContext* cx, unsigned argc, Value* vp) {
|
||||
nsAutoString absolutePath(*gWorkingDirectory);
|
||||
absolutePath.Append(filenameString);
|
||||
|
||||
rv = NS_NewLocalFile(absolutePath, false, getter_AddRefs(location));
|
||||
rv = NS_NewLocalFile(absolutePath, getter_AddRefs(location));
|
||||
}
|
||||
|
||||
if (location) {
|
||||
@ -1152,7 +1151,7 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
|
||||
printf("GetCurrentWorkingDirectory failed.\n");
|
||||
return 1;
|
||||
}
|
||||
rv = NS_NewLocalFile(workingDir, true, getter_AddRefs(greDir));
|
||||
rv = NS_NewLocalFile(workingDir, getter_AddRefs(greDir));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("NS_NewLocalFile failed.\n");
|
||||
return 1;
|
||||
|
@ -179,7 +179,7 @@ static void AppendBlobImplAsDirectory(nsTArray<OwningFileOrDirectory>& aArray,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(fullpath, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(fullpath, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ nsZipReaderCache::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
file = do_QueryInterface(aSubject);
|
||||
} else if (aSomeData) {
|
||||
nsDependentString fileName(aSomeData);
|
||||
Unused << NS_NewLocalFile(fileName, false, getter_AddRefs(file));
|
||||
Unused << NS_NewLocalFile(fileName, getter_AddRefs(file));
|
||||
}
|
||||
|
||||
if (!file) return NS_OK;
|
||||
|
@ -97,8 +97,8 @@ class ZipArchiveLogger {
|
||||
|
||||
if (!mFd) {
|
||||
nsCOMPtr<nsIFile> logFile;
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false,
|
||||
getter_AddRefs(logFile));
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(logFile));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// Create the log file and its parent directory (in case it doesn't exist)
|
||||
|
@ -2568,7 +2568,7 @@ nsPrefBranch::GetComplexValue(const char* aPrefName, const nsIID& aType,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> theFile;
|
||||
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(theFile));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(theFile));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ nsresult net_GetFileFromURLSpec(const nsACString& aURL, nsIFile** result) {
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localFile));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoCString directory, fileBaseName, fileExtension, path;
|
||||
|
@ -57,7 +57,7 @@ nsresult net_GetFileFromURLSpec(const nsACString& aURL, nsIFile** result) {
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localFile));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoCString directory, fileBaseName, fileExtension, path;
|
||||
|
@ -1311,7 +1311,7 @@ nsresult CacheFileIOManager::OnProfile() {
|
||||
nsCOMPtr<nsIFile> profilelessDirectory;
|
||||
char* cachePath = getenv("CACHE_DIRECTORY");
|
||||
if (!directory && cachePath && *cachePath) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cachePath), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cachePath),
|
||||
getter_AddRefs(directory));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Save this directory as the profileless path.
|
||||
|
@ -262,12 +262,11 @@ nsresult nsFileChannel::Init() {
|
||||
NS_SUCCEEDED(file->IsSymlink(&symLink)) && symLink &&
|
||||
#ifdef XP_WIN
|
||||
NS_SUCCEEDED(file->GetTarget(fileTarget)) &&
|
||||
NS_SUCCEEDED(
|
||||
NS_NewLocalFile(fileTarget, true, getter_AddRefs(resolvedFile))) &&
|
||||
NS_SUCCEEDED(NS_NewLocalFile(fileTarget, getter_AddRefs(resolvedFile))) &&
|
||||
#else
|
||||
NS_SUCCEEDED(file->GetNativeTarget(fileTarget)) &&
|
||||
NS_SUCCEEDED(NS_NewNativeLocalFile(fileTarget, true,
|
||||
getter_AddRefs(resolvedFile))) &&
|
||||
NS_SUCCEEDED(
|
||||
NS_NewNativeLocalFile(fileTarget, getter_AddRefs(resolvedFile))) &&
|
||||
#endif
|
||||
NS_SUCCEEDED(
|
||||
NS_NewFileURI(getter_AddRefs(targetURI), resolvedFile, nullptr))) {
|
||||
|
@ -151,8 +151,8 @@ nsFileProtocolHandler::ReadShellLink(nsIFile* aFile, nsIURI** aURI) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIFile> linkedFile;
|
||||
MOZ_TRY(NS_NewLocalFile(nsDependentString(lpTemp), false,
|
||||
getter_AddRefs(linkedFile)));
|
||||
MOZ_TRY(
|
||||
NS_NewLocalFile(nsDependentString(lpTemp), getter_AddRefs(linkedFile)));
|
||||
return NS_NewFileURI(aURI, linkedFile);
|
||||
#else
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -1944,8 +1944,8 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
|
||||
nsCOMPtr<nsIFile> qlogDir;
|
||||
if (Preferences::GetBool(HTTP_PREF("http3.enable_qlog")) &&
|
||||
!mHttp3QlogDir.IsEmpty() &&
|
||||
NS_SUCCEEDED(NS_NewNativeLocalFile(mHttp3QlogDir, false,
|
||||
getter_AddRefs(qlogDir)))) {
|
||||
NS_SUCCEEDED(
|
||||
NS_NewNativeLocalFile(mHttp3QlogDir, getter_AddRefs(qlogDir)))) {
|
||||
// Here we do main thread IO, but since this only happens
|
||||
// when enabling a developer feature it's not a problem for users.
|
||||
rv = qlogDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
|
||||
|
@ -556,7 +556,7 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() {
|
||||
// GetSpecialSystemDirectory(Unix_XDG_ConfigHome) ?
|
||||
nsCOMPtr<nsIFile> confDirOrXDGConfigHomeDir;
|
||||
if (!xdgConfigHome.IsEmpty()) {
|
||||
rv = NS_NewNativeLocalFile(xdgConfigHome, true,
|
||||
rv = NS_NewNativeLocalFile(xdgConfigHome,
|
||||
getter_AddRefs(confDirOrXDGConfigHomeDir));
|
||||
// confDirOrXDGConfigHomeDir = nsIFile($XDG_CONFIG_HOME)
|
||||
} else {
|
||||
|
@ -186,8 +186,7 @@ nsresult StartupCache::Init() {
|
||||
// cache in.
|
||||
char* env = PR_GetEnv("MOZ_STARTUP_CACHE");
|
||||
if (env && *env) {
|
||||
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false,
|
||||
getter_AddRefs(mFile));
|
||||
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(mFile));
|
||||
} else {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
rv = NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(file));
|
||||
|
@ -138,8 +138,8 @@ int RunGTestFunc(int* argc, char** argv) {
|
||||
char* path = PR_GetEnv("MOZ_GTEST_MINIDUMPS_PATH");
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (path) {
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true,
|
||||
getter_AddRefs(file));
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf_stderr("Ignoring invalid MOZ_GTEST_MINIDUMPS_PATH\n");
|
||||
}
|
||||
|
@ -1674,7 +1674,7 @@ ContentAnalysis::MaybeExpandAndAnalyzeFolderContentRequest(
|
||||
#endif
|
||||
|
||||
RefPtr<nsIFile> file;
|
||||
rv = NS_NewLocalFile(filename, false, getter_AddRefs(file));
|
||||
rv = NS_NewLocalFile(filename, getter_AddRefs(file));
|
||||
NS_ENSURE_SUCCESS(rv, Err(rv));
|
||||
|
||||
bool exists;
|
||||
|
@ -39,7 +39,7 @@ nsresult WinRemoteMessageReceiver::ParseV2(const nsAString& aBuffer) {
|
||||
|
||||
nsCOMPtr<nsIFile> workingDir;
|
||||
if (cch < aBuffer.Length()) {
|
||||
NS_NewLocalFile(Substring(aBuffer, cch), false, getter_AddRefs(workingDir));
|
||||
NS_NewLocalFile(Substring(aBuffer, cch), getter_AddRefs(workingDir));
|
||||
}
|
||||
|
||||
int argc = parser.Argc();
|
||||
@ -79,7 +79,7 @@ nsresult WinRemoteMessageReceiver::ParseV3(const nsACString& aBuffer) {
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLocalFile(
|
||||
NS_ConvertUTF8toUTF16(Substring(aBuffer, pos, nextNul - pos)), false,
|
||||
NS_ConvertUTF8toUTF16(Substring(aBuffer, pos, nextNul - pos)),
|
||||
getter_AddRefs(workingDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -81,8 +81,8 @@ const char* nsUnixRemoteServer::HandleCommandLine(
|
||||
const char* workingDir = aBuffer.data() + offsetFilelist;
|
||||
|
||||
nsCOMPtr<nsIFile> lf;
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(workingDir), true,
|
||||
getter_AddRefs(lf));
|
||||
nsresult rv =
|
||||
NS_NewNativeLocalFile(nsDependentCString(workingDir), getter_AddRefs(lf));
|
||||
if (NS_FAILED(rv)) {
|
||||
return "509 internal error";
|
||||
}
|
||||
|
@ -1070,8 +1070,7 @@ nsAppStartup::CreateInstanceWithProfile(nsIToolkitProfile* aProfile) {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> execPath;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(gAbsoluteArgv0Path, true, getter_AddRefs(execPath));
|
||||
nsresult rv = NS_NewLocalFile(gAbsoluteArgv0Path, getter_AddRefs(execPath));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ static inline void my_u64tostring(uint64_t aValue, char* aBuffer,
|
||||
|
||||
#ifdef XP_WIN
|
||||
static void CreateFileFromPath(const xpstring& path, nsIFile** file) {
|
||||
NS_NewLocalFile(nsDependentString(path.c_str()), false, file);
|
||||
NS_NewLocalFile(nsDependentString(path.c_str()), file);
|
||||
}
|
||||
|
||||
static std::optional<xpstring> CreatePathFromFile(nsIFile* file) {
|
||||
@ -429,7 +429,7 @@ static std::optional<xpstring> CreatePathFromFile(nsIFile* file) {
|
||||
}
|
||||
#else
|
||||
static void CreateFileFromPath(const xpstring& path, nsIFile** file) {
|
||||
NS_NewNativeLocalFile(nsDependentCString(path.c_str()), false, file);
|
||||
NS_NewNativeLocalFile(nsDependentCString(path.c_str()), file);
|
||||
}
|
||||
|
||||
MAYBE_UNUSED static std::optional<xpstring> CreatePathFromFile(nsIFile* file) {
|
||||
@ -2834,8 +2834,7 @@ static void SetCrashEventsDir(nsIFile* aDir) {
|
||||
|
||||
const char* env = PR_GetEnv("CRASHES_EVENTS_DIR");
|
||||
if (env && *env) {
|
||||
NS_NewNativeLocalFile(nsDependentCString(env), false,
|
||||
getter_AddRefs(eventsDir));
|
||||
NS_NewNativeLocalFile(nsDependentCString(env), getter_AddRefs(eventsDir));
|
||||
EnsureDirectoryExists(eventsDir);
|
||||
}
|
||||
|
||||
|
@ -428,12 +428,12 @@ Result<nsCOMPtr<nsIFile>, nsresult> Addon::FullPath() {
|
||||
|
||||
// First check for an absolute path, in case we have a proxy file.
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_SUCCEEDED(NS_NewLocalFile(path, false, getter_AddRefs(file)))) {
|
||||
if (NS_SUCCEEDED(NS_NewLocalFile(path, getter_AddRefs(file)))) {
|
||||
return std::move(file);
|
||||
}
|
||||
|
||||
// If not an absolute path, fall back to a relative path from the location.
|
||||
MOZ_TRY(NS_NewLocalFile(mLocation.Path(), false, getter_AddRefs(file)));
|
||||
MOZ_TRY(NS_NewLocalFile(mLocation.Path(), getter_AddRefs(file)));
|
||||
|
||||
MOZ_TRY(file->AppendRelativePath(path));
|
||||
return std::move(file);
|
||||
|
@ -200,7 +200,6 @@ nsresult ProfileUnlockerWin::TryToTerminate(RM_UNIQUE_PROCESS& aProcess) {
|
||||
}
|
||||
nsCOMPtr<nsIFile> otherProcessImageName;
|
||||
if (NS_FAILED(NS_NewLocalFile(nsDependentString(imageName, imageNameLen),
|
||||
false,
|
||||
getter_AddRefs(otherProcessImageName)))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -216,7 +215,7 @@ nsresult ProfileUnlockerWin::TryToTerminate(RM_UNIQUE_PROCESS& aProcess) {
|
||||
}
|
||||
nsCOMPtr<nsIFile> thisProcessImageName;
|
||||
if (NS_FAILED(NS_NewLocalFile(nsDependentString(imageName, imageNameLen),
|
||||
false, getter_AddRefs(thisProcessImageName)))) {
|
||||
getter_AddRefs(thisProcessImageName)))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAutoString thisProcessLeafName;
|
||||
|
@ -753,7 +753,7 @@ bool nsToolkitProfileService::IsProfileForCurrentInstall(
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> lastGreDir;
|
||||
rv = NS_NewNativeLocalFile(""_ns, false, getter_AddRefs(lastGreDir));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lastGreDir));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
rv = lastGreDir->SetPersistentDescriptor(lastGreDirStr);
|
||||
@ -1117,7 +1117,7 @@ nsresult nsToolkitProfileService::Init() {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> rootDir;
|
||||
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(rootDir));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(rootDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (isRelative) {
|
||||
@ -1615,7 +1615,7 @@ nsresult nsToolkitProfileService::SelectStartupProfile(
|
||||
nsCOMPtr<nsIToolkitProfile> profile;
|
||||
if (delim) {
|
||||
nsCOMPtr<nsIFile> lf;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(delim + 1), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(delim + 1),
|
||||
getter_AddRefs(lf));
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_fprintf(PR_STDERR, "Error: profile path not valid.\n");
|
||||
@ -2678,7 +2678,7 @@ nsresult nsToolkitProfileService::GetLocalDirFromRootDir(nsIFile* aRootDir,
|
||||
|
||||
nsCOMPtr<nsIFile> localDir;
|
||||
if (isRelative) {
|
||||
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localDir));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = localDir->SetRelativeDescriptor(
|
||||
@ -2717,7 +2717,7 @@ nsresult XRE_GetFileFromPath(const char* aPath, nsIFile** aResult) {
|
||||
if (!fullPath) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIFile> lf;
|
||||
nsresult rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(lf));
|
||||
nsresult rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lf));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocalFileMac> lfMac = do_QueryInterface(lf, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -2735,14 +2735,14 @@ nsresult XRE_GetFileFromPath(const char* aPath, nsIFile** aResult) {
|
||||
|
||||
if (!realpath(aPath, fullPath)) return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_NewNativeLocalFile(nsDependentCString(fullPath), true, aResult);
|
||||
return NS_NewNativeLocalFile(nsDependentCString(fullPath), aResult);
|
||||
#elif defined(XP_WIN)
|
||||
WCHAR fullPath[MAXPATHLEN];
|
||||
|
||||
if (!_wfullpath(fullPath, NS_ConvertUTF8toUTF16(aPath).get(), MAXPATHLEN))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_NewLocalFile(nsDependentString(fullPath), true, aResult);
|
||||
return NS_NewLocalFile(nsDependentString(fullPath), aResult);
|
||||
|
||||
#else
|
||||
# error Platform-specific logic needed here.
|
||||
|
@ -25,7 +25,7 @@ already_AddRefed<nsIFile> GetFileFromEnv(const char* name) {
|
||||
_MAX_PATH))
|
||||
return nullptr;
|
||||
|
||||
rv = NS_NewLocalFile(nsDependentString(path), true, getter_AddRefs(file));
|
||||
rv = NS_NewLocalFile(nsDependentString(path), getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) return nullptr;
|
||||
|
||||
return file.forget();
|
||||
@ -35,8 +35,7 @@ already_AddRefed<nsIFile> GetFileFromEnv(const char* name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(arg), true,
|
||||
getter_AddRefs(file));
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(arg), getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -283,8 +283,7 @@ already_AddRefed<nsIFile> GetNormalizedAppFile(nsIFile* aAppFile) {
|
||||
FSRef ref;
|
||||
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(appFile);
|
||||
if (macFile && NS_SUCCEEDED(macFile->GetFSRef(&ref)) &&
|
||||
NS_SUCCEEDED(
|
||||
NS_NewLocalFileWithFSRef(&ref, true, getter_AddRefs(macFile)))) {
|
||||
NS_SUCCEEDED(NS_NewLocalFileWithFSRef(&ref, getter_AddRefs(macFile)))) {
|
||||
appFile = static_cast<nsIFile*>(macFile);
|
||||
} else {
|
||||
NS_WARNING("Failed to resolve install directory.");
|
||||
|
@ -85,7 +85,7 @@ DynamicBlocklistWriter::DynamicBlocklistWriter(
|
||||
|
||||
nsresult DynamicBlocklistWriter::WriteToFile(const nsAString& aName) const {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
MOZ_TRY(NS_NewLocalFile(aName, true, getter_AddRefs(file)));
|
||||
MOZ_TRY(NS_NewLocalFile(aName, getter_AddRefs(file)));
|
||||
|
||||
nsCOMPtr<nsIOutputStream> stream;
|
||||
MOZ_TRY(NS_NewSafeLocalFileOutputStream(getter_AddRefs(stream), file));
|
||||
|
@ -83,7 +83,7 @@ bool ModuleEvaluator::ResolveKnownFolder(REFKNOWNFOLDERID aFolderId,
|
||||
|
||||
ShellStringUniquePtr path(rawPath);
|
||||
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(path.get()), false, aOutFile);
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(path.get()), aOutFile);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ ModuleRecord::ModuleRecord(const nsAString& aResolvedNtPath)
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(resolvedDosPath, false, getter_AddRefs(mResolvedDosName));
|
||||
NS_NewLocalFile(resolvedDosPath, getter_AddRefs(mResolvedDosName));
|
||||
if (NS_FAILED(rv) || !mResolvedDosName) {
|
||||
return;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ struct ParamTraits<mozilla::ModuleRecord> {
|
||||
if (resolvedDosName.IsEmpty()) {
|
||||
aResult->mResolvedDosName = nullptr;
|
||||
} else if (NS_FAILED(NS_NewLocalFile(
|
||||
resolvedDosName, false,
|
||||
resolvedDosName,
|
||||
getter_AddRefs(aResult->mResolvedDosName)))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1748,14 +1748,16 @@ nsXULAppInfo::SetServerURL(nsIURL* aServerURL) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAppInfo::GetMinidumpPath(nsIFile** aMinidumpPath) {
|
||||
if (!CrashReporter::GetEnabled()) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!CrashReporter::GetEnabled()) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsAutoString path;
|
||||
if (!CrashReporter::GetMinidumpPath(path)) return NS_ERROR_FAILURE;
|
||||
if (!CrashReporter::GetMinidumpPath(path)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLocalFile(path, false, aMinidumpPath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
return NS_NewLocalFile(path, aMinidumpPath);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -3447,7 +3449,7 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
|
||||
if (NS_FAILED(rv)) return false;
|
||||
|
||||
nsCOMPtr<nsIFile> lf;
|
||||
rv = NS_NewNativeLocalFile(""_ns, false, getter_AddRefs(lf));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lf));
|
||||
if (NS_FAILED(rv)) return false;
|
||||
|
||||
rv = lf->SetPersistentDescriptor(buf);
|
||||
@ -3461,7 +3463,7 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
|
||||
rv = parser.GetString("Compatibility", "LastAppDir", buf);
|
||||
if (NS_FAILED(rv)) return false;
|
||||
|
||||
rv = NS_NewNativeLocalFile(""_ns, false, getter_AddRefs(lf));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lf));
|
||||
if (NS_FAILED(rv)) return false;
|
||||
|
||||
rv = lf->SetPersistentDescriptor(buf);
|
||||
|
@ -296,7 +296,7 @@ static nsresult GetSystemParentDirectory(nsIFile** aFile) {
|
||||
"/usr/lib/mozilla"_ns
|
||||
# endif
|
||||
;
|
||||
rv = NS_NewNativeLocalFile(dirname, false, getter_AddRefs(localDir));
|
||||
rv = NS_NewNativeLocalFile(dirname, getter_AddRefs(localDir));
|
||||
# endif
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -401,7 +401,7 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
|
||||
# else
|
||||
static const char* const sysLExtDir = "/usr/share/mozilla/extensions";
|
||||
# endif
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(sysLExtDir), false,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(sysLExtDir),
|
||||
getter_AddRefs(file));
|
||||
# endif
|
||||
}
|
||||
@ -414,7 +414,7 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
|
||||
#if defined(XP_UNIX)
|
||||
nsPrintfCString path("/run/user/%d/%s/", getuid(), GetAppName());
|
||||
ToLowerCase(path);
|
||||
rv = NS_NewNativeLocalFile(path, false, getter_AddRefs(file));
|
||||
rv = NS_NewNativeLocalFile(path, getter_AddRefs(file));
|
||||
#endif
|
||||
} else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) {
|
||||
bool persistent = false;
|
||||
@ -825,7 +825,7 @@ nsresult nsXREDirProvider::GetInstallHash(nsAString& aPathHash) {
|
||||
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(installDir);
|
||||
rv = macFile->GetFSRef(&ref);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = NS_NewLocalFileWithFSRef(&ref, true, getter_AddRefs(macFile));
|
||||
rv = NS_NewLocalFileWithFSRef(&ref, getter_AddRefs(macFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
installDir = static_cast<nsIFile*>(macFile);
|
||||
#endif
|
||||
@ -1053,7 +1053,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
|
||||
OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
|
||||
NS_ENSURE_FALSE(err, NS_ERROR_FAILURE);
|
||||
|
||||
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localDir));
|
||||
rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(localDir);
|
||||
@ -1066,7 +1066,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
|
||||
#elif defined(XP_IOS)
|
||||
nsAutoCString userDir;
|
||||
if (GetUIKitDirectory(aLocal, userDir)) {
|
||||
rv = NS_NewNativeLocalFile(userDir, true, getter_AddRefs(localDir));
|
||||
rv = NS_NewNativeLocalFile(userDir, getter_AddRefs(localDir));
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1085,7 +1085,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir));
|
||||
rv = NS_NewLocalFile(path, getter_AddRefs(localDir));
|
||||
#elif defined(XP_UNIX)
|
||||
const char* homeDir = getenv("HOME");
|
||||
if (!homeDir || !*homeDir) return NS_ERROR_FAILURE;
|
||||
@ -1098,15 +1098,15 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
|
||||
// If $XDG_CACHE_HOME is defined use it, otherwise use $HOME/.cache.
|
||||
const char* cacheHome = getenv("XDG_CACHE_HOME");
|
||||
if (cacheHome && *cacheHome) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cacheHome), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cacheHome),
|
||||
getter_AddRefs(localDir));
|
||||
} else {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir),
|
||||
getter_AddRefs(localDir));
|
||||
if (NS_SUCCEEDED(rv)) rv = localDir->AppendNative(".cache"_ns);
|
||||
}
|
||||
} else {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir),
|
||||
getter_AddRefs(localDir));
|
||||
}
|
||||
#else
|
||||
|
@ -73,8 +73,8 @@ void CodeCoverageHandler::FlushCounters(const bool initialized) {
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(outDir), false,
|
||||
getter_AddRefs(file));
|
||||
nsresult rv =
|
||||
NS_NewNativeLocalFile(nsDependentCString(outDir), getter_AddRefs(file));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
rv = file->AppendNative(
|
||||
|
@ -141,10 +141,9 @@ class ScopedXPCOM final : public nsIDirectoryServiceProvider2 {
|
||||
return copy.forget();
|
||||
}
|
||||
|
||||
char* env = PR_GetEnv("MOZ_XRE_DIR");
|
||||
nsCOMPtr<nsIFile> greD;
|
||||
if (env) {
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(greD));
|
||||
if (char* env = PR_GetEnv("MOZ_XRE_DIR")) {
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(greD));
|
||||
}
|
||||
|
||||
mGRED = greD;
|
||||
|
@ -52,7 +52,7 @@ void MessageManagerFuzzer::ReadFile(const char* path,
|
||||
nsTArray<nsCString>& aArray) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true, getter_AddRefs(file));
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), getter_AddRefs(file));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
bool exists = false;
|
||||
|
@ -869,7 +869,7 @@ nsresult nsExternalHelperAppService::GetFileTokenForPath(
|
||||
nsDependentString platformAppPath(aPlatformAppPath);
|
||||
// First, check if we have an absolute path
|
||||
nsIFile* localFile = nullptr;
|
||||
nsresult rv = NS_NewLocalFile(platformAppPath, true, &localFile);
|
||||
nsresult rv = NS_NewLocalFile(platformAppPath, &localFile);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aFile = localFile;
|
||||
bool exists;
|
||||
|
@ -372,7 +372,7 @@ void nsMIMEInfoWin::UpdateDefaultInfoIfStale() {
|
||||
bool nsMIMEInfoWin::GetLocalHandlerApp(const nsAString& aCommandHandler,
|
||||
nsCOMPtr<nsILocalHandlerApp>& aApp) {
|
||||
nsCOMPtr<nsIFile> locfile;
|
||||
nsresult rv = NS_NewLocalFile(aCommandHandler, true, getter_AddRefs(locfile));
|
||||
nsresult rv = NS_NewLocalFile(aCommandHandler, getter_AddRefs(locfile));
|
||||
if (NS_FAILED(rv)) return false;
|
||||
|
||||
aApp = do_CreateInstance("@mozilla.org/uriloader/local-handler-app;1");
|
||||
|
@ -84,7 +84,7 @@ nsDeviceContextSpecAndroid::DoEndDocument() {
|
||||
nsAutoString targetPath;
|
||||
mPrintSettings->GetToFileName(targetPath);
|
||||
nsCOMPtr<nsIFile> destFile;
|
||||
MOZ_TRY(NS_NewLocalFile(targetPath, false, getter_AddRefs(destFile)));
|
||||
MOZ_TRY(NS_NewLocalFile(targetPath, getter_AddRefs(destFile)));
|
||||
nsAutoString destLeafName;
|
||||
MOZ_TRY(destFile->GetLeafName(destLeafName));
|
||||
|
||||
|
@ -4493,7 +4493,7 @@ static CFTypeRefPtr<CFURLRef> GetPasteLocation(NSPasteboard* aPasteboard) {
|
||||
stringFromPboardType:
|
||||
(NSString*)kPasteboardTypeFileURLPromise]]) {
|
||||
nsCOMPtr<nsIFile> targFile;
|
||||
NS_NewLocalFile(u""_ns, true, getter_AddRefs(targFile));
|
||||
NS_NewLocalFile(u""_ns, getter_AddRefs(targFile));
|
||||
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(targFile);
|
||||
if (!macLocalFile) {
|
||||
NS_ERROR("No Mac local file");
|
||||
|
@ -1726,7 +1726,7 @@ void nsCocoaUtils::SetTransferDataForTypeFromPasteboardItem(
|
||||
clipboardDataPtr[stringLength] = 0; // null terminate
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr), true,
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr),
|
||||
getter_AddRefs(file));
|
||||
free(clipboardDataPtr);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -359,7 +359,7 @@ nsIFilePicker::ResultCode nsFilePicker::GetLocalFiles(
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile));
|
||||
NS_NewLocalFile(u""_ns, getter_AddRefs(localFile));
|
||||
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
|
||||
if (macLocalFile &&
|
||||
NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)url))) {
|
||||
@ -414,7 +414,7 @@ nsIFilePicker::ResultCode nsFilePicker::GetLocalFolder(nsIFile** outFile) {
|
||||
NSURL* theURL = [[thePanel URLs] objectAtIndex:0];
|
||||
if (theURL) {
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile));
|
||||
NS_NewLocalFile(u""_ns, getter_AddRefs(localFile));
|
||||
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
|
||||
if (macLocalFile &&
|
||||
NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)theURL))) {
|
||||
@ -505,7 +505,7 @@ nsIFilePicker::ResultCode nsFilePicker::PutLocalFile(nsIFile** outFile) {
|
||||
NSURL* fileURL = [thePanel URL];
|
||||
if (fileURL) {
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile));
|
||||
NS_NewLocalFile(u""_ns, getter_AddRefs(localFile));
|
||||
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
|
||||
if (macLocalFile &&
|
||||
NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)fileURL))) {
|
||||
|
@ -756,7 +756,7 @@ bool MPRISServiceHandler::InitLocalImageFolder() {
|
||||
// The XDG_DATA_HOME points to the same location in the host and guest
|
||||
// filesystem.
|
||||
if (const auto* xdgDataHome = g_getenv("XDG_DATA_HOME")) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(xdgDataHome), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(xdgDataHome),
|
||||
getter_AddRefs(mLocalImageFolder));
|
||||
}
|
||||
} else {
|
||||
|
@ -96,7 +96,7 @@ already_AddRefed<PrintTarget> nsDeviceContextSpecGTK::MakePrintTarget() {
|
||||
return nullptr;
|
||||
}
|
||||
close(fd);
|
||||
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(buf), false,
|
||||
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(buf),
|
||||
getter_AddRefs(mSpoolFile)))) {
|
||||
unlink(buf);
|
||||
g_free(buf);
|
||||
@ -380,8 +380,7 @@ RefPtr<PrintEndDocumentPromise> nsDeviceContextSpecGTK::EndDocument() {
|
||||
nsCOMPtr<nsIFile> destFile;
|
||||
mPrintSettings->GetToFileName(targetPath);
|
||||
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(targetPath, false, getter_AddRefs(destFile));
|
||||
nsresult rv = NS_NewLocalFile(targetPath, getter_AddRefs(destFile));
|
||||
if (NS_FAILED(rv)) {
|
||||
return PrintEndDocumentPromise::CreateAndReject(rv, __func__);
|
||||
}
|
||||
|
@ -2162,7 +2162,7 @@ void nsDragSession::SourceDataGetXDND(nsITransferable* aItem,
|
||||
LOGDRAGSERVICE(" XdndDirectSave filepath is %s", fullpath.get());
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(fullpath.get()), false,
|
||||
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(fullpath.get()),
|
||||
getter_AddRefs(file)))) {
|
||||
LOGDRAGSERVICE(" failed to get local file");
|
||||
return;
|
||||
|
@ -182,7 +182,7 @@ void ReadMultipleFiles(gpointer filename, gpointer array) {
|
||||
nsCOMPtr<nsIFile> localfile;
|
||||
nsresult rv =
|
||||
NS_NewNativeLocalFile(nsDependentCString(static_cast<char*>(filename)),
|
||||
false, getter_AddRefs(localfile));
|
||||
getter_AddRefs(localfile));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMArray<nsIFile>& files = *static_cast<nsCOMArray<nsIFile>*>(array);
|
||||
files.AppendObject(localfile);
|
||||
|
@ -310,7 +310,7 @@ nsPrintSettingsGTK::SetToFileName(const nsAString& aToFileName) {
|
||||
"pdf");
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(aToFileName, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(aToFileName, getter_AddRefs(file));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Convert the nsIFile to a URL
|
||||
|
@ -177,7 +177,7 @@ mozilla::ipc::IPCResult nsFilePickerProxy::Recv__delete__(
|
||||
} else if (aData.type() == MaybeInputData::TInputDirectory) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
const nsAString& path(aData.get_InputDirectory().directoryPath());
|
||||
nsresult rv = NS_NewLocalFile(path, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(path, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ void JumpListBuilder::DeleteIconFromDisk(const nsAString& aPath) {
|
||||
if (StringTail(aPath, 4).LowerCaseEqualsASCII(".ico")) {
|
||||
// Construct the parent path of the passed in path
|
||||
nsCOMPtr<nsIFile> icoFile;
|
||||
nsresult rv = NS_NewLocalFile(aPath, true, getter_AddRefs(icoFile));
|
||||
nsresult rv = NS_NewLocalFile(aPath, getter_AddRefs(icoFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -960,8 +960,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject* aDataObject,
|
||||
// we have a file path in |data|. Create an nsLocalFile object.
|
||||
nsDependentString filepath(reinterpret_cast<char16_t*>(data));
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_SUCCEEDED(
|
||||
NS_NewLocalFile(filepath, false, getter_AddRefs(file)))) {
|
||||
if (NS_SUCCEEDED(NS_NewLocalFile(filepath, getter_AddRefs(file)))) {
|
||||
genericDataWrapper = do_QueryInterface(file);
|
||||
}
|
||||
free(data);
|
||||
@ -1159,7 +1158,7 @@ bool nsClipboard ::FindURLFromLocalFile(IDataObject* inDataObject, UINT inIndex,
|
||||
// file?
|
||||
const nsDependentString filepath(static_cast<char16_t*>(*outData));
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(filepath, true, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(filepath, getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
free(*outData);
|
||||
return dataFound;
|
||||
|
@ -361,7 +361,7 @@ RefPtr<PrintEndDocumentPromise> nsDeviceContextSpecWin::EndDocument() {
|
||||
|
||||
// We still need to move the file to its actual destination.
|
||||
nsCOMPtr<nsIFile> destFile;
|
||||
auto rv = NS_NewLocalFile(targetPath, false, getter_AddRefs(destFile));
|
||||
auto rv = NS_NewLocalFile(targetPath, getter_AddRefs(destFile));
|
||||
if (NS_FAILED(rv)) {
|
||||
return PrintEndDocumentPromise::CreateAndReject(rv, __func__);
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ nsFilePicker::ShowFilePicker(const nsString& aInitialDir) {
|
||||
// multiple selection
|
||||
for (auto const& str : paths) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_SUCCEEDED(NS_NewLocalFile(str, false, getter_AddRefs(file)))) {
|
||||
if (NS_SUCCEEDED(NS_NewLocalFile(str, getter_AddRefs(file)))) {
|
||||
self->mFiles.AppendObject(file);
|
||||
}
|
||||
}
|
||||
@ -908,7 +908,7 @@ nsresult nsFilePicker::Open(nsIFilePickerShownCallback* aCallback) {
|
||||
// file already exists.
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(self->mUnicodeFile, false, getter_AddRefs(file));
|
||||
NS_NewLocalFile(self->mUnicodeFile, getter_AddRefs(file));
|
||||
|
||||
bool flag = false;
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(file->Exists(&flag)) && flag) {
|
||||
@ -975,7 +975,7 @@ nsFilePicker::GetFile(nsIFile** aFile) {
|
||||
if (mUnicodeFile.IsEmpty()) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(mUnicodeFile, false, getter_AddRefs(file));
|
||||
nsresult rv = NS_NewLocalFile(mUnicodeFile, getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -1097,7 +1097,7 @@ void nsFilePicker::RememberLastUsedDirectory() {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_FAILED(NS_NewLocalFile(mUnicodeFile, false, getter_AddRefs(file)))) {
|
||||
if (NS_FAILED(NS_NewLocalFile(mUnicodeFile, getter_AddRefs(file)))) {
|
||||
NS_WARNING("RememberLastUsedDirectory failed to init file path.");
|
||||
return;
|
||||
}
|
||||
|
@ -1621,7 +1621,7 @@ class nsCycleCollectorLogSinkToFile final : public nsICycleCollectorLogSink {
|
||||
// wouldn't work.
|
||||
nsIFile* logFile = nullptr;
|
||||
if (char* env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, &logFile);
|
||||
NS_NewNativeLocalFile(nsCString(env), &logFile);
|
||||
}
|
||||
|
||||
// On Android or B2G, this function will open a file named
|
||||
|
@ -409,9 +409,8 @@ nsresult nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
|
||||
// For Android, first try the downloads directory which is world-readable
|
||||
// rather than the temp directory which is not.
|
||||
if (!*aFile) {
|
||||
char* env = PR_GetEnv("DOWNLOADS_DIRECTORY");
|
||||
if (env) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, aFile);
|
||||
if (char* env = PR_GetEnv("DOWNLOADS_DIRECTORY")) {
|
||||
NS_NewNativeLocalFile(nsCString(env), aFile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -122,8 +122,8 @@ bool nsMacUtilsImpl::GetAppPath(nsCString& aAppPath) {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> app;
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), true,
|
||||
getter_AddRefs(app));
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), getter_AddRefs(app));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
@ -326,8 +326,7 @@ static nsresult GetDirFromBundlePlist(const nsAString& aKey, nsIFile** aDir) {
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(dirPath), false,
|
||||
getter_AddRefs(dir));
|
||||
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(dirPath), getter_AddRefs(dir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = dir->Normalize();
|
||||
|
@ -615,7 +615,7 @@ nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
|
||||
// Create the file.
|
||||
|
||||
nsCOMPtr<nsIFile> reportsFile;
|
||||
nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(reportsFile));
|
||||
nsresult rv = NS_NewLocalFile(aFilename, getter_AddRefs(reportsFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -302,10 +302,9 @@ class BinaryPath {
|
||||
return rv;
|
||||
}
|
||||
# ifdef XP_WIN
|
||||
rv = NS_NewLocalFile(nsDependentString(exePath), true, getter_AddRefs(lf));
|
||||
rv = NS_NewLocalFile(nsDependentString(exePath), getter_AddRefs(lf));
|
||||
# else
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(exePath), true,
|
||||
getter_AddRefs(lf));
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(exePath), getter_AddRefs(lf));
|
||||
# endif
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
@ -141,11 +141,6 @@ XPCOM_API(nsresult) NS_GetComponentRegistrar(nsIComponentRegistrar** aResult);
|
||||
* error (NS_ERROR_FILE_UNRECOGNIZED_PATH).
|
||||
* |NS_NewNativeLocalFile|'s path must be in the
|
||||
* filesystem charset.
|
||||
* @param aFollowLinks
|
||||
* This attribute will determine if the nsLocalFile will auto
|
||||
* resolve symbolic links. By default, this value will be false
|
||||
* on all non unix systems. On unix, this attribute is effectively
|
||||
* a noop.
|
||||
* @param aResult Interface pointer to a new instance of an nsIFile
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
@ -155,18 +150,17 @@ XPCOM_API(nsresult) NS_GetComponentRegistrar(nsIComponentRegistrar** aResult);
|
||||
#ifdef __cplusplus
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsIFile** aResult);
|
||||
NS_NewLocalFile(const nsAString& aPath, nsIFile** aResult);
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowLinks,
|
||||
nsIFile** aResult);
|
||||
NS_NewNativeLocalFile(const nsACString& aPath, nsIFile** aResult);
|
||||
|
||||
// Use NS_NewLocalFile if you already have a UTF-16 string.
|
||||
// Otherwise non-ASCII paths will break on some platforms
|
||||
// including Windows.
|
||||
class NS_ConvertUTF16toUTF8;
|
||||
nsresult NS_NewNativeLocalFile(const NS_ConvertUTF16toUTF8& aPath,
|
||||
bool aFollowLinks, nsIFile** aResult) = delete;
|
||||
nsIFile** aResult) = delete;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -66,7 +66,7 @@ static nsresult GetKnownFolder(GUID* aGuid, nsIFile** aFile) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(path), true, aFile);
|
||||
nsresult rv = NS_NewLocalFile(nsDependentString(path), aFile);
|
||||
|
||||
CoTaskMemFree(path);
|
||||
return rv;
|
||||
@ -91,7 +91,7 @@ static nsresult GetWindowsFolder(int aFolder, nsIFile** aFile) {
|
||||
path[++len] = L'\0';
|
||||
}
|
||||
|
||||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -113,7 +113,7 @@ static nsresult GetLibrarySaveToPath(int aFallbackFolderId,
|
||||
nsAutoString path;
|
||||
path.Assign(str);
|
||||
path.Append('\\');
|
||||
nsresult rv = NS_NewLocalFile(path, false, aFile);
|
||||
nsresult rv = NS_NewLocalFile(path, aFile);
|
||||
CoTaskMemFree(str);
|
||||
return rv;
|
||||
}
|
||||
@ -154,7 +154,7 @@ static nsresult GetRegWindowsAppDataFolder(bool aLocal, nsIFile** aFile) {
|
||||
path[++len] = L'\0';
|
||||
}
|
||||
|
||||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
}
|
||||
|
||||
#endif // XP_WIN
|
||||
@ -165,8 +165,7 @@ static nsresult GetUnixHomeDir(nsIFile** aFile) {
|
||||
// XXX no home dir on android; maybe we should return the sdcard if present?
|
||||
return NS_ERROR_FAILURE;
|
||||
# else
|
||||
return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
|
||||
aFile);
|
||||
return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), aFile);
|
||||
# endif
|
||||
}
|
||||
|
||||
@ -199,7 +198,7 @@ static nsresult GetUnixSystemConfigDir(nsIFile** aFile) {
|
||||
if (sysConfigDir.IsEmpty()) {
|
||||
sysConfigDir.Assign(nsLiteralCString("/etc"));
|
||||
}
|
||||
MOZ_TRY(NS_NewNativeLocalFile(sysConfigDir, true, aFile));
|
||||
MOZ_TRY(NS_NewNativeLocalFile(sysConfigDir, aFile));
|
||||
MOZ_TRY((*aFile)->AppendNative(appName));
|
||||
return NS_OK;
|
||||
# endif
|
||||
@ -387,8 +386,7 @@ static nsresult GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
|
||||
nsCOMPtr<nsIFile> file;
|
||||
bool exists;
|
||||
if (dir) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(dir), true,
|
||||
getter_AddRefs(file));
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(dir), getter_AddRefs(file));
|
||||
free(dir);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -460,7 +458,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
if (!_wgetcwd(path, MAX_PATH)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_NewLocalFile(nsDependentString(path), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path), aFile);
|
||||
#else
|
||||
if (!getcwd(path, MAXPATHLEN)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -468,7 +466,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
#endif
|
||||
|
||||
#if !defined(XP_WIN)
|
||||
return NS_NewNativeLocalFile(nsDependentCString(path), true, aFile);
|
||||
return NS_NewNativeLocalFile(nsDependentCString(path), aFile);
|
||||
#endif
|
||||
|
||||
case OS_TemporaryDirectory:
|
||||
@ -478,7 +476,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
}
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
{
|
||||
@ -500,7 +498,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_NewNativeLocalFile(nsDependentCString(tPath), true, aFile);
|
||||
return NS_NewNativeLocalFile(nsDependentCString(tPath), aFile);
|
||||
}
|
||||
#else
|
||||
break;
|
||||
@ -554,7 +552,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
CFRangeMake(0, data.Length()),
|
||||
reinterpret_cast<UniChar*>(data.Elements()));
|
||||
|
||||
return NS_NewLocalFile(path, true, aFile);
|
||||
return NS_NewLocalFile(path, aFile);
|
||||
}
|
||||
#elif defined(XP_WIN)
|
||||
case Win_SystemDirectory: {
|
||||
@ -567,7 +565,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
path[len] = L'\\';
|
||||
path[++len] = L'\0';
|
||||
|
||||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
}
|
||||
|
||||
case Win_WindowsDirectory: {
|
||||
@ -581,7 +579,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
path[len] = L'\\';
|
||||
path[++len] = L'\0';
|
||||
|
||||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
}
|
||||
|
||||
case Win_ProgramFiles: {
|
||||
@ -604,7 +602,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
path[len] = L'\\';
|
||||
path[++len] = L'\0';
|
||||
|
||||
rv = NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
rv = NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -628,7 +626,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
path[len] = L'\\';
|
||||
path[++len] = L'\0';
|
||||
|
||||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
return NS_NewLocalFile(nsDependentString(path, len), aFile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -706,7 +704,7 @@ nsresult GetOSXFolderType(short aDomain, OSType aFolderType,
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (aFolderType == kTemporaryFolderType) {
|
||||
NS_NewLocalFile(u""_ns, true, aLocalFile);
|
||||
NS_NewLocalFile(u""_ns, aLocalFile);
|
||||
nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile));
|
||||
if (localMacFile) {
|
||||
rv = localMacFile->InitWithCFURL(
|
||||
@ -719,7 +717,7 @@ nsresult GetOSXFolderType(short aDomain, OSType aFolderType,
|
||||
FSRef fsRef;
|
||||
err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef);
|
||||
if (err == noErr) {
|
||||
NS_NewLocalFile(u""_ns, true, aLocalFile);
|
||||
NS_NewLocalFile(u""_ns, aLocalFile);
|
||||
nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile));
|
||||
if (localMacFile) {
|
||||
rv = localMacFile->InitWithFSRef(&fsRef);
|
||||
|
@ -183,7 +183,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
|
||||
nsCOMPtr<nsIFile> localDir;
|
||||
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localDir));
|
||||
NS_NewLocalFile(u""_ns, getter_AddRefs(localDir));
|
||||
if (!localDir) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -207,7 +207,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
|
||||
return rv;
|
||||
}
|
||||
#elif defined(XP_UNIX)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")),
|
||||
getter_AddRefs(localDir));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
@ -62,7 +62,7 @@ nsresult nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
|
||||
if (!greHome) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(greHome), true,
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(greHome),
|
||||
getter_AddRefs(mXCurProcD));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
@ -206,7 +206,7 @@ interface nsILocalFileMac : nsIFile
|
||||
%{C++
|
||||
extern "C"
|
||||
{
|
||||
NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowSymlinks, nsILocalFileMac** result);
|
||||
NS_EXPORT nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, bool aFollowSymlinks, nsILocalFileMac** result);
|
||||
NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, nsILocalFileMac** result);
|
||||
NS_EXPORT nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, nsILocalFileMac** result);
|
||||
}
|
||||
%}
|
||||
|
@ -1868,7 +1868,7 @@ nsLocalFile::GetParent(nsIFile** aParent) {
|
||||
*slashp = '\0';
|
||||
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(buffer), true,
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(buffer),
|
||||
getter_AddRefs(localFile));
|
||||
|
||||
// make buffer whole again
|
||||
@ -2418,8 +2418,7 @@ nsLocalFile::Launch() {
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowSymlinks,
|
||||
nsIFile** aResult) {
|
||||
nsresult NS_NewNativeLocalFile(const nsACString& aPath, nsIFile** aResult) {
|
||||
RefPtr<nsLocalFile> file = new nsLocalFile();
|
||||
|
||||
if (!aPath.IsEmpty()) {
|
||||
@ -2537,14 +2536,13 @@ nsresult nsLocalFile::GetTarget(nsAString& aResult) {
|
||||
GET_UCS(GetNativeTarget, aResult);
|
||||
}
|
||||
|
||||
nsresult NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks,
|
||||
nsIFile** aResult) {
|
||||
nsresult NS_NewLocalFile(const nsAString& aPath, nsIFile** aResult) {
|
||||
nsAutoCString buf;
|
||||
nsresult rv = NS_CopyUnicodeToNative(aPath, buf);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return NS_NewNativeLocalFile(buf, aFollowLinks, aResult);
|
||||
return NS_NewNativeLocalFile(buf, aResult);
|
||||
}
|
||||
|
||||
// nsILocalFileMac
|
||||
@ -3066,7 +3064,7 @@ NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile* aFile) {
|
||||
return InitWithNativePath(nativePath);
|
||||
}
|
||||
|
||||
nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowLinks,
|
||||
nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef,
|
||||
nsILocalFileMac** aResult) {
|
||||
RefPtr<nsLocalFile> file = new nsLocalFile();
|
||||
|
||||
@ -3078,7 +3076,7 @@ nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowLinks,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, bool aFollowLinks,
|
||||
nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL,
|
||||
nsILocalFileMac** aResult) {
|
||||
RefPtr<nsLocalFile> file = new nsLocalFile();
|
||||
|
||||
|
@ -3448,8 +3448,7 @@ nsLocalFile::Launch() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks,
|
||||
nsIFile** aResult) {
|
||||
nsresult NS_NewLocalFile(const nsAString& aPath, nsIFile** aResult) {
|
||||
RefPtr<nsLocalFile> file = new nsLocalFile();
|
||||
|
||||
if (!aPath.IsEmpty()) {
|
||||
@ -3622,15 +3621,14 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowLinks,
|
||||
nsIFile** aResult) {
|
||||
nsresult NS_NewNativeLocalFile(const nsACString& aPath, nsIFile** aResult) {
|
||||
nsAutoString buf;
|
||||
nsresult rv = NS_CopyNativeToUnicode(aPath, buf);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nullptr;
|
||||
return rv;
|
||||
}
|
||||
return NS_NewLocalFile(buf, aFollowLinks, aResult);
|
||||
return NS_NewLocalFile(buf, aResult);
|
||||
}
|
||||
|
||||
void nsLocalFile::EnsureShortPath() {
|
||||
|
@ -35,7 +35,7 @@ void print_err(nsresult err) {
|
||||
nsresult Register(nsIComponentRegistrar* registrar, const char* path) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv =
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true, getter_AddRefs(file));
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = registrar->AutoRegister(file);
|
||||
return rv;
|
||||
|
@ -155,10 +155,9 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 {
|
||||
return copy.forget();
|
||||
}
|
||||
|
||||
char* env = PR_GetEnv("MOZ_XRE_DIR");
|
||||
nsCOMPtr<nsIFile> greD;
|
||||
if (env) {
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(greD));
|
||||
if (char* env = PR_GetEnv("MOZ_XRE_DIR")) {
|
||||
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(greD));
|
||||
}
|
||||
|
||||
mGRED = greD;
|
||||
|
Loading…
Reference in New Issue
Block a user