Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Commit

Permalink
fixes tilemill-project#1015: migrate certain defaults to ~/.tilemill.…
Browse files Browse the repository at this point in the history
…json
  • Loading branch information
incanus committed Dec 14, 2011
1 parent 4e0db0b commit bbf0ac1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions platforms/osx/TileMillAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,39 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
//
PFMoveToApplicationsFolderIfNecessary();

// v0.7.2+ migrations from defaults to dotfile (see #1015)
//
if ( ! [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/.tilemill.json", NSHomeDirectory()]])
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableArray *options = [NSMutableArray array];

if ([defaults objectForKey:@"serverPort"])
[options addObject:[NSString stringWithFormat:@"\"port\": %i", [defaults integerForKey:@"serverPort"]]];

if ([defaults objectForKey:@"filesPath"])
[options addObject:[NSString stringWithFormat:@"\"files\": \"%@\"", [defaults objectForKey:@"filesPath"]]];

if ([defaults objectForKey:@"bufferSize"])
[options addObject:[NSString stringWithFormat:@"\"bufferSize\": %i", [defaults integerForKey:@"bufferSize"]]];

if ([defaults objectForKey:@"listenAllInterfaces"])
[options addObject:[NSString stringWithFormat:@"\"listenHost\": \"%@\"", ([defaults boolForKey:@"listenAllInterfaces"] ? @"0.0.0.0" : @"127.0.0.1")]];

if ([options count])
{
NSMutableString *contents = [NSMutableString stringWithString:@"{\n "];

[contents appendString:[options componentsJoinedByString:@",\n "]];
[contents appendString:@"\n}\n"];

[contents writeToFile:[NSString stringWithFormat:@"%@/.tilemill.json", NSHomeDirectory()]
atomically:YES
encoding:NSUTF8StringEncoding
error:NULL];
}
}

// setup logging & fire up main functionality
//
self.logPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Logs/TileMill.log"];
Expand Down

0 comments on commit bbf0ac1

Please sign in to comment.