Fix osx launcher crash when there is a space in the launcher path. Launching the game still doesn't work in this case.

This commit is contained in:
Paul Chote
2010-12-22 20:35:43 +13:00
parent 54c49dfa15
commit 7ef884532d
9 changed files with 21 additions and 22 deletions

View File

@@ -139,7 +139,7 @@
if ([aMod standalone]) if ([aMod standalone])
{ {
id path = [[game gamePath] stringByAppendingPathComponent:@"mods"]; id path = [[game gamePath] stringByAppendingPathComponent:@"mods"];
id child = [SidebarEntry entryWithMod:aMod allMods:allMods baseURL:[NSURL URLWithString:path]]; id child = [SidebarEntry entryWithMod:aMod allMods:allMods basePath:path];
[rootItem addChild:child]; [rootItem addChild:child];
} }
} }

View File

@@ -71,7 +71,7 @@
if (current != nil) if (current != nil)
{ {
id path = [gamePath stringByAppendingPathComponent:[NSString stringWithFormat:@"mods/%@",current]]; id path = [gamePath stringByAppendingPathComponent:[NSString stringWithFormat:@"mods/%@",current]];
[ret setObject:[Mod modWithId:current fields:fields baseURL:[NSURL URLWithString:path]] forKey:current]; [ret setObject:[Mod modWithId:current fields:fields path:path] forKey:current];
} }
NSLog(@"Parsing mod %@",value); NSLog(@"Parsing mod %@",value);
current = value; current = value;
@@ -85,7 +85,7 @@
if (current != nil) if (current != nil)
{ {
id path = [gamePath stringByAppendingPathComponent:[NSString stringWithFormat:@"mods/%@",current]]; id path = [gamePath stringByAppendingPathComponent:[NSString stringWithFormat:@"mods/%@",current]];
[ret setObject:[Mod modWithId:current fields:fields baseURL:[NSURL URLWithString:path]] forKey:current]; [ret setObject:[Mod modWithId:current fields:fields path:path] forKey:current];
} }
return ret; return ret;

View File

@@ -209,8 +209,7 @@ static JSBridge *SharedInstance;
} }
// Disallow traversing up the directory tree // Disallow traversing up the directory tree
id path = [[[mod baseURL] absoluteString] id path = [[mod path] stringByAppendingPathComponent:[aFile stringByReplacingOccurrencesOfString:@"../"
stringByAppendingPathComponent:[aFile stringByReplacingOccurrencesOfString:@"../"
withString:@""]]; withString:@""]];
return [[NSFileManager defaultManager] fileExistsAtPath:path]; return [[NSFileManager defaultManager] fileExistsAtPath:path];

View File

@@ -9,7 +9,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface Mod : NSObject { @interface Mod : NSObject {
NSURL *baseURL; NSString *path;
NSString *mod; NSString *mod;
NSString *title; NSString *title;
NSString *version; NSString *version;
@@ -25,9 +25,9 @@
@property (readonly) NSString *author; @property (readonly) NSString *author;
@property (readonly) NSString *description; @property (readonly) NSString *description;
@property (readonly) NSString *requires; @property (readonly) NSString *requires;
@property (readonly) NSURL *baseURL; @property (readonly) NSString *path;
@property (readonly) BOOL standalone; @property (readonly) BOOL standalone;
+ (id)modWithId:(NSString *)mid fields:(id)fields baseURL:(NSURL *)url; + (id)modWithId:(NSString *)mid fields:(id)fields path:(NSString *)path;
- (id)initWithId:(NSString *)anId fields:(NSDictionary *)fields baseURL:(NSURL *)url; - (id)initWithId:(NSString *)anId fields:(NSDictionary *)fields path:(NSString *)path;
@end @end

View File

@@ -17,22 +17,22 @@
@synthesize description; @synthesize description;
@synthesize requires; @synthesize requires;
@synthesize standalone; @synthesize standalone;
@synthesize baseURL; @synthesize path;
+ (id)modWithId:(NSString *)mod fields:(id)fields baseURL:(NSURL *)url + (id)modWithId:(NSString *)mod fields:(id)fields path:(NSString *)aPath
{ {
id newObject = [[self alloc] initWithId:mod fields:fields baseURL:url]; id newObject = [[self alloc] initWithId:mod fields:fields path:aPath];
[newObject autorelease]; [newObject autorelease];
return newObject; return newObject;
} }
- (id)initWithId:(NSString *)anId fields:(NSDictionary *)fields baseURL:(NSURL *)url - (id)initWithId:(NSString *)anId fields:(NSDictionary *)fields path:(NSString *)aPath
{ {
self = [super init]; self = [super init];
if (self) if (self)
{ {
mod = [anId retain]; mod = [anId retain];
baseURL = [url retain]; path = [aPath retain];
title = [[fields objectForKey:@"Title"] retain]; title = [[fields objectForKey:@"Title"] retain];
version = [[fields objectForKey:@"Version"] retain]; version = [[fields objectForKey:@"Version"] retain];
author = [[fields objectForKey:@"Author"] retain]; author = [[fields objectForKey:@"Author"] retain];
@@ -46,7 +46,7 @@
- (void) dealloc - (void) dealloc
{ {
[mod release]; mod = nil; [mod release]; mod = nil;
[baseURL release]; baseURL = nil; [path release]; path = nil;
[title release]; title = nil; [title release]; title = nil;
[version release]; version = nil; [version release]; version = nil;
[author release]; author = nil; [author release]; author = nil;

View File

@@ -25,7 +25,7 @@
+ (id)headerWithTitle:(NSString *)aTitle; + (id)headerWithTitle:(NSString *)aTitle;
+ (id)entryWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon; + (id)entryWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon;
+ (id)entryWithMod:(Mod *)baseMod allMods:(NSDictionary *)allMods baseURL:(NSURL *)aURL; + (id)entryWithMod:(Mod *)baseMod allMods:(NSDictionary *)allMods basePath:(NSString *)aPath;
- (id)initWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon isHeader:(BOOL)aHeader; - (id)initWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon isHeader:(BOOL)aHeader;
- (void)addChild:(id)child; - (void)addChild:(id)child;
- (NSURL *)url; - (NSURL *)url;

View File

@@ -29,14 +29,14 @@
return newObject; return newObject;
} }
+ (id)entryWithMod:(Mod *)baseMod allMods:(NSDictionary *)allMods baseURL:(NSURL *)baseURL + (id)entryWithMod:(Mod *)baseMod allMods:(NSDictionary *)allMods basePath:(NSString *)basePath
{ {
// TODO: Get the mod icon from the Mod // TODO: Get the mod icon from the Mod
// Temporary hack until mods define an icon // Temporary hack until mods define an icon
NSString *imageName = [[NSBundle mainBundle] pathForResource:@"OpenRA" ofType:@"icns"]; NSString *imageName = [[NSBundle mainBundle] pathForResource:@"OpenRA" ofType:@"icns"];
id icon = [[[NSImage alloc] initWithContentsOfFile:imageName] autorelease]; NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:imageName] autorelease];
id path = [[[baseURL absoluteString] stringByAppendingPathComponent:[baseMod mod]] stringByAppendingPathComponent:@"mod.html"]; NSURL *url = [NSURL URLWithString:[[[baseMod path] stringByAppendingPathComponent:@"mod.html"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
id ret = [SidebarEntry entryWithTitle:[baseMod title] url:[NSURL URLWithString:path] icon:icon]; SidebarEntry *ret = [SidebarEntry entryWithTitle:[baseMod title] url:url icon:icon];
for (id key in allMods) for (id key in allMods)
{ {
@@ -44,7 +44,7 @@
if (![[aMod requires] isEqualToString:[baseMod mod]]) if (![[aMod requires] isEqualToString:[baseMod mod]])
continue; continue;
id child = [SidebarEntry entryWithMod:aMod allMods:allMods baseURL:baseURL]; id child = [SidebarEntry entryWithMod:aMod allMods:allMods basePath:basePath];
[ret addChild:child]; [ret addChild:child];
} }
return ret; return ret;