Bug 462034. Should consider .desktop files executable. r=bsmedberg

git-svn-id: svn://10.0.0.236/trunk@254789 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2008-10-29 05:06:16 +00:00
parent aa951d6f06
commit 6a9b79dd76
2 changed files with 22 additions and 0 deletions

View File

@@ -1306,6 +1306,11 @@ nsLocalFile::IsExecutable(PRBool *_retval)
NS_ENSURE_ARG_POINTER(_retval);
struct stat buf;
if (IsDesktopFile()) {
*_retval = PR_TRUE;
return NS_OK;
}
*_retval = (stat(mPath.get(), &buf) == 0);
if (*_retval || errno == EACCES) {
*_retval = *_retval && (buf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH ));
@@ -1356,6 +1361,11 @@ nsLocalFile::IsExecutable(PRBool *_retval)
CHECK_mPath();
NS_ENSURE_ARG_POINTER(_retval);
if (IsDesktopFile()) {
*_retval = PR_TRUE;
return NS_OK;
}
*_retval = (access(mPath.get(), X_OK) == 0);
if (*_retval || errno == EACCES)
return NS_OK;
@@ -1842,3 +1852,13 @@ void
nsLocalFile::GlobalShutdown()
{
}
PRBool
nsLocalFile::IsDesktopFile()
{
// Just needs to be good enough to match nsFileProtocolHandler::ReadURLFile
nsCAutoString leafName;
nsresult rv = GetNativeLeafName(leafName);
return NS_FAILED(rv) ||
StringEndsWith(leafName, NS_LITERAL_CSTRING(".desktop"));
}