From 8e13a8327dcf32267a4f9e82f63bbb3a125b3fe1 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 26 Dec 2010 21:07:55 +0900 Subject: [PATCH] Use NSFileManager methods instead of access(). This even fixes a bug where an inaccessible bspSound was being opened. --- tools/Forge/Bundles/MapEdit/Preferences.m | 4 ++-- tools/Forge/Bundles/MapEdit/Project.m | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/Forge/Bundles/MapEdit/Preferences.m b/tools/Forge/Bundles/MapEdit/Preferences.m index fdf1d04f1..31ab7ed19 100644 --- a/tools/Forge/Bundles/MapEdit/Preferences.m +++ b/tools/Forge/Bundles/MapEdit/Preferences.m @@ -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]; } diff --git a/tools/Forge/Bundles/MapEdit/Project.m b/tools/Forge/Bundles/MapEdit/Project.m index 2077bdfd0..975f83bcd 100644 --- a/tools/Forge/Bundles/MapEdit/Project.m +++ b/tools/Forge/Bundles/MapEdit/Project.m @@ -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);