Use NSFileManager methods instead of access().

This even fixes a bug where an inaccessible bspSound was being opened.
This commit is contained in:
Bill Currie 2010-12-26 21:07:55 +09:00
parent f105fbd6a0
commit 8e13a8327d
2 changed files with 4 additions and 3 deletions

View file

@ -130,7 +130,7 @@ WriteNumericDefault (id prefs, NSString *name, float value)
// Set the bspSound path
- (id) setBspSoundPath: (NSString *)path
{
NSFileManager *fm = [NSFileManager defaultManager];
[path retain];
[bspSound release];
bspSound = path;
@ -139,7 +139,7 @@ WriteNumericDefault (id prefs, NSString *name, float value)
[bspSound_i release];
bspSound_i = nil;
}
if (access ([path cString], R_OK)) {
if ([fm isReadableFileAtPath: bspSound]) {
bspSound_i = [[NSSound alloc] initWithContentsOfFile: bspSound
byReference: YES];
}

View file

@ -256,9 +256,10 @@ id project_i;
{
NSString *path;
int rtn;
NSFileManager *fm = [NSFileManager defaultManager];
path = [preferences_i getProjectPath];
if (![path length] || access ([path cString], 0)) {
if (![path length] || ![fm fileExistsAtPath: path]) {
rtn = NSRunAlertPanel (@"Project Error!",
@"A default project has not been found.\n",
@"Open Project", NULL, NULL);