Skip to content

Commit

Permalink
Use fileSystemRepresentation to get a file's POSIX path, as opposed t…
Browse files Browse the repository at this point in the history
…o UTF8String
  • Loading branch information
MaddTheSane authored and C.W. Betts committed Aug 29, 2015
1 parent 85ada5b commit 5fd66cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions ui/StoryMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1093,17 +1093,17 @@ - (StoryMainViewController*)init {

NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
docPath = [array[0] copy];
chdir([docPath UTF8String]);
chdir([docPath fileSystemRepresentation]);

storyGamePath = [docPath stringByAppendingPathComponent: @kFrotzGameDir];
storyTopSavePath = [docPath stringByAppendingPathComponent: @kFrotzSaveDir];


if (![fileMgr fileExistsAtPath: storyGamePath]) {
[fileMgr createDirectoryAtPath: storyGamePath attributes: nil];
[fileMgr createDirectoryAtPath: storyGamePath attributes: [NSDictionary dictionary]];
}
if (![fileMgr fileExistsAtPath: storyTopSavePath]) {
[fileMgr createDirectoryAtPath: storyTopSavePath attributes: nil];
[fileMgr createDirectoryAtPath: storyTopSavePath attributes: [NSDictionary dictionary]];
}

NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
Expand All @@ -1115,9 +1115,9 @@ - (StoryMainViewController*)init {
storySIPSavePath= [storyTopSavePath stringByAppendingPathComponent: @kFrotzOldAutoSaveFile];
activeStoryPath = [storyTopSavePath stringByAppendingPathComponent: @kFrotzAutoSaveActiveFile];

strcpy(SAVE_PATH, [storyTopSavePath UTF8String]);
strcpy(SAVE_PATH, [storyTopSavePath fileSystemRepresentation]);

strcpy(AUTOSAVE_FILE, [storySIPSavePath UTF8String]); // used by interpreter from z_save
strcpy(AUTOSAVE_FILE, [storySIPSavePath fileSystemRepresentation]); // used by interpreter from z_save

m_currentStory = [NSMutableString stringWithString: @""];

Expand Down Expand Up @@ -2533,7 +2533,7 @@ -(void) fileBrowser: (FileBrowser *)browser fileSelected:(NSString *)file {
[self.navigationController setNavigationBarHidden:m_landscape ? YES:NO animated:YES];
}
if (file)
strcpy(iosif_filename, [file UTF8String]);
strcpy(iosif_filename, [file fileSystemRepresentation]);
else
*iosif_filename = '\0';
[self activateKeyboard];
Expand Down Expand Up @@ -2732,7 +2732,7 @@ -(void)updateAutosavePaths {
}
if (storySavePath) {
storySIPSavePath= [storySavePath stringByAppendingPathComponent: @kFrotzAutoSaveFile];
strcpy(AUTOSAVE_FILE, [storySIPSavePath UTF8String]); // used by interpreter from z_save
strcpy(AUTOSAVE_FILE, [storySIPSavePath fileSystemRepresentation]); // used by interpreter from z_save
}
}

Expand Down Expand Up @@ -2767,8 +2767,8 @@ -(void) setCurrentStory: (NSString*)storyPath {
if (m_currentStory) {
storySavePath = [storyTopSavePath stringByAppendingPathComponent: [self saveSubFolderForStory: m_currentStory]];
if (![fileMgr fileExistsAtPath: storySavePath])
[fileMgr createDirectoryAtPath: storySavePath attributes: nil];
strcpy(SAVE_PATH, [storySavePath UTF8String]);
[fileMgr createDirectoryAtPath: storySavePath attributes: [NSDictionary dictionary]];
strcpy(SAVE_PATH, [storySavePath fileSystemRepresentation]);

if (![fileMgr fileExistsAtPath: storySIPPathOld]) {
[self updateAutosavePaths];
Expand Down Expand Up @@ -3832,7 +3832,7 @@ -(BOOL) autoRestoreSession {
NSString *savedScriptname = dict[@"scriptname"];
if (savedScriptname) {
savedScriptname = [self relativePathToAppAbsolutePath: savedScriptname];
iosif_start_script((char*)[savedScriptname UTF8String]);
iosif_start_script((char*)[savedScriptname fileSystemRepresentation]);
} else
iosif_stop_script();

Expand Down
4 changes: 2 additions & 2 deletions ui/ui_utils.m
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ BOOL readGLULheaderFromUlxOrBlorb(const char *filename, char *glulHeader) {


BOOL metaDataFromBlorb(NSString *blorbFile, NSString **title, NSString **author, NSString **description, NSString **tuid) {
const char *filename = [blorbFile UTF8String];
const char *filename = [blorbFile fileSystemRepresentation];
BOOL found = NO;
FILE *fp;
if ((fp = os_path_open(filename, "rb")) == NULL)
Expand Down Expand Up @@ -497,7 +497,7 @@ BOOL metaDataFromBlorb(NSString *blorbFile, NSString **title, NSString **author,
}

NSData *imageDataFromBlorb(NSString *blorbFile) {
const char *filename = [blorbFile UTF8String];
const char *filename = [blorbFile fileSystemRepresentation];
NSData *data = nil;
FILE *fp;
if ((fp = os_path_open(filename, "rb")) == NULL)
Expand Down

0 comments on commit 5fd66cc

Please sign in to comment.