diff --git a/mozilla/xpcom/io/nsILocalFileMac.idl b/mozilla/xpcom/io/nsILocalFileMac.idl index d1a4b7507bd..e0640bc767d 100644 --- a/mozilla/xpcom/io/nsILocalFileMac.idl +++ b/mozilla/xpcom/io/nsILocalFileMac.idl @@ -158,6 +158,13 @@ interface nsILocalFileMac : nsILocalFile */ void openDocWithApp(in nsILocalFile aAppToOpenWith, in boolean aLaunchInBackground); + /** + * isPackage + * + * returns true if a directory is determined to be a package under Mac OS 9/X + * + */ + boolean isPackage(); }; %{C++ diff --git a/mozilla/xpcom/io/nsLocalFileMac.cpp b/mozilla/xpcom/io/nsLocalFileMac.cpp index f730ac4abbd..294cfd5411c 100644 --- a/mozilla/xpcom/io/nsLocalFileMac.cpp +++ b/mozilla/xpcom/io/nsLocalFileMac.cpp @@ -2059,6 +2059,41 @@ nsLocalFile::Exists(PRBool *_retval) return NS_OK; } +NS_IMETHODIMP +nsLocalFile::IsPackage(PRBool *outIsPackage) +{ + NS_ENSURE_ARG(outIsPackage); + *outIsPackage = PR_FALSE; + + // Note: IsDirectory() calls ResolveAndStat() & UpdateCachedCatInfo + PRBool isDir; + nsresult rv = IsDirectory(&isDir); + if (NS_FAILED(rv)) return rv; + + *outIsPackage = ((mCachedCatInfo.dirInfo.ioFlAttrib & kioFlAttribDirMask) && + (mCachedCatInfo.dirInfo.ioDrUsrWds.frFlags & kHasBundle)); + + if ((!*outIsPackage) && isDir) + { + // Believe it or not, folders ending with ".app" are also considered + // to be packages, even if the top-level folder doesn't have bundle set + nsXPIDLCString name; + if (NS_SUCCEEDED(rv = GetLeafName(getter_Copies(name)))) + { + const char *extPtr = strrchr(name, '.'); + if (extPtr) + { + if (!nsCRT::strcasecmp(extPtr, ".app")) + { + *outIsPackage = PR_TRUE; + } + } + } + } + + return NS_OK; +} + NS_IMETHODIMP nsLocalFile::IsWritable(PRBool *outIsWritable) {