зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
c185df6a51
Коммит
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)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче