[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- [NSFileManager isDeleteableFileAtPath:] bug in usage of access()
From: |
Roland Schwingel |
Subject: |
- [NSFileManager isDeleteableFileAtPath:] bug in usage of access() |
Date: |
Thu, 06 Mar 2003 17:18:31 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 |
Hi...
Its me again...
In -[NSFileManager isDeleteableFileAtPath:] you have
- (BOOL) isDeletableFileAtPath: (NSString*)path
{
const char* cpath = [self fileSystemRepresentationWithPath: path];
... [some code deleted] ...
#else
cpath = [self fileSystemRepresentationWithPath:
[path stringByDeletingLastPathComponent]];
return (access(cpath, X_OK || W_OK) != 0);
#endif
}
}
I thinks this access() call cannot work...
1) The parameter #2 for access() is defined to be a bitmask so it should
be X_OK | W_OK
2) -isDeleteableFileAtPath: should return YES when the file is
deleteable. access() returns 0 on success,
so the logic is invers.
In my opinion the line with the access() call should read
return (access(cpath, X_OK | W_OK) == 0);
And that is the way I got it working here. With the current
implementation the
method returns NO for perfectly deleteable files...
Roland
- - [NSFileManager isDeleteableFileAtPath:] bug in usage of access(),
Roland Schwingel <=