From 748b857484a868d02db5c30923fe9825bb6dbe31 Mon Sep 17 00:00:00 2001 From: Nikos Barkas Date: Thu, 15 Jul 2010 16:31:45 +0000 Subject: [PATCH] Unbroken SDL builds. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3674 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/GameController.m | 1 + src/Core/NSFileManagerOOExtensions.h | 8 ++++++++ src/Core/NSFileManagerOOExtensions.m | 28 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Core/GameController.m b/src/Core/GameController.m index 800e44e9..18bb2180 100644 --- a/src/Core/GameController.m +++ b/src/Core/GameController.m @@ -999,6 +999,7 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context) [fmgr createDirectoryAtPath:path attributes:nil]; } } + return url; } #else diff --git a/src/Core/NSFileManagerOOExtensions.h b/src/Core/NSFileManagerOOExtensions.h index 537fe063..9d202c30 100644 --- a/src/Core/NSFileManagerOOExtensions.h +++ b/src/Core/NSFileManagerOOExtensions.h @@ -30,11 +30,19 @@ MA 02110-1301, USA. #define SAVEDIR "oolite-saves" +#if OOLITE_SDL +#define SNAPSHOTDIR "snapshots" +#endif + @interface NSFileManager (OOExtensions) - (NSArray*) commanderContentsOfPath:(NSString*) savePath; - (NSString*) defaultCommanderPath; +#if OOLITE_SDL +- (BOOL) chdirToSnapshotPath; +#endif + @end diff --git a/src/Core/NSFileManagerOOExtensions.m b/src/Core/NSFileManagerOOExtensions.m index 97cd116d..97feb6be 100644 --- a/src/Core/NSFileManagerOOExtensions.m +++ b/src/Core/NSFileManagerOOExtensions.m @@ -27,10 +27,10 @@ MA 02110-1301, USA. */ #include -#import "NSFileManagerOOExtensions.h" #import "ResourceManager.h" #import "OOPListParsing.h" #import "GameController.h" +#import "NSFileManagerOOExtensions.h" #define kOOLogUnconvertedNSLog @"unclassified.NSFileManagerOOExtensions" @@ -116,6 +116,32 @@ MA 02110-1301, USA. return savedir; } + +#if OOLITE_SDL +- (BOOL) chdirToSnapshotPath +{ + // SDL: the default path for snapshots is oolite.app/oolite-saves/snapshots + NSString *savedir = [[NSHomeDirectory() stringByAppendingPathComponent:@SAVEDIR] stringByAppendingPathComponent:@SNAPSHOTDIR]; + + if (![self changeCurrentDirectoryPath: savedir]) + { + // it probably doesn't exist. + if (![self createDirectoryAtPath: savedir attributes: nil]) + { + OOLog(@"savedSnapshot.defaultPath.create.failed", @"Unable to create directory %@", savedir); + return NO; + } + if (![self changeCurrentDirectoryPath: savedir]) + { + OOLog(@"savedSnapshot.defaultPath.chdir.failed", @"Created %@ but couldn't make it the current directory.", savedir); + return NO; + } + } + + return YES; +} +#endif + @end