tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 173a98cdaaa1bf07a5802632dc0133a5a82c3499
parent e47c8a97881712c63622ac96eab3f4c36d8ccd82
Author: Josh Aas <jaas@kflag.net>
Date:   Mon, 27 Oct 2025 19:53:11 +0000

Bug 1996502 - nsILocalFileMac: Remove fileSizeWithResFork, openDocWithApp, bundleIdentifier, bundleContentsLastModifiedTime. r=spohl

Differential Revision: https://phabricator.services.mozilla.com/D270098

Diffstat:
Mxpcom/io/nsIFile.idl | 6------
Mxpcom/io/nsILocalFileMac.idl | 39---------------------------------------
Mxpcom/io/nsLocalFileUnix.cpp | 151------------------------------------------------------------------------------
3 files changed, 0 insertions(+), 196 deletions(-)

diff --git a/xpcom/io/nsIFile.idl b/xpcom/io/nsIFile.idl @@ -303,12 +303,6 @@ interface nsIFile : nsISupports readonly attribute PRTime creationTime; readonly attribute PRTime creationTimeOfLink; - /** - * WARNING! On the Mac, getting/setting the file size with nsIFile - * only deals with the size of the data fork. If you need to - * know the size of the combined data and resource forks use the - * GetFileSizeWithResFork() method defined on nsILocalFileMac. - */ attribute int64_t fileSize; readonly attribute int64_t fileSizeOfLink; diff --git a/xpcom/io/nsILocalFileMac.idl b/xpcom/io/nsILocalFileMac.idl @@ -95,16 +95,6 @@ interface nsILocalFileMac : nsIFile [noscript] FSSpec getFSSpec(); /** - * fileSizeWithResFork - * - * Returns the combined size of both the data fork and the resource - * fork (if present) rather than just the size of the data fork - * as returned by GetFileSize() - * - */ - readonly attribute int64_t fileSizeWithResFork; - - /** * fileType, creator * * File type and creator attributes @@ -125,19 +115,6 @@ interface nsILocalFileMac : nsIFile void launchWithDoc(in nsIFile aDocToLoad, in boolean aLaunchInBackground); /** - * openDocWithApp - * - * Open the document that this file points to with the given application. - * - * @param aAppToOpenWith The application with which to open the document. - * If NULL, the creator code of the document is used - * to determine the application. - * @param aLaunchInBackground TRUE if the application should not come to the front. - * - */ - void openDocWithApp(in nsIFile aAppToOpenWith, in boolean aLaunchInBackground); - - /** * isPackage * * returns true if a directory is determined to be a package under Mac OS 9/X @@ -153,22 +130,6 @@ interface nsILocalFileMac : nsIFile */ readonly attribute AString bundleDisplayName; - /** - * bundleIdentifier - * - * returns the identifier of the bundle - */ - readonly attribute AUTF8String bundleIdentifier; - - /** - * Last modified time of a bundle's contents (as opposed to its package - * directory). Our convention is to make the bundle's Info.plist file - * stand in for the rest of its contents -- since this file contains the - * bundle's version information and other identifiers. For non-bundles - * this is the same as lastModifiedTime. - */ - readonly attribute int64_t bundleContentsLastModifiedTime; - /** * Return whether or not the file has an extended attribute. * diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp @@ -2686,29 +2686,6 @@ static nsresult MacErrorMapper(OSErr inErr) { return outErr; } -static nsresult CFStringReftoUTF8(CFStringRef aInStrRef, nsACString& aOutStr) { - // first see if the conversion would succeed and find the length of the - // result - CFIndex usedBufLen, inStrLen = ::CFStringGetLength(aInStrRef); - CFIndex charsConverted = ::CFStringGetBytes( - aInStrRef, CFRangeMake(0, inStrLen), kCFStringEncodingUTF8, 0, false, - nullptr, 0, &usedBufLen); - if (charsConverted == inStrLen) { - // all characters converted, do the actual conversion - aOutStr.SetLength(usedBufLen); - if (aOutStr.Length() != (unsigned int)usedBufLen) { - return NS_ERROR_OUT_OF_MEMORY; - } - UInt8* buffer = (UInt8*)aOutStr.BeginWriting(); - ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen), - kCFStringEncodingUTF8, 0, false, buffer, usedBufLen, - &usedBufLen); - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - NS_IMETHODIMP nsLocalFile::InitWithCFURL(CFURLRef aCFURL) { UInt8 path[PATH_MAX]; @@ -2785,31 +2762,6 @@ nsLocalFile::GetFSSpec(FSSpec* aResult) { } NS_IMETHODIMP -nsLocalFile::GetFileSizeWithResFork(int64_t* aFileSizeWithResFork) { - if (NS_WARN_IF(!aFileSizeWithResFork)) { - return NS_ERROR_INVALID_ARG; - } - - FSRef fsRef; - nsresult rv = GetFSRef(&fsRef); - if (NS_FAILED(rv)) { - return rv; - } - - FSCatalogInfo catalogInfo; - OSErr err = - ::FSGetCatalogInfo(&fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes, - &catalogInfo, nullptr, nullptr, nullptr); - if (err != noErr) { - return MacErrorMapper(err); - } - - *aFileSizeWithResFork = - catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize; - return NS_OK; -} - -NS_IMETHODIMP nsLocalFile::GetFileType(OSType* aFileType) { CFURLRef url; if (NS_SUCCEEDED(GetCFURL(&url))) { @@ -2902,60 +2854,6 @@ nsLocalFile::LaunchWithDoc(nsIFile* aDocToLoad, bool aLaunchInBackground) { } NS_IMETHODIMP -nsLocalFile::OpenDocWithApp(nsIFile* aAppToOpenWith, bool aLaunchInBackground) { - FSRef docFSRef; - nsresult rv = GetFSRef(&docFSRef); - if (NS_FAILED(rv)) { - return rv; - } - - if (!aAppToOpenWith) { - OSErr err = ::LSOpenFSRef(&docFSRef, nullptr); - return MacErrorMapper(err); - } - - nsCOMPtr<nsILocalFileMac> appFileMac = do_QueryInterface(aAppToOpenWith, &rv); - if (!appFileMac) { - return rv; - } - - bool isExecutable; - rv = appFileMac->IsExecutable(&isExecutable); - if (NS_FAILED(rv)) { - return rv; - } - if (!isExecutable) { - return NS_ERROR_FILE_EXECUTION_FAILED; - } - - FSRef appFSRef; - rv = appFileMac->GetFSRef(&appFSRef); - if (NS_FAILED(rv)) { - return rv; - } - - LSLaunchFlags theLaunchFlags = kLSLaunchDefaults; - LSLaunchFSRefSpec thelaunchSpec; - - if (aLaunchInBackground) { - theLaunchFlags |= kLSLaunchDontSwitch; - } - memset(&thelaunchSpec, 0, sizeof(LSLaunchFSRefSpec)); - - thelaunchSpec.appRef = &appFSRef; - thelaunchSpec.numDocs = 1; - thelaunchSpec.itemRefs = &docFSRef; - thelaunchSpec.launchFlags = theLaunchFlags; - - OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, nullptr); - if (err != noErr) { - return MacErrorMapper(err); - } - - return NS_OK; -} - -NS_IMETHODIMP nsLocalFile::IsPackage(bool* aResult) { if (NS_WARN_IF(!aResult)) { return NS_ERROR_INVALID_ARG; @@ -3008,55 +2906,6 @@ nsLocalFile::GetBundleDisplayName(nsAString& aOutBundleName) { return NS_OK; } -NS_IMETHODIMP -nsLocalFile::GetBundleIdentifier(nsACString& aOutBundleIdentifier) { - nsresult rv = NS_ERROR_FAILURE; - - CFURLRef urlRef; - if (NS_SUCCEEDED(GetCFURL(&urlRef))) { - CFBundleRef bundle = ::CFBundleCreate(nullptr, urlRef); - if (bundle) { - CFStringRef bundleIdentifier = ::CFBundleGetIdentifier(bundle); - if (bundleIdentifier) { - rv = CFStringReftoUTF8(bundleIdentifier, aOutBundleIdentifier); - } - ::CFRelease(bundle); - } - ::CFRelease(urlRef); - } - - return rv; -} - -NS_IMETHODIMP -nsLocalFile::GetBundleContentsLastModifiedTime(int64_t* aLastModTime) { - CHECK_mPath(); - if (NS_WARN_IF(!aLastModTime)) { - return NS_ERROR_INVALID_ARG; - } - - bool isPackage = false; - nsresult rv = IsPackage(&isPackage); - if (NS_FAILED(rv) || !isPackage) { - return GetLastModifiedTime(aLastModTime); - } - - nsAutoCString infoPlistPath(mPath); - infoPlistPath.AppendLiteral("/Contents/Info.plist"); - PRFileInfo64 info; - if (PR_GetFileInfo64(infoPlistPath.get(), &info) != PR_SUCCESS) { - return GetLastModifiedTime(aLastModTime); - } - int64_t modTime = int64_t(info.modifyTime); - if (modTime == 0) { - *aLastModTime = 0; - } else { - *aLastModTime = modTime / int64_t(PR_USEC_PER_MSEC); - } - - return NS_OK; -} - NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile* aFile) { if (NS_WARN_IF(!aFile)) { return NS_ERROR_INVALID_ARG;