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:
Emilio Cobos Álvarez 2024-10-22 09:38:16 +00:00
parent 6c0b4b7b4f
commit b5d2263c26
84 changed files with 178 additions and 214 deletions

View File

@ -162,7 +162,7 @@ static bool GetInstantiatorExecutable(const DWORD aPid,
} }
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(nsDependentString(buf.get(), bufLen), false, nsresult rv = NS_NewLocalFile(nsDependentString(buf.get(), bufLen),
getter_AddRefs(file)); getter_AddRefs(file));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;

View File

@ -224,8 +224,7 @@ nsMacShellService::OnStateChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP NS_IMETHODIMP
nsMacShellService::ShowDesktopPreferences() { nsMacShellService::ShowDesktopPreferences() {
nsCOMPtr<nsIFile> lf; nsCOMPtr<nsIFile> lf;
nsresult rv = nsresult rv = NS_NewNativeLocalFile(DESKTOP_PREFPANE, getter_AddRefs(lf));
NS_NewNativeLocalFile(DESKTOP_PREFPANE, true, getter_AddRefs(lf));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
bool exists; bool exists;
lf->Exists(&exists); lf->Exists(&exists);

View File

@ -1734,7 +1734,7 @@ static nsresult PinCurrentAppToTaskbarImpl(
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsAutoString exeStr(exePath); nsAutoString exeStr(exePath);
nsresult rv = NS_NewLocalFile(exeStr, true, getter_AddRefs(exeFile)); nsresult rv = NS_NewLocalFile(exeStr, getter_AddRefs(exeFile));
if (!NS_SUCCEEDED(rv)) { if (!NS_SUCCEEDED(rv)) {
return NS_ERROR_FILE_NOT_FOUND; return NS_ERROR_FILE_NOT_FOUND;
} }

View File

@ -695,7 +695,7 @@ already_AddRefed<Directory> ReadDirectoryInternal(
} }
nsCOMPtr<nsIFile> file; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr; return nullptr;
} }

View File

@ -392,8 +392,7 @@ already_AddRefed<FileSystemEntry> DataTransferItem::GetAsEntry(
nsCOMPtr<nsIFile> directoryFile; nsCOMPtr<nsIFile> directoryFile;
// fullPath is already in unicode, we don't have to use // fullPath is already in unicode, we don't have to use
// NS_NewNativeLocalFile. // NS_NewNativeLocalFile.
nsresult rv = nsresult rv = NS_NewLocalFile(fullpath, getter_AddRefs(directoryFile));
NS_NewLocalFile(fullpath, true, getter_AddRefs(directoryFile));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr; return nullptr;
} }

View File

@ -181,7 +181,7 @@ already_AddRefed<Promise> File::CreateFromFileName(
const ChromeFilePropertyBag& aBag, SystemCallerGuarantee aGuarantee, const ChromeFilePropertyBag& aBag, SystemCallerGuarantee aGuarantee,
ErrorResult& aRv) { ErrorResult& aRv) {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
aRv = NS_NewLocalFile(aPath, false, getter_AddRefs(file)); aRv = NS_NewLocalFile(aPath, getter_AddRefs(file));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return nullptr; return nullptr;
} }

View File

@ -73,7 +73,7 @@ nsresult FileCreatorParent::CreateBlobImpl(
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
nsCOMPtr<nsIFile> file; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

View File

@ -50,7 +50,7 @@ already_AddRefed<Directory> Directory::Constructor(const GlobalObject& aGlobal,
const nsAString& aRealPath, const nsAString& aRealPath,
ErrorResult& aRv) { ErrorResult& aRv) {
nsCOMPtr<nsIFile> path; nsCOMPtr<nsIFile> path;
aRv = NS_NewLocalFile(aRealPath, true, getter_AddRefs(path)); aRv = NS_NewLocalFile(aRealPath, getter_AddRefs(path));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return nullptr; return nullptr;
} }

View File

@ -41,7 +41,7 @@ bool FileSystemBase::GetRealPath(BlobImpl* aFile, nsIFile** aPath) const {
return false; return false;
} }
rv = NS_NewLocalFile(filePath, true, aPath); rv = NS_NewLocalFile(filePath, aPath);
if (NS_WARN_IF(rv.Failed())) { if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException(); rv.SuppressException();
return false; return false;
@ -77,7 +77,7 @@ void FileSystemBase::GetDOMPath(nsIFile* aFile, nsAString& aRetval,
aRetval.Truncate(); aRetval.Truncate();
nsCOMPtr<nsIFile> fileSystemPath; nsCOMPtr<nsIFile> fileSystemPath;
aRv = NS_NewLocalFile(LocalRootPath(), true, getter_AddRefs(fileSystemPath)); aRv = NS_NewLocalFile(LocalRootPath(), getter_AddRefs(fileSystemPath));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return; return;
} }

View File

@ -135,7 +135,7 @@ void GetDirectoryListingTaskChild::SetSuccessRequestResult(
data.get_FileSystemDirectoryListingResponseDirectory(); data.get_FileSystemDirectoryListingResponseDirectory();
nsCOMPtr<nsIFile> path; 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())) { if (NS_WARN_IF(aRv.Failed())) {
return; return;
} }
@ -184,8 +184,7 @@ GetDirectoryListingTaskParent::Create(
RefPtr<GetDirectoryListingTaskParent> task = RefPtr<GetDirectoryListingTaskParent> task =
new GetDirectoryListingTaskParent(aFileSystem, aParam, aParent); new GetDirectoryListingTaskParent(aFileSystem, aParam, aParent);
aRv = NS_NewLocalFile(aParam.realPath(), true, aRv = NS_NewLocalFile(aParam.realPath(), getter_AddRefs(task->mTargetPath));
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return nullptr; return nullptr;
} }
@ -214,8 +213,7 @@ FileSystemResponseValue GetDirectoryListingTaskParent::GetSuccessRequestResult(
for (unsigned i = 0; i < mTargetData.Length(); i++) { for (unsigned i = 0; i < mTargetData.Length(); i++) {
if (mTargetData[i].mType == FileOrDirectoryPath::eFilePath) { if (mTargetData[i].mType == FileOrDirectoryPath::eFilePath) {
nsCOMPtr<nsIFile> path; nsCOMPtr<nsIFile> path;
nsresult rv = nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, getter_AddRefs(path));
NS_NewLocalFile(mTargetData[i].mPath, true, getter_AddRefs(path));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
continue; continue;
} }
@ -393,8 +391,7 @@ nsresult GetDirectoryListingTaskParent::MainThreadWork() {
} }
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, getter_AddRefs(file));
NS_NewLocalFile(mTargetData[i].mPath, true, getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
continue; continue;
} }

View File

@ -103,7 +103,7 @@ void GetFileOrDirectoryTaskChild::SetSuccessRequestResult(
FileSystemDirectoryResponse r = aValue; FileSystemDirectoryResponse r = aValue;
nsCOMPtr<nsIFile> file; 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())) { if (NS_WARN_IF(aRv.Failed())) {
return; return;
} }
@ -163,8 +163,7 @@ GetFileOrDirectoryTaskParent::Create(
RefPtr<GetFileOrDirectoryTaskParent> task = RefPtr<GetFileOrDirectoryTaskParent> task =
new GetFileOrDirectoryTaskParent(aFileSystem, aParam, aParent); new GetFileOrDirectoryTaskParent(aFileSystem, aParam, aParent);
aRv = NS_NewLocalFile(aParam.realPath(), true, aRv = NS_NewLocalFile(aParam.realPath(), getter_AddRefs(task->mTargetPath));
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return nullptr; return nullptr;
} }

View File

@ -238,7 +238,7 @@ void GetFilesHelper::RunIO() {
MOZ_ASSERT(!mListingCompleted); MOZ_ASSERT(!mListingCompleted);
nsCOMPtr<nsIFile> file; 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))) { if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
return; return;
} }

View File

@ -155,8 +155,7 @@ already_AddRefed<GetFilesTaskParent> GetFilesTaskParent::Create(
RefPtr<GetFilesTaskParent> task = RefPtr<GetFilesTaskParent> task =
new GetFilesTaskParent(aFileSystem, aParam, aParent); new GetFilesTaskParent(aFileSystem, aParam, aParent);
aRv = NS_NewLocalFile(aParam.realPath(), true, aRv = NS_NewLocalFile(aParam.realPath(), getter_AddRefs(task->mTargetPath));
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return nullptr; return nullptr;
} }

View File

@ -397,7 +397,7 @@ static already_AddRefed<nsIFile> LastUsedDirectory(
} }
nsCOMPtr<nsIFile> localFile; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr; return nullptr;
} }
@ -2164,7 +2164,7 @@ void HTMLInputElement::MozSetFileNameArray(const Sequence<nsString>& aFileNames,
if (!file) { if (!file) {
// this is no "file://", try as local 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) { if (!file) {
@ -2197,7 +2197,7 @@ void HTMLInputElement::MozSetDirectory(const nsAString& aDirectoryPath,
} }
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
aRv = NS_NewLocalFile(aDirectoryPath, true, getter_AddRefs(file)); aRv = NS_NewLocalFile(aDirectoryPath, getter_AddRefs(file));
if (NS_WARN_IF(aRv.Failed())) { if (NS_WARN_IF(aRv.Failed())) {
return; return;
} }
@ -6285,8 +6285,7 @@ static nsTArray<OwningFileOrDirectory> RestoreFileContentData(
} else { } else {
MOZ_ASSERT(it.type() == FileContentData::TnsString); MOZ_ASSERT(it.type() == FileContentData::TnsString);
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = nsresult rv = NS_NewLocalFile(it.get_nsString(), getter_AddRefs(file));
NS_NewLocalFile(it.get_nsString(), true, getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
continue; continue;
} }

View File

@ -253,7 +253,7 @@ bool GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) {
MOZ_CRASH(explain); \ MOZ_CRASH(explain); \
} while (false) } 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
GMP_PATH_CRASH("Failed to create file for plugin path"); GMP_PATH_CRASH("Failed to create file for plugin path");
return false; return false;
@ -310,7 +310,7 @@ bool GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) {
bool GMPChild::GetPluginName(nsACString& aPluginName) const { bool GMPChild::GetPluginName(nsACString& aPluginName) const {
// Extract the plugin directory name if possible. // Extract the plugin directory name if possible.
nsCOMPtr<nsIFile> libFile; 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); NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIFile> parent; nsCOMPtr<nsIFile> parent;
@ -463,8 +463,7 @@ GMPChild::MakeCDMHostVerificationPaths(const nsACString& aPluginLibPath) {
CopyUTF8toUTF16(nsDependentCString(pluginContainer.c_str()), str); CopyUTF8toUTF16(nsDependentCString(pluginContainer.c_str()), str);
nsCOMPtr<nsIFile> path; nsCOMPtr<nsIFile> path;
if (NS_FAILED(NS_NewLocalFile(str, true, /* aFollowLinks */ if (NS_FAILED(NS_NewLocalFile(str, getter_AddRefs(path))) ||
getter_AddRefs(path))) ||
!AppendHostPath(path, paths)) { !AppendHostPath(path, paths)) {
// Without successfully determining plugin-container's path, we can't // Without successfully determining plugin-container's path, we can't
// determine libxul's or Firefox's. So give up. // determine libxul's or Firefox's. So give up.

View File

@ -277,7 +277,7 @@ bool GMPProcessParent::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
"plugin dir path: %s", "plugin dir path: %s",
mGMPPath.c_str()); mGMPPath.c_str());
nsCOMPtr<nsIFile> pluginDir; 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)); getter_AddRefs(pluginDir));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
GMP_LOG_DEBUG( GMP_LOG_DEBUG(
@ -347,8 +347,8 @@ bool GMPProcessParent::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
nsresult GMPProcessParent::NormalizePath(const char* aPath, nsresult GMPProcessParent::NormalizePath(const char* aPath,
PathString& aNormalizedPath) { PathString& aNormalizedPath) {
nsCOMPtr<nsIFile> fileOrDir; nsCOMPtr<nsIFile> fileOrDir;
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(aPath), true, nsresult rv =
getter_AddRefs(fileOrDir)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(aPath), getter_AddRefs(fileOrDir));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fileOrDir->Normalize(); rv = fileOrDir->Normalize();

View File

@ -1068,7 +1068,7 @@ RefPtr<GenericPromise> GeckoMediaPluginServiceParent::AddOnGMPThread(
GMP_LOG_DEBUG("%s::%s: %s", __CLASS__, __FUNCTION__, dir.get()); GMP_LOG_DEBUG("%s::%s: %s", __CLASS__, __FUNCTION__, dir.get());
nsCOMPtr<nsIFile> directory; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
GMP_LOG_DEBUG("%s::%s: failed to create nsIFile for dir=%s rv=%" PRIx32, GMP_LOG_DEBUG("%s::%s: failed to create nsIFile for dir=%s rv=%" PRIx32,
__CLASS__, __FUNCTION__, dir.get(), __CLASS__, __FUNCTION__, dir.get(),
@ -1110,7 +1110,7 @@ void GeckoMediaPluginServiceParent::RemoveOnGMPThread(
NS_LossyConvertUTF16toASCII(aDirectory).get()); NS_LossyConvertUTF16toASCII(aDirectory).get());
nsCOMPtr<nsIFile> directory; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }

View File

@ -135,8 +135,7 @@ void CacheUseDOSDevicePathSyntaxPrefValue() {
Result<nsCOMPtr<nsIFile>, nsresult> QM_NewLocalFile(const nsAString& aPath) { Result<nsCOMPtr<nsIFile>, nsresult> QM_NewLocalFile(const nsAString& aPath) {
QM_TRY_UNWRAP( QM_TRY_UNWRAP(
auto file, auto file,
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, NS_NewLocalFile, aPath, MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, NS_NewLocalFile, aPath),
/* aFollowLinks */ false),
QM_PROPAGATE, [&aPath](const nsresult rv) { QM_PROPAGATE, [&aPath](const nsresult rv) {
QM_WARNING("Failed to construct a file for path (%s)", QM_WARNING("Failed to construct a file for path (%s)",
NS_ConvertUTF16toUTF8(aPath).get()); NS_ConvertUTF16toUTF8(aPath).get());

View File

@ -243,7 +243,7 @@ void mozHunspell::LoadDictionaryList(bool aNotifyChildProcesses) {
rv = prefs->GetCharPref("spellchecker.dictionary_path", extDictPath); rv = prefs->GetCharPref("spellchecker.dictionary_path", extDictPath);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// set the spellchecker.dictionary_path // set the spellchecker.dictionary_path
rv = NS_NewNativeLocalFile(extDictPath, true, getter_AddRefs(dictDir)); rv = NS_NewNativeLocalFile(extDictPath, getter_AddRefs(dictDir));
} }
if (dictDir) { if (dictDir) {
LoadDictionariesFromDir(dictDir); LoadDictionariesFromDir(dictDir);
@ -262,8 +262,7 @@ void mozHunspell::LoadDictionaryList(bool aNotifyChildProcesses) {
char* nextPaths = env.BeginWriting(); char* nextPaths = env.BeginWriting();
while ((currPath = NS_strtok(":", &nextPaths))) { while ((currPath = NS_strtok(":", &nextPaths))) {
nsCOMPtr<nsIFile> dir; nsCOMPtr<nsIFile> dir;
rv = rv = NS_NewNativeLocalFile(nsCString(currPath), getter_AddRefs(dir));
NS_NewNativeLocalFile(nsCString(currPath), true, getter_AddRefs(dir));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
dirs.AppendElement(dir); dirs.AppendElement(dir);
} }

View File

@ -546,7 +546,7 @@ mozilla::BinPathType BaseProcessLauncher::GetPathToBinary(
exePath = FilePath(char16ptr_t(gGREBinPath)); exePath = FilePath(char16ptr_t(gGREBinPath));
#elif MOZ_WIDGET_COCOA #elif MOZ_WIDGET_COCOA
nsCOMPtr<nsIFile> childProcPath; nsCOMPtr<nsIFile> childProcPath;
NS_NewLocalFile(nsDependentString(gGREBinPath), false, NS_NewLocalFile(nsDependentString(gGREBinPath),
getter_AddRefs(childProcPath)); getter_AddRefs(childProcPath));
// We need to use an App Bundle on OS X so that we can hide // We need to use an App Bundle on OS X so that we can hide

View File

@ -630,8 +630,8 @@ size_t URLPreloader::ShallowSizeOfIncludingThis(
Result<FileLocation, nsresult> URLPreloader::CacheKey::ToFileLocation() { Result<FileLocation, nsresult> URLPreloader::CacheKey::ToFileLocation() {
if (mType == TypeFile) { if (mType == TypeFile) {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
MOZ_TRY(NS_NewLocalFile(NS_ConvertUTF8toUTF16(mPath), false, MOZ_TRY(
getter_AddRefs(file))); NS_NewLocalFile(NS_ConvertUTF8toUTF16(mPath), getter_AddRefs(file)));
return FileLocation(file); return FileLocation(file);
} }

View File

@ -181,8 +181,7 @@ static bool GetLocationProperty(JSContext* cx, unsigned argc, Value* vp) {
# endif # endif
nsCOMPtr<nsIFile> location; nsCOMPtr<nsIFile> location;
nsresult rv = nsresult rv = NS_NewLocalFile(filenameString, getter_AddRefs(location));
NS_NewLocalFile(filenameString, false, getter_AddRefs(location));
if (!location && gWorkingDirectory) { if (!location && gWorkingDirectory) {
// could be a relative path, try appending it to the cwd // 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); nsAutoString absolutePath(*gWorkingDirectory);
absolutePath.Append(filenameString); absolutePath.Append(filenameString);
rv = NS_NewLocalFile(absolutePath, false, getter_AddRefs(location)); rv = NS_NewLocalFile(absolutePath, getter_AddRefs(location));
} }
if (location) { if (location) {
@ -1152,7 +1151,7 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
printf("GetCurrentWorkingDirectory failed.\n"); printf("GetCurrentWorkingDirectory failed.\n");
return 1; return 1;
} }
rv = NS_NewLocalFile(workingDir, true, getter_AddRefs(greDir)); rv = NS_NewLocalFile(workingDir, getter_AddRefs(greDir));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
printf("NS_NewLocalFile failed.\n"); printf("NS_NewLocalFile failed.\n");
return 1; return 1;

View File

@ -179,7 +179,7 @@ static void AppendBlobImplAsDirectory(nsTArray<OwningFileOrDirectory>& aArray,
} }
nsCOMPtr<nsIFile> file; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }

View File

@ -861,7 +861,7 @@ nsZipReaderCache::Observe(nsISupports* aSubject, const char* aTopic,
file = do_QueryInterface(aSubject); file = do_QueryInterface(aSubject);
} else if (aSomeData) { } else if (aSomeData) {
nsDependentString fileName(aSomeData); nsDependentString fileName(aSomeData);
Unused << NS_NewLocalFile(fileName, false, getter_AddRefs(file)); Unused << NS_NewLocalFile(fileName, getter_AddRefs(file));
} }
if (!file) return NS_OK; if (!file) return NS_OK;

View File

@ -97,8 +97,8 @@ class ZipArchiveLogger {
if (!mFd) { if (!mFd) {
nsCOMPtr<nsIFile> logFile; nsCOMPtr<nsIFile> logFile;
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, nsresult rv =
getter_AddRefs(logFile)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(logFile));
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
// Create the log file and its parent directory (in case it doesn't exist) // Create the log file and its parent directory (in case it doesn't exist)

View File

@ -2568,7 +2568,7 @@ nsPrefBranch::GetComplexValue(const char* aPrefName, const nsIID& aType,
} }
nsCOMPtr<nsIFile> theFile; nsCOMPtr<nsIFile> theFile;
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(theFile)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(theFile));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }

View File

@ -143,7 +143,7 @@ nsresult net_GetFileFromURLSpec(const nsACString& aURL, nsIFile** result) {
nsresult rv; nsresult rv;
nsCOMPtr<nsIFile> localFile; nsCOMPtr<nsIFile> localFile;
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localFile)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localFile));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsAutoCString directory, fileBaseName, fileExtension, path; nsAutoCString directory, fileBaseName, fileExtension, path;

View File

@ -57,7 +57,7 @@ nsresult net_GetFileFromURLSpec(const nsACString& aURL, nsIFile** result) {
nsresult rv; nsresult rv;
nsCOMPtr<nsIFile> localFile; nsCOMPtr<nsIFile> localFile;
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localFile)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localFile));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsAutoCString directory, fileBaseName, fileExtension, path; nsAutoCString directory, fileBaseName, fileExtension, path;

View File

@ -1311,7 +1311,7 @@ nsresult CacheFileIOManager::OnProfile() {
nsCOMPtr<nsIFile> profilelessDirectory; nsCOMPtr<nsIFile> profilelessDirectory;
char* cachePath = getenv("CACHE_DIRECTORY"); char* cachePath = getenv("CACHE_DIRECTORY");
if (!directory && cachePath && *cachePath) { if (!directory && cachePath && *cachePath) {
rv = NS_NewNativeLocalFile(nsDependentCString(cachePath), true, rv = NS_NewNativeLocalFile(nsDependentCString(cachePath),
getter_AddRefs(directory)); getter_AddRefs(directory));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Save this directory as the profileless path. // Save this directory as the profileless path.

View File

@ -262,12 +262,11 @@ nsresult nsFileChannel::Init() {
NS_SUCCEEDED(file->IsSymlink(&symLink)) && symLink && NS_SUCCEEDED(file->IsSymlink(&symLink)) && symLink &&
#ifdef XP_WIN #ifdef XP_WIN
NS_SUCCEEDED(file->GetTarget(fileTarget)) && NS_SUCCEEDED(file->GetTarget(fileTarget)) &&
NS_SUCCEEDED( NS_SUCCEEDED(NS_NewLocalFile(fileTarget, getter_AddRefs(resolvedFile))) &&
NS_NewLocalFile(fileTarget, true, getter_AddRefs(resolvedFile))) &&
#else #else
NS_SUCCEEDED(file->GetNativeTarget(fileTarget)) && NS_SUCCEEDED(file->GetNativeTarget(fileTarget)) &&
NS_SUCCEEDED(NS_NewNativeLocalFile(fileTarget, true, NS_SUCCEEDED(
getter_AddRefs(resolvedFile))) && NS_NewNativeLocalFile(fileTarget, getter_AddRefs(resolvedFile))) &&
#endif #endif
NS_SUCCEEDED( NS_SUCCEEDED(
NS_NewFileURI(getter_AddRefs(targetURI), resolvedFile, nullptr))) { NS_NewFileURI(getter_AddRefs(targetURI), resolvedFile, nullptr))) {

View File

@ -151,8 +151,8 @@ nsFileProtocolHandler::ReadShellLink(nsIFile* aFile, nsIURI** aURI) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsCOMPtr<nsIFile> linkedFile; nsCOMPtr<nsIFile> linkedFile;
MOZ_TRY(NS_NewLocalFile(nsDependentString(lpTemp), false, MOZ_TRY(
getter_AddRefs(linkedFile))); NS_NewLocalFile(nsDependentString(lpTemp), getter_AddRefs(linkedFile)));
return NS_NewFileURI(aURI, linkedFile); return NS_NewFileURI(aURI, linkedFile);
#else #else
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;

View File

@ -1944,8 +1944,8 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
nsCOMPtr<nsIFile> qlogDir; nsCOMPtr<nsIFile> qlogDir;
if (Preferences::GetBool(HTTP_PREF("http3.enable_qlog")) && if (Preferences::GetBool(HTTP_PREF("http3.enable_qlog")) &&
!mHttp3QlogDir.IsEmpty() && !mHttp3QlogDir.IsEmpty() &&
NS_SUCCEEDED(NS_NewNativeLocalFile(mHttp3QlogDir, false, NS_SUCCEEDED(
getter_AddRefs(qlogDir)))) { NS_NewNativeLocalFile(mHttp3QlogDir, getter_AddRefs(qlogDir)))) {
// Here we do main thread IO, but since this only happens // Here we do main thread IO, but since this only happens
// when enabling a developer feature it's not a problem for users. // when enabling a developer feature it's not a problem for users.
rv = qlogDir->Create(nsIFile::DIRECTORY_TYPE, 0755); rv = qlogDir->Create(nsIFile::DIRECTORY_TYPE, 0755);

View File

@ -556,7 +556,7 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() {
// GetSpecialSystemDirectory(Unix_XDG_ConfigHome) ? // GetSpecialSystemDirectory(Unix_XDG_ConfigHome) ?
nsCOMPtr<nsIFile> confDirOrXDGConfigHomeDir; nsCOMPtr<nsIFile> confDirOrXDGConfigHomeDir;
if (!xdgConfigHome.IsEmpty()) { if (!xdgConfigHome.IsEmpty()) {
rv = NS_NewNativeLocalFile(xdgConfigHome, true, rv = NS_NewNativeLocalFile(xdgConfigHome,
getter_AddRefs(confDirOrXDGConfigHomeDir)); getter_AddRefs(confDirOrXDGConfigHomeDir));
// confDirOrXDGConfigHomeDir = nsIFile($XDG_CONFIG_HOME) // confDirOrXDGConfigHomeDir = nsIFile($XDG_CONFIG_HOME)
} else { } else {

View File

@ -186,8 +186,7 @@ nsresult StartupCache::Init() {
// cache in. // cache in.
char* env = PR_GetEnv("MOZ_STARTUP_CACHE"); char* env = PR_GetEnv("MOZ_STARTUP_CACHE");
if (env && *env) { if (env && *env) {
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(mFile));
getter_AddRefs(mFile));
} else { } else {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
rv = NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(file)); rv = NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(file));

View File

@ -138,8 +138,8 @@ int RunGTestFunc(int* argc, char** argv) {
char* path = PR_GetEnv("MOZ_GTEST_MINIDUMPS_PATH"); char* path = PR_GetEnv("MOZ_GTEST_MINIDUMPS_PATH");
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
if (path) { if (path) {
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true, nsresult rv =
getter_AddRefs(file)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), getter_AddRefs(file));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
printf_stderr("Ignoring invalid MOZ_GTEST_MINIDUMPS_PATH\n"); printf_stderr("Ignoring invalid MOZ_GTEST_MINIDUMPS_PATH\n");
} }

View File

@ -1674,7 +1674,7 @@ ContentAnalysis::MaybeExpandAndAnalyzeFolderContentRequest(
#endif #endif
RefPtr<nsIFile> file; RefPtr<nsIFile> file;
rv = NS_NewLocalFile(filename, false, getter_AddRefs(file)); rv = NS_NewLocalFile(filename, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, Err(rv)); NS_ENSURE_SUCCESS(rv, Err(rv));
bool exists; bool exists;

View File

@ -39,7 +39,7 @@ nsresult WinRemoteMessageReceiver::ParseV2(const nsAString& aBuffer) {
nsCOMPtr<nsIFile> workingDir; nsCOMPtr<nsIFile> workingDir;
if (cch < aBuffer.Length()) { 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(); int argc = parser.Argc();
@ -79,7 +79,7 @@ nsresult WinRemoteMessageReceiver::ParseV3(const nsACString& aBuffer) {
} }
nsresult rv = NS_NewLocalFile( nsresult rv = NS_NewLocalFile(
NS_ConvertUTF8toUTF16(Substring(aBuffer, pos, nextNul - pos)), false, NS_ConvertUTF8toUTF16(Substring(aBuffer, pos, nextNul - pos)),
getter_AddRefs(workingDir)); getter_AddRefs(workingDir));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -81,8 +81,8 @@ const char* nsUnixRemoteServer::HandleCommandLine(
const char* workingDir = aBuffer.data() + offsetFilelist; const char* workingDir = aBuffer.data() + offsetFilelist;
nsCOMPtr<nsIFile> lf; nsCOMPtr<nsIFile> lf;
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(workingDir), true, nsresult rv =
getter_AddRefs(lf)); NS_NewNativeLocalFile(nsDependentCString(workingDir), getter_AddRefs(lf));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return "509 internal error"; return "509 internal error";
} }

View File

@ -1070,8 +1070,7 @@ nsAppStartup::CreateInstanceWithProfile(nsIToolkitProfile* aProfile) {
} }
nsCOMPtr<nsIFile> execPath; nsCOMPtr<nsIFile> execPath;
nsresult rv = nsresult rv = NS_NewLocalFile(gAbsoluteArgv0Path, getter_AddRefs(execPath));
NS_NewLocalFile(gAbsoluteArgv0Path, true, getter_AddRefs(execPath));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

View File

@ -416,7 +416,7 @@ static inline void my_u64tostring(uint64_t aValue, char* aBuffer,
#ifdef XP_WIN #ifdef XP_WIN
static void CreateFileFromPath(const xpstring& path, nsIFile** file) { 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) { static std::optional<xpstring> CreatePathFromFile(nsIFile* file) {
@ -429,7 +429,7 @@ static std::optional<xpstring> CreatePathFromFile(nsIFile* file) {
} }
#else #else
static void CreateFileFromPath(const xpstring& path, nsIFile** file) { 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) { 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"); const char* env = PR_GetEnv("CRASHES_EVENTS_DIR");
if (env && *env) { if (env && *env) {
NS_NewNativeLocalFile(nsDependentCString(env), false, NS_NewNativeLocalFile(nsDependentCString(env), getter_AddRefs(eventsDir));
getter_AddRefs(eventsDir));
EnsureDirectoryExists(eventsDir); EnsureDirectoryExists(eventsDir);
} }

View File

@ -428,12 +428,12 @@ Result<nsCOMPtr<nsIFile>, nsresult> Addon::FullPath() {
// First check for an absolute path, in case we have a proxy file. // First check for an absolute path, in case we have a proxy file.
nsCOMPtr<nsIFile> 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); return std::move(file);
} }
// If not an absolute path, fall back to a relative path from the location. // 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)); MOZ_TRY(file->AppendRelativePath(path));
return std::move(file); return std::move(file);

View File

@ -200,7 +200,6 @@ nsresult ProfileUnlockerWin::TryToTerminate(RM_UNIQUE_PROCESS& aProcess) {
} }
nsCOMPtr<nsIFile> otherProcessImageName; nsCOMPtr<nsIFile> otherProcessImageName;
if (NS_FAILED(NS_NewLocalFile(nsDependentString(imageName, imageNameLen), if (NS_FAILED(NS_NewLocalFile(nsDependentString(imageName, imageNameLen),
false,
getter_AddRefs(otherProcessImageName)))) { getter_AddRefs(otherProcessImageName)))) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -216,7 +215,7 @@ nsresult ProfileUnlockerWin::TryToTerminate(RM_UNIQUE_PROCESS& aProcess) {
} }
nsCOMPtr<nsIFile> thisProcessImageName; nsCOMPtr<nsIFile> thisProcessImageName;
if (NS_FAILED(NS_NewLocalFile(nsDependentString(imageName, imageNameLen), if (NS_FAILED(NS_NewLocalFile(nsDependentString(imageName, imageNameLen),
false, getter_AddRefs(thisProcessImageName)))) { getter_AddRefs(thisProcessImageName)))) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsAutoString thisProcessLeafName; nsAutoString thisProcessLeafName;

View File

@ -753,7 +753,7 @@ bool nsToolkitProfileService::IsProfileForCurrentInstall(
} }
nsCOMPtr<nsIFile> lastGreDir; nsCOMPtr<nsIFile> lastGreDir;
rv = NS_NewNativeLocalFile(""_ns, false, getter_AddRefs(lastGreDir)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lastGreDir));
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, false);
rv = lastGreDir->SetPersistentDescriptor(lastGreDirStr); rv = lastGreDir->SetPersistentDescriptor(lastGreDirStr);
@ -1117,7 +1117,7 @@ nsresult nsToolkitProfileService::Init() {
} }
nsCOMPtr<nsIFile> rootDir; nsCOMPtr<nsIFile> rootDir;
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(rootDir)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(rootDir));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (isRelative) { if (isRelative) {
@ -1615,7 +1615,7 @@ nsresult nsToolkitProfileService::SelectStartupProfile(
nsCOMPtr<nsIToolkitProfile> profile; nsCOMPtr<nsIToolkitProfile> profile;
if (delim) { if (delim) {
nsCOMPtr<nsIFile> lf; nsCOMPtr<nsIFile> lf;
rv = NS_NewNativeLocalFile(nsDependentCString(delim + 1), true, rv = NS_NewNativeLocalFile(nsDependentCString(delim + 1),
getter_AddRefs(lf)); getter_AddRefs(lf));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
PR_fprintf(PR_STDERR, "Error: profile path not valid.\n"); PR_fprintf(PR_STDERR, "Error: profile path not valid.\n");
@ -2678,7 +2678,7 @@ nsresult nsToolkitProfileService::GetLocalDirFromRootDir(nsIFile* aRootDir,
nsCOMPtr<nsIFile> localDir; nsCOMPtr<nsIFile> localDir;
if (isRelative) { if (isRelative) {
rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(localDir)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(localDir));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = localDir->SetRelativeDescriptor( rv = localDir->SetRelativeDescriptor(
@ -2717,7 +2717,7 @@ nsresult XRE_GetFileFromPath(const char* aPath, nsIFile** aResult) {
if (!fullPath) return NS_ERROR_FAILURE; if (!fullPath) return NS_ERROR_FAILURE;
nsCOMPtr<nsIFile> lf; nsCOMPtr<nsIFile> lf;
nsresult rv = NS_NewNativeLocalFile(""_ns, true, getter_AddRefs(lf)); nsresult rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lf));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFileMac> lfMac = do_QueryInterface(lf, &rv); nsCOMPtr<nsILocalFileMac> lfMac = do_QueryInterface(lf, &rv);
if (NS_SUCCEEDED(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; 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) #elif defined(XP_WIN)
WCHAR fullPath[MAXPATHLEN]; WCHAR fullPath[MAXPATHLEN];
if (!_wfullpath(fullPath, NS_ConvertUTF8toUTF16(aPath).get(), MAXPATHLEN)) if (!_wfullpath(fullPath, NS_ConvertUTF8toUTF16(aPath).get(), MAXPATHLEN))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
return NS_NewLocalFile(nsDependentString(fullPath), true, aResult); return NS_NewLocalFile(nsDependentString(fullPath), aResult);
#else #else
# error Platform-specific logic needed here. # error Platform-specific logic needed here.

View File

@ -25,7 +25,7 @@ already_AddRefed<nsIFile> GetFileFromEnv(const char* name) {
_MAX_PATH)) _MAX_PATH))
return nullptr; 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; if (NS_FAILED(rv)) return nullptr;
return file.forget(); return file.forget();
@ -35,8 +35,7 @@ already_AddRefed<nsIFile> GetFileFromEnv(const char* name) {
return nullptr; return nullptr;
} }
rv = NS_NewNativeLocalFile(nsDependentCString(arg), true, rv = NS_NewNativeLocalFile(nsDependentCString(arg), getter_AddRefs(file));
getter_AddRefs(file));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return nullptr; return nullptr;
} }

View File

@ -283,8 +283,7 @@ already_AddRefed<nsIFile> GetNormalizedAppFile(nsIFile* aAppFile) {
FSRef ref; FSRef ref;
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(appFile); nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(appFile);
if (macFile && NS_SUCCEEDED(macFile->GetFSRef(&ref)) && if (macFile && NS_SUCCEEDED(macFile->GetFSRef(&ref)) &&
NS_SUCCEEDED( NS_SUCCEEDED(NS_NewLocalFileWithFSRef(&ref, getter_AddRefs(macFile)))) {
NS_NewLocalFileWithFSRef(&ref, true, getter_AddRefs(macFile)))) {
appFile = static_cast<nsIFile*>(macFile); appFile = static_cast<nsIFile*>(macFile);
} else { } else {
NS_WARNING("Failed to resolve install directory."); NS_WARNING("Failed to resolve install directory.");

View File

@ -85,7 +85,7 @@ DynamicBlocklistWriter::DynamicBlocklistWriter(
nsresult DynamicBlocklistWriter::WriteToFile(const nsAString& aName) const { nsresult DynamicBlocklistWriter::WriteToFile(const nsAString& aName) const {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
MOZ_TRY(NS_NewLocalFile(aName, true, getter_AddRefs(file))); MOZ_TRY(NS_NewLocalFile(aName, getter_AddRefs(file)));
nsCOMPtr<nsIOutputStream> stream; nsCOMPtr<nsIOutputStream> stream;
MOZ_TRY(NS_NewSafeLocalFileOutputStream(getter_AddRefs(stream), file)); MOZ_TRY(NS_NewSafeLocalFileOutputStream(getter_AddRefs(stream), file));

View File

@ -83,7 +83,7 @@ bool ModuleEvaluator::ResolveKnownFolder(REFKNOWNFOLDERID aFolderId,
ShellStringUniquePtr path(rawPath); ShellStringUniquePtr path(rawPath);
nsresult rv = NS_NewLocalFile(nsDependentString(path.get()), false, aOutFile); nsresult rv = NS_NewLocalFile(nsDependentString(path.get()), aOutFile);
return NS_SUCCEEDED(rv); return NS_SUCCEEDED(rv);
} }

View File

@ -97,7 +97,7 @@ ModuleRecord::ModuleRecord(const nsAString& aResolvedNtPath)
} }
nsresult rv = nsresult rv =
NS_NewLocalFile(resolvedDosPath, false, getter_AddRefs(mResolvedDosName)); NS_NewLocalFile(resolvedDosPath, getter_AddRefs(mResolvedDosName));
if (NS_FAILED(rv) || !mResolvedDosName) { if (NS_FAILED(rv) || !mResolvedDosName) {
return; return;
} }

View File

@ -346,7 +346,7 @@ struct ParamTraits<mozilla::ModuleRecord> {
if (resolvedDosName.IsEmpty()) { if (resolvedDosName.IsEmpty()) {
aResult->mResolvedDosName = nullptr; aResult->mResolvedDosName = nullptr;
} else if (NS_FAILED(NS_NewLocalFile( } else if (NS_FAILED(NS_NewLocalFile(
resolvedDosName, false, resolvedDosName,
getter_AddRefs(aResult->mResolvedDosName)))) { getter_AddRefs(aResult->mResolvedDosName)))) {
return false; return false;
} }

View File

@ -1748,14 +1748,16 @@ nsXULAppInfo::SetServerURL(nsIURL* aServerURL) {
NS_IMETHODIMP NS_IMETHODIMP
nsXULAppInfo::GetMinidumpPath(nsIFile** aMinidumpPath) { nsXULAppInfo::GetMinidumpPath(nsIFile** aMinidumpPath) {
if (!CrashReporter::GetEnabled()) return NS_ERROR_NOT_INITIALIZED; if (!CrashReporter::GetEnabled()) {
return NS_ERROR_NOT_INITIALIZED;
}
nsAutoString path; 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); return NS_NewLocalFile(path, aMinidumpPath);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -3447,7 +3449,7 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
if (NS_FAILED(rv)) return false; if (NS_FAILED(rv)) return false;
nsCOMPtr<nsIFile> lf; nsCOMPtr<nsIFile> lf;
rv = NS_NewNativeLocalFile(""_ns, false, getter_AddRefs(lf)); rv = NS_NewNativeLocalFile(""_ns, getter_AddRefs(lf));
if (NS_FAILED(rv)) return false; if (NS_FAILED(rv)) return false;
rv = lf->SetPersistentDescriptor(buf); rv = lf->SetPersistentDescriptor(buf);
@ -3461,7 +3463,7 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
rv = parser.GetString("Compatibility", "LastAppDir", buf); rv = parser.GetString("Compatibility", "LastAppDir", buf);
if (NS_FAILED(rv)) return false; 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; if (NS_FAILED(rv)) return false;
rv = lf->SetPersistentDescriptor(buf); rv = lf->SetPersistentDescriptor(buf);

View File

@ -296,7 +296,7 @@ static nsresult GetSystemParentDirectory(nsIFile** aFile) {
"/usr/lib/mozilla"_ns "/usr/lib/mozilla"_ns
# endif # endif
; ;
rv = NS_NewNativeLocalFile(dirname, false, getter_AddRefs(localDir)); rv = NS_NewNativeLocalFile(dirname, getter_AddRefs(localDir));
# endif # endif
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
@ -401,7 +401,7 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
# else # else
static const char* const sysLExtDir = "/usr/share/mozilla/extensions"; static const char* const sysLExtDir = "/usr/share/mozilla/extensions";
# endif # endif
rv = NS_NewNativeLocalFile(nsDependentCString(sysLExtDir), false, rv = NS_NewNativeLocalFile(nsDependentCString(sysLExtDir),
getter_AddRefs(file)); getter_AddRefs(file));
# endif # endif
} }
@ -414,7 +414,7 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
#if defined(XP_UNIX) #if defined(XP_UNIX)
nsPrintfCString path("/run/user/%d/%s/", getuid(), GetAppName()); nsPrintfCString path("/run/user/%d/%s/", getuid(), GetAppName());
ToLowerCase(path); ToLowerCase(path);
rv = NS_NewNativeLocalFile(path, false, getter_AddRefs(file)); rv = NS_NewNativeLocalFile(path, getter_AddRefs(file));
#endif #endif
} else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) { } else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) {
bool persistent = false; bool persistent = false;
@ -825,7 +825,7 @@ nsresult nsXREDirProvider::GetInstallHash(nsAString& aPathHash) {
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(installDir); nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(installDir);
rv = macFile->GetFSRef(&ref); rv = macFile->GetFSRef(&ref);
NS_ENSURE_SUCCESS(rv, rv); 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); NS_ENSURE_SUCCESS(rv, rv);
installDir = static_cast<nsIFile*>(macFile); installDir = static_cast<nsIFile*>(macFile);
#endif #endif
@ -1053,7 +1053,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
NS_ENSURE_FALSE(err, NS_ERROR_FAILURE); 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); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(localDir); nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(localDir);
@ -1066,7 +1066,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
#elif defined(XP_IOS) #elif defined(XP_IOS)
nsAutoCString userDir; nsAutoCString userDir;
if (GetUIKitDirectory(aLocal, userDir)) { if (GetUIKitDirectory(aLocal, userDir)) {
rv = NS_NewNativeLocalFile(userDir, true, getter_AddRefs(localDir)); rv = NS_NewNativeLocalFile(userDir, getter_AddRefs(localDir));
} else { } else {
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
} }
@ -1085,7 +1085,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
} }
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir)); rv = NS_NewLocalFile(path, getter_AddRefs(localDir));
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
const char* homeDir = getenv("HOME"); const char* homeDir = getenv("HOME");
if (!homeDir || !*homeDir) return NS_ERROR_FAILURE; 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. // If $XDG_CACHE_HOME is defined use it, otherwise use $HOME/.cache.
const char* cacheHome = getenv("XDG_CACHE_HOME"); const char* cacheHome = getenv("XDG_CACHE_HOME");
if (cacheHome && *cacheHome) { if (cacheHome && *cacheHome) {
rv = NS_NewNativeLocalFile(nsDependentCString(cacheHome), true, rv = NS_NewNativeLocalFile(nsDependentCString(cacheHome),
getter_AddRefs(localDir)); getter_AddRefs(localDir));
} else { } else {
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true, rv = NS_NewNativeLocalFile(nsDependentCString(homeDir),
getter_AddRefs(localDir)); getter_AddRefs(localDir));
if (NS_SUCCEEDED(rv)) rv = localDir->AppendNative(".cache"_ns); if (NS_SUCCEEDED(rv)) rv = localDir->AppendNative(".cache"_ns);
} }
} else { } else {
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true, rv = NS_NewNativeLocalFile(nsDependentCString(homeDir),
getter_AddRefs(localDir)); getter_AddRefs(localDir));
} }
#else #else

View File

@ -73,8 +73,8 @@ void CodeCoverageHandler::FlushCounters(const bool initialized) {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(outDir), false, nsresult rv =
getter_AddRefs(file)); NS_NewNativeLocalFile(nsDependentCString(outDir), getter_AddRefs(file));
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = file->AppendNative( rv = file->AppendNative(

View File

@ -141,10 +141,9 @@ class ScopedXPCOM final : public nsIDirectoryServiceProvider2 {
return copy.forget(); return copy.forget();
} }
char* env = PR_GetEnv("MOZ_XRE_DIR");
nsCOMPtr<nsIFile> greD; nsCOMPtr<nsIFile> greD;
if (env) { if (char* env = PR_GetEnv("MOZ_XRE_DIR")) {
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(greD)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(greD));
} }
mGRED = greD; mGRED = greD;

View File

@ -52,7 +52,7 @@ void MessageManagerFuzzer::ReadFile(const char* path,
nsTArray<nsCString>& aArray) { nsTArray<nsCString>& aArray) {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = nsresult rv =
NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true, getter_AddRefs(file)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), getter_AddRefs(file));
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
bool exists = false; bool exists = false;

View File

@ -869,7 +869,7 @@ nsresult nsExternalHelperAppService::GetFileTokenForPath(
nsDependentString platformAppPath(aPlatformAppPath); nsDependentString platformAppPath(aPlatformAppPath);
// First, check if we have an absolute path // First, check if we have an absolute path
nsIFile* localFile = nullptr; nsIFile* localFile = nullptr;
nsresult rv = NS_NewLocalFile(platformAppPath, true, &localFile); nsresult rv = NS_NewLocalFile(platformAppPath, &localFile);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
*aFile = localFile; *aFile = localFile;
bool exists; bool exists;

View File

@ -372,7 +372,7 @@ void nsMIMEInfoWin::UpdateDefaultInfoIfStale() {
bool nsMIMEInfoWin::GetLocalHandlerApp(const nsAString& aCommandHandler, bool nsMIMEInfoWin::GetLocalHandlerApp(const nsAString& aCommandHandler,
nsCOMPtr<nsILocalHandlerApp>& aApp) { nsCOMPtr<nsILocalHandlerApp>& aApp) {
nsCOMPtr<nsIFile> locfile; 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; if (NS_FAILED(rv)) return false;
aApp = do_CreateInstance("@mozilla.org/uriloader/local-handler-app;1"); aApp = do_CreateInstance("@mozilla.org/uriloader/local-handler-app;1");

View File

@ -84,7 +84,7 @@ nsDeviceContextSpecAndroid::DoEndDocument() {
nsAutoString targetPath; nsAutoString targetPath;
mPrintSettings->GetToFileName(targetPath); mPrintSettings->GetToFileName(targetPath);
nsCOMPtr<nsIFile> destFile; nsCOMPtr<nsIFile> destFile;
MOZ_TRY(NS_NewLocalFile(targetPath, false, getter_AddRefs(destFile))); MOZ_TRY(NS_NewLocalFile(targetPath, getter_AddRefs(destFile)));
nsAutoString destLeafName; nsAutoString destLeafName;
MOZ_TRY(destFile->GetLeafName(destLeafName)); MOZ_TRY(destFile->GetLeafName(destLeafName));

View File

@ -4493,7 +4493,7 @@ static CFTypeRefPtr<CFURLRef> GetPasteLocation(NSPasteboard* aPasteboard) {
stringFromPboardType: stringFromPboardType:
(NSString*)kPasteboardTypeFileURLPromise]]) { (NSString*)kPasteboardTypeFileURLPromise]]) {
nsCOMPtr<nsIFile> targFile; nsCOMPtr<nsIFile> targFile;
NS_NewLocalFile(u""_ns, true, getter_AddRefs(targFile)); NS_NewLocalFile(u""_ns, getter_AddRefs(targFile));
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(targFile); nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(targFile);
if (!macLocalFile) { if (!macLocalFile) {
NS_ERROR("No Mac local file"); NS_ERROR("No Mac local file");

View File

@ -1726,7 +1726,7 @@ void nsCocoaUtils::SetTransferDataForTypeFromPasteboardItem(
clipboardDataPtr[stringLength] = 0; // null terminate clipboardDataPtr[stringLength] = 0; // null terminate
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr), true, nsresult rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr),
getter_AddRefs(file)); getter_AddRefs(file));
free(clipboardDataPtr); free(clipboardDataPtr);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {

View File

@ -359,7 +359,7 @@ nsIFilePicker::ResultCode nsFilePicker::GetLocalFiles(
} }
nsCOMPtr<nsIFile> localFile; nsCOMPtr<nsIFile> localFile;
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile)); NS_NewLocalFile(u""_ns, getter_AddRefs(localFile));
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile); nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
if (macLocalFile && if (macLocalFile &&
NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)url))) { NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)url))) {
@ -414,7 +414,7 @@ nsIFilePicker::ResultCode nsFilePicker::GetLocalFolder(nsIFile** outFile) {
NSURL* theURL = [[thePanel URLs] objectAtIndex:0]; NSURL* theURL = [[thePanel URLs] objectAtIndex:0];
if (theURL) { if (theURL) {
nsCOMPtr<nsIFile> localFile; nsCOMPtr<nsIFile> localFile;
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile)); NS_NewLocalFile(u""_ns, getter_AddRefs(localFile));
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile); nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
if (macLocalFile && if (macLocalFile &&
NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)theURL))) { NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)theURL))) {
@ -505,7 +505,7 @@ nsIFilePicker::ResultCode nsFilePicker::PutLocalFile(nsIFile** outFile) {
NSURL* fileURL = [thePanel URL]; NSURL* fileURL = [thePanel URL];
if (fileURL) { if (fileURL) {
nsCOMPtr<nsIFile> localFile; nsCOMPtr<nsIFile> localFile;
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localFile)); NS_NewLocalFile(u""_ns, getter_AddRefs(localFile));
nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile); nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
if (macLocalFile && if (macLocalFile &&
NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)fileURL))) { NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)fileURL))) {

View File

@ -756,7 +756,7 @@ bool MPRISServiceHandler::InitLocalImageFolder() {
// The XDG_DATA_HOME points to the same location in the host and guest // The XDG_DATA_HOME points to the same location in the host and guest
// filesystem. // filesystem.
if (const auto* xdgDataHome = g_getenv("XDG_DATA_HOME")) { if (const auto* xdgDataHome = g_getenv("XDG_DATA_HOME")) {
rv = NS_NewNativeLocalFile(nsDependentCString(xdgDataHome), true, rv = NS_NewNativeLocalFile(nsDependentCString(xdgDataHome),
getter_AddRefs(mLocalImageFolder)); getter_AddRefs(mLocalImageFolder));
} }
} else { } else {

View File

@ -96,7 +96,7 @@ already_AddRefed<PrintTarget> nsDeviceContextSpecGTK::MakePrintTarget() {
return nullptr; return nullptr;
} }
close(fd); close(fd);
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(buf), false, if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(buf),
getter_AddRefs(mSpoolFile)))) { getter_AddRefs(mSpoolFile)))) {
unlink(buf); unlink(buf);
g_free(buf); g_free(buf);
@ -380,8 +380,7 @@ RefPtr<PrintEndDocumentPromise> nsDeviceContextSpecGTK::EndDocument() {
nsCOMPtr<nsIFile> destFile; nsCOMPtr<nsIFile> destFile;
mPrintSettings->GetToFileName(targetPath); mPrintSettings->GetToFileName(targetPath);
nsresult rv = nsresult rv = NS_NewLocalFile(targetPath, getter_AddRefs(destFile));
NS_NewLocalFile(targetPath, false, getter_AddRefs(destFile));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return PrintEndDocumentPromise::CreateAndReject(rv, __func__); return PrintEndDocumentPromise::CreateAndReject(rv, __func__);
} }

View File

@ -2162,7 +2162,7 @@ void nsDragSession::SourceDataGetXDND(nsITransferable* aItem,
LOGDRAGSERVICE(" XdndDirectSave filepath is %s", fullpath.get()); LOGDRAGSERVICE(" XdndDirectSave filepath is %s", fullpath.get());
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(fullpath.get()), false, if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(fullpath.get()),
getter_AddRefs(file)))) { getter_AddRefs(file)))) {
LOGDRAGSERVICE(" failed to get local file"); LOGDRAGSERVICE(" failed to get local file");
return; return;

View File

@ -182,7 +182,7 @@ void ReadMultipleFiles(gpointer filename, gpointer array) {
nsCOMPtr<nsIFile> localfile; nsCOMPtr<nsIFile> localfile;
nsresult rv = nsresult rv =
NS_NewNativeLocalFile(nsDependentCString(static_cast<char*>(filename)), NS_NewNativeLocalFile(nsDependentCString(static_cast<char*>(filename)),
false, getter_AddRefs(localfile)); getter_AddRefs(localfile));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsCOMArray<nsIFile>& files = *static_cast<nsCOMArray<nsIFile>*>(array); nsCOMArray<nsIFile>& files = *static_cast<nsCOMArray<nsIFile>*>(array);
files.AppendObject(localfile); files.AppendObject(localfile);

View File

@ -310,7 +310,7 @@ nsPrintSettingsGTK::SetToFileName(const nsAString& aToFileName) {
"pdf"); "pdf");
nsCOMPtr<nsIFile> file; 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); NS_ENSURE_SUCCESS(rv, rv);
// Convert the nsIFile to a URL // Convert the nsIFile to a URL

View File

@ -177,7 +177,7 @@ mozilla::ipc::IPCResult nsFilePickerProxy::Recv__delete__(
} else if (aData.type() == MaybeInputData::TInputDirectory) { } else if (aData.type() == MaybeInputData::TInputDirectory) {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
const nsAString& path(aData.get_InputDirectory().directoryPath()); 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return IPC_OK(); return IPC_OK();
} }

View File

@ -790,7 +790,7 @@ void JumpListBuilder::DeleteIconFromDisk(const nsAString& aPath) {
if (StringTail(aPath, 4).LowerCaseEqualsASCII(".ico")) { if (StringTail(aPath, 4).LowerCaseEqualsASCII(".ico")) {
// Construct the parent path of the passed in path // Construct the parent path of the passed in path
nsCOMPtr<nsIFile> icoFile; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }

View File

@ -960,8 +960,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject* aDataObject,
// we have a file path in |data|. Create an nsLocalFile object. // we have a file path in |data|. Create an nsLocalFile object.
nsDependentString filepath(reinterpret_cast<char16_t*>(data)); nsDependentString filepath(reinterpret_cast<char16_t*>(data));
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
if (NS_SUCCEEDED( if (NS_SUCCEEDED(NS_NewLocalFile(filepath, getter_AddRefs(file)))) {
NS_NewLocalFile(filepath, false, getter_AddRefs(file)))) {
genericDataWrapper = do_QueryInterface(file); genericDataWrapper = do_QueryInterface(file);
} }
free(data); free(data);
@ -1159,7 +1158,7 @@ bool nsClipboard ::FindURLFromLocalFile(IDataObject* inDataObject, UINT inIndex,
// file? // file?
const nsDependentString filepath(static_cast<char16_t*>(*outData)); const nsDependentString filepath(static_cast<char16_t*>(*outData));
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(filepath, true, getter_AddRefs(file)); nsresult rv = NS_NewLocalFile(filepath, getter_AddRefs(file));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
free(*outData); free(*outData);
return dataFound; return dataFound;

View File

@ -361,7 +361,7 @@ RefPtr<PrintEndDocumentPromise> nsDeviceContextSpecWin::EndDocument() {
// We still need to move the file to its actual destination. // We still need to move the file to its actual destination.
nsCOMPtr<nsIFile> destFile; nsCOMPtr<nsIFile> destFile;
auto rv = NS_NewLocalFile(targetPath, false, getter_AddRefs(destFile)); auto rv = NS_NewLocalFile(targetPath, getter_AddRefs(destFile));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return PrintEndDocumentPromise::CreateAndReject(rv, __func__); return PrintEndDocumentPromise::CreateAndReject(rv, __func__);
} }

View File

@ -762,7 +762,7 @@ nsFilePicker::ShowFilePicker(const nsString& aInitialDir) {
// multiple selection // multiple selection
for (auto const& str : paths) { for (auto const& str : paths) {
nsCOMPtr<nsIFile> file; 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); self->mFiles.AppendObject(file);
} }
} }
@ -908,7 +908,7 @@ nsresult nsFilePicker::Open(nsIFilePickerShownCallback* aCallback) {
// file already exists. // file already exists.
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = nsresult rv =
NS_NewLocalFile(self->mUnicodeFile, false, getter_AddRefs(file)); NS_NewLocalFile(self->mUnicodeFile, getter_AddRefs(file));
bool flag = false; bool flag = false;
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(file->Exists(&flag)) && flag) { if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(file->Exists(&flag)) && flag) {
@ -975,7 +975,7 @@ nsFilePicker::GetFile(nsIFile** aFile) {
if (mUnicodeFile.IsEmpty()) return NS_OK; if (mUnicodeFile.IsEmpty()) return NS_OK;
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(mUnicodeFile, false, getter_AddRefs(file)); nsresult rv = NS_NewLocalFile(mUnicodeFile, getter_AddRefs(file));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -1097,7 +1097,7 @@ void nsFilePicker::RememberLastUsedDirectory() {
} }
nsCOMPtr<nsIFile> file; 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."); NS_WARNING("RememberLastUsedDirectory failed to init file path.");
return; return;
} }

View File

@ -1621,7 +1621,7 @@ class nsCycleCollectorLogSinkToFile final : public nsICycleCollectorLogSink {
// wouldn't work. // wouldn't work.
nsIFile* logFile = nullptr; nsIFile* logFile = nullptr;
if (char* env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) { 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 // On Android or B2G, this function will open a file named

View File

@ -409,9 +409,8 @@ nsresult nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
// For Android, first try the downloads directory which is world-readable // For Android, first try the downloads directory which is world-readable
// rather than the temp directory which is not. // rather than the temp directory which is not.
if (!*aFile) { if (!*aFile) {
char* env = PR_GetEnv("DOWNLOADS_DIRECTORY"); if (char* env = PR_GetEnv("DOWNLOADS_DIRECTORY")) {
if (env) { NS_NewNativeLocalFile(nsCString(env), aFile);
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, aFile);
} }
} }
#endif #endif

View File

@ -122,8 +122,8 @@ bool nsMacUtilsImpl::GetAppPath(nsCString& aAppPath) {
} }
nsCOMPtr<nsIFile> app; nsCOMPtr<nsIFile> app;
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), true, nsresult rv =
getter_AddRefs(app)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), getter_AddRefs(app));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }
@ -326,8 +326,7 @@ static nsresult GetDirFromBundlePlist(const nsAString& aKey, nsIFile** aDir) {
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> dir; nsCOMPtr<nsIFile> dir;
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(dirPath), false, rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(dirPath), getter_AddRefs(dir));
getter_AddRefs(dir));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = dir->Normalize(); rv = dir->Normalize();

View File

@ -615,7 +615,7 @@ nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
// Create the file. // Create the file.
nsCOMPtr<nsIFile> reportsFile; 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))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

View File

@ -302,10 +302,9 @@ class BinaryPath {
return rv; return rv;
} }
# ifdef XP_WIN # ifdef XP_WIN
rv = NS_NewLocalFile(nsDependentString(exePath), true, getter_AddRefs(lf)); rv = NS_NewLocalFile(nsDependentString(exePath), getter_AddRefs(lf));
# else # else
rv = NS_NewNativeLocalFile(nsDependentCString(exePath), true, rv = NS_NewNativeLocalFile(nsDependentCString(exePath), getter_AddRefs(lf));
getter_AddRefs(lf));
# endif # endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;

View File

@ -141,11 +141,6 @@ XPCOM_API(nsresult) NS_GetComponentRegistrar(nsIComponentRegistrar** aResult);
* error (NS_ERROR_FILE_UNRECOGNIZED_PATH). * error (NS_ERROR_FILE_UNRECOGNIZED_PATH).
* |NS_NewNativeLocalFile|'s path must be in the * |NS_NewNativeLocalFile|'s path must be in the
* filesystem charset. * 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 * @param aResult Interface pointer to a new instance of an nsIFile
* *
* @return NS_OK for success; * @return NS_OK for success;
@ -155,18 +150,17 @@ XPCOM_API(nsresult) NS_GetComponentRegistrar(nsIComponentRegistrar** aResult);
#ifdef __cplusplus #ifdef __cplusplus
XPCOM_API(nsresult) XPCOM_API(nsresult)
NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsIFile** aResult); NS_NewLocalFile(const nsAString& aPath, nsIFile** aResult);
XPCOM_API(nsresult) XPCOM_API(nsresult)
NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowLinks, NS_NewNativeLocalFile(const nsACString& aPath, nsIFile** aResult);
nsIFile** aResult);
// Use NS_NewLocalFile if you already have a UTF-16 string. // Use NS_NewLocalFile if you already have a UTF-16 string.
// Otherwise non-ASCII paths will break on some platforms // Otherwise non-ASCII paths will break on some platforms
// including Windows. // including Windows.
class NS_ConvertUTF16toUTF8; class NS_ConvertUTF16toUTF8;
nsresult NS_NewNativeLocalFile(const NS_ConvertUTF16toUTF8& aPath, nsresult NS_NewNativeLocalFile(const NS_ConvertUTF16toUTF8& aPath,
bool aFollowLinks, nsIFile** aResult) = delete; nsIFile** aResult) = delete;
#endif #endif

View File

@ -66,7 +66,7 @@ static nsresult GetKnownFolder(GUID* aGuid, nsIFile** aFile) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsresult rv = NS_NewLocalFile(nsDependentString(path), true, aFile); nsresult rv = NS_NewLocalFile(nsDependentString(path), aFile);
CoTaskMemFree(path); CoTaskMemFree(path);
return rv; return rv;
@ -91,7 +91,7 @@ static nsresult GetWindowsFolder(int aFolder, nsIFile** aFile) {
path[++len] = L'\0'; 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; nsAutoString path;
path.Assign(str); path.Assign(str);
path.Append('\\'); path.Append('\\');
nsresult rv = NS_NewLocalFile(path, false, aFile); nsresult rv = NS_NewLocalFile(path, aFile);
CoTaskMemFree(str); CoTaskMemFree(str);
return rv; return rv;
} }
@ -154,7 +154,7 @@ static nsresult GetRegWindowsAppDataFolder(bool aLocal, nsIFile** aFile) {
path[++len] = L'\0'; path[++len] = L'\0';
} }
return NS_NewLocalFile(nsDependentString(path, len), true, aFile); return NS_NewLocalFile(nsDependentString(path, len), aFile);
} }
#endif // XP_WIN #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? // XXX no home dir on android; maybe we should return the sdcard if present?
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
# else # else
return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true, return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), aFile);
aFile);
# endif # endif
} }
@ -199,7 +198,7 @@ static nsresult GetUnixSystemConfigDir(nsIFile** aFile) {
if (sysConfigDir.IsEmpty()) { if (sysConfigDir.IsEmpty()) {
sysConfigDir.Assign(nsLiteralCString("/etc")); sysConfigDir.Assign(nsLiteralCString("/etc"));
} }
MOZ_TRY(NS_NewNativeLocalFile(sysConfigDir, true, aFile)); MOZ_TRY(NS_NewNativeLocalFile(sysConfigDir, aFile));
MOZ_TRY((*aFile)->AppendNative(appName)); MOZ_TRY((*aFile)->AppendNative(appName));
return NS_OK; return NS_OK;
# endif # endif
@ -387,8 +386,7 @@ static nsresult GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
bool exists; bool exists;
if (dir) { if (dir) {
rv = NS_NewNativeLocalFile(nsDependentCString(dir), true, rv = NS_NewNativeLocalFile(nsDependentCString(dir), getter_AddRefs(file));
getter_AddRefs(file));
free(dir); free(dir);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -460,7 +458,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
if (!_wgetcwd(path, MAX_PATH)) { if (!_wgetcwd(path, MAX_PATH)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
return NS_NewLocalFile(nsDependentString(path), true, aFile); return NS_NewLocalFile(nsDependentString(path), aFile);
#else #else
if (!getcwd(path, MAXPATHLEN)) { if (!getcwd(path, MAXPATHLEN)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -468,7 +466,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
#endif #endif
#if !defined(XP_WIN) #if !defined(XP_WIN)
return NS_NewNativeLocalFile(nsDependentCString(path), true, aFile); return NS_NewNativeLocalFile(nsDependentCString(path), aFile);
#endif #endif
case OS_TemporaryDirectory: case OS_TemporaryDirectory:
@ -478,7 +476,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
if (len == 0) { if (len == 0) {
break; break;
} }
return NS_NewLocalFile(nsDependentString(path, len), true, aFile); return NS_NewLocalFile(nsDependentString(path, len), aFile);
} }
#elif defined(MOZ_WIDGET_COCOA) #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 #else
break; break;
@ -554,7 +552,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
CFRangeMake(0, data.Length()), CFRangeMake(0, data.Length()),
reinterpret_cast<UniChar*>(data.Elements())); reinterpret_cast<UniChar*>(data.Elements()));
return NS_NewLocalFile(path, true, aFile); return NS_NewLocalFile(path, aFile);
} }
#elif defined(XP_WIN) #elif defined(XP_WIN)
case Win_SystemDirectory: { case Win_SystemDirectory: {
@ -567,7 +565,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), true, aFile); return NS_NewLocalFile(nsDependentString(path, len), aFile);
} }
case Win_WindowsDirectory: { case Win_WindowsDirectory: {
@ -581,7 +579,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), true, aFile); return NS_NewLocalFile(nsDependentString(path, len), aFile);
} }
case Win_ProgramFiles: { case Win_ProgramFiles: {
@ -604,7 +602,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
rv = NS_NewLocalFile(nsDependentString(path, len), true, aFile); rv = NS_NewLocalFile(nsDependentString(path, len), aFile);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
return rv; return rv;
} }
@ -628,7 +626,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), true, aFile); return NS_NewLocalFile(nsDependentString(path, len), aFile);
} }
break; break;
} }
@ -706,7 +704,7 @@ nsresult GetOSXFolderType(short aDomain, OSType aFolderType,
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
if (aFolderType == kTemporaryFolderType) { if (aFolderType == kTemporaryFolderType) {
NS_NewLocalFile(u""_ns, true, aLocalFile); NS_NewLocalFile(u""_ns, aLocalFile);
nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile)); nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile));
if (localMacFile) { if (localMacFile) {
rv = localMacFile->InitWithCFURL( rv = localMacFile->InitWithCFURL(
@ -719,7 +717,7 @@ nsresult GetOSXFolderType(short aDomain, OSType aFolderType,
FSRef fsRef; FSRef fsRef;
err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef); err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef);
if (err == noErr) { if (err == noErr) {
NS_NewLocalFile(u""_ns, true, aLocalFile); NS_NewLocalFile(u""_ns, aLocalFile);
nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile)); nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile));
if (localMacFile) { if (localMacFile) {
rv = localMacFile->InitWithFSRef(&fsRef); rv = localMacFile->InitWithFSRef(&fsRef);

View File

@ -183,7 +183,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
nsCOMPtr<nsIFile> localDir; nsCOMPtr<nsIFile> localDir;
#if defined(MOZ_WIDGET_COCOA) #if defined(MOZ_WIDGET_COCOA)
NS_NewLocalFile(u""_ns, true, getter_AddRefs(localDir)); NS_NewLocalFile(u""_ns, getter_AddRefs(localDir));
if (!localDir) { if (!localDir) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -207,7 +207,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
return rv; return rv;
} }
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true, rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")),
getter_AddRefs(localDir)); getter_AddRefs(localDir));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;

View File

@ -62,7 +62,7 @@ nsresult nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
if (!greHome) { if (!greHome) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(greHome), true, nsresult rv = NS_NewNativeLocalFile(nsDependentCString(greHome),
getter_AddRefs(mXCurProcD)); getter_AddRefs(mXCurProcD));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;

View File

@ -206,7 +206,7 @@ interface nsILocalFileMac : nsIFile
%{C++ %{C++
extern "C" extern "C"
{ {
NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowSymlinks, nsILocalFileMac** result); NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, nsILocalFileMac** result);
NS_EXPORT nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, bool aFollowSymlinks, nsILocalFileMac** result); NS_EXPORT nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, nsILocalFileMac** result);
} }
%} %}

View File

@ -1868,7 +1868,7 @@ nsLocalFile::GetParent(nsIFile** aParent) {
*slashp = '\0'; *slashp = '\0';
nsCOMPtr<nsIFile> localFile; nsCOMPtr<nsIFile> localFile;
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(buffer), true, nsresult rv = NS_NewNativeLocalFile(nsDependentCString(buffer),
getter_AddRefs(localFile)); getter_AddRefs(localFile));
// make buffer whole again // make buffer whole again
@ -2418,8 +2418,7 @@ nsLocalFile::Launch() {
#endif #endif
} }
nsresult NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowSymlinks, nsresult NS_NewNativeLocalFile(const nsACString& aPath, nsIFile** aResult) {
nsIFile** aResult) {
RefPtr<nsLocalFile> file = new nsLocalFile(); RefPtr<nsLocalFile> file = new nsLocalFile();
if (!aPath.IsEmpty()) { if (!aPath.IsEmpty()) {
@ -2537,14 +2536,13 @@ nsresult nsLocalFile::GetTarget(nsAString& aResult) {
GET_UCS(GetNativeTarget, aResult); GET_UCS(GetNativeTarget, aResult);
} }
nsresult NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsresult NS_NewLocalFile(const nsAString& aPath, nsIFile** aResult) {
nsIFile** aResult) {
nsAutoCString buf; nsAutoCString buf;
nsresult rv = NS_CopyUnicodeToNative(aPath, buf); nsresult rv = NS_CopyUnicodeToNative(aPath, buf);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
return NS_NewNativeLocalFile(buf, aFollowLinks, aResult); return NS_NewNativeLocalFile(buf, aResult);
} }
// nsILocalFileMac // nsILocalFileMac
@ -3066,7 +3064,7 @@ NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile* aFile) {
return InitWithNativePath(nativePath); return InitWithNativePath(nativePath);
} }
nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowLinks, nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef,
nsILocalFileMac** aResult) { nsILocalFileMac** aResult) {
RefPtr<nsLocalFile> file = new nsLocalFile(); RefPtr<nsLocalFile> file = new nsLocalFile();
@ -3078,7 +3076,7 @@ nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowLinks,
return NS_OK; return NS_OK;
} }
nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, bool aFollowLinks, nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL,
nsILocalFileMac** aResult) { nsILocalFileMac** aResult) {
RefPtr<nsLocalFile> file = new nsLocalFile(); RefPtr<nsLocalFile> file = new nsLocalFile();

View File

@ -3448,8 +3448,7 @@ nsLocalFile::Launch() {
return NS_OK; return NS_OK;
} }
nsresult NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsresult NS_NewLocalFile(const nsAString& aPath, nsIFile** aResult) {
nsIFile** aResult) {
RefPtr<nsLocalFile> file = new nsLocalFile(); RefPtr<nsLocalFile> file = new nsLocalFile();
if (!aPath.IsEmpty()) { if (!aPath.IsEmpty()) {
@ -3622,15 +3621,14 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) {
return rv; return rv;
} }
nsresult NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowLinks, nsresult NS_NewNativeLocalFile(const nsACString& aPath, nsIFile** aResult) {
nsIFile** aResult) {
nsAutoString buf; nsAutoString buf;
nsresult rv = NS_CopyNativeToUnicode(aPath, buf); nsresult rv = NS_CopyNativeToUnicode(aPath, buf);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
*aResult = nullptr; *aResult = nullptr;
return rv; return rv;
} }
return NS_NewLocalFile(buf, aFollowLinks, aResult); return NS_NewLocalFile(buf, aResult);
} }
void nsLocalFile::EnsureShortPath() { void nsLocalFile::EnsureShortPath() {

View File

@ -35,7 +35,7 @@ void print_err(nsresult err) {
nsresult Register(nsIComponentRegistrar* registrar, const char* path) { nsresult Register(nsIComponentRegistrar* registrar, const char* path) {
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsresult rv = 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; if (NS_FAILED(rv)) return rv;
rv = registrar->AutoRegister(file); rv = registrar->AutoRegister(file);
return rv; return rv;

View File

@ -155,10 +155,9 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 {
return copy.forget(); return copy.forget();
} }
char* env = PR_GetEnv("MOZ_XRE_DIR");
nsCOMPtr<nsIFile> greD; nsCOMPtr<nsIFile> greD;
if (env) { if (char* env = PR_GetEnv("MOZ_XRE_DIR")) {
NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(greD)); NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), getter_AddRefs(greD));
} }
mGRED = greD; mGRED = greD;