OS X launcher: Create download directory if it doesn't exist.

This commit is contained in:
Paul Chote
2010-12-21 21:29:50 +13:00
parent 8809cbb4f1
commit 54c49dfa15
2 changed files with 6 additions and 1 deletions

View File

@@ -101,8 +101,13 @@ static JSBridge *SharedInstance;
- (BOOL)registerDownload:(NSString *)key withURL:(NSString *)url filename:(NSString *)filename - (BOOL)registerDownload:(NSString *)key withURL:(NSString *)url filename:(NSString *)filename
{ {
// Create the download directory if it doesn't exist
NSString *downloadDir = [@"~/Library/Application Support/OpenRA/Downloads/" stringByExpandingTildeInPath];
if (![[NSFileManager defaultManager] fileExistsAtPath:downloadDir])
[[NSFileManager defaultManager] createDirectoryAtPath:downloadDir withIntermediateDirectories:YES attributes:nil error:NULL];
// Disallow traversing directories; take only the last component // Disallow traversing directories; take only the last component
id path = [[@"~/Library/Application Support/OpenRA/Downloads/" stringByAppendingPathComponent:[filename lastPathComponent]] stringByExpandingTildeInPath]; NSString *path = [downloadDir stringByAppendingPathComponent:[filename lastPathComponent]];
return [controller registerDownload:key withURL:url filePath:path]; return [controller registerDownload:key withURL:url filePath:path];
} }