mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Improve nsIFile's IsFile on Mac OS X, stop using FSGetCatalogInfo. b=491074 r=mstange sr=roc
This commit is contained in:
parent
56ca298d60
commit
62c4bceb6c
@ -1129,25 +1129,21 @@ NS_IMETHODIMP nsLocalFile::IsDirectory(PRBool *_retval)
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::IsFile(PRBool *_retval)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
FSRef fsRef;
|
||||
nsresult rv = GetFSRefInternal(fsRef);
|
||||
|
||||
nsCAutoString path;
|
||||
nsresult rv = GetPathInternal(path);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
FSCatalogInfo catalogInfo;
|
||||
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNodeFlags, &catalogInfo,
|
||||
nsnull, nsnull, nsnull);
|
||||
if (err != noErr)
|
||||
return MacErrorMapper(err);
|
||||
*_retval = ((catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) == 0);
|
||||
return NS_OK;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
struct STAT buf;
|
||||
if (STAT(path.get(), &buf) != 0)
|
||||
return NSRESULT_FOR_ERRNO();
|
||||
|
||||
*_retval = S_ISREG(buf.st_mode);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::IsSymlink(PRBool *_retval)
|
||||
|
Loading…
x
Reference in New Issue
Block a user