mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Fix bug # 122571: add ability to determine if a directory is actually a package (for Mac OS 9/X) r=ccarlen sr=ben
This commit is contained in:
parent
c185df6a51
commit
73c203cb23
@ -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++
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user