Fix bug # 122571: add ability to determine if a directory is actually a package (for Mac OS 9/X) r=ccarlen sr=ben
git-svn-id: svn://10.0.0.236/trunk@113252 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user