Skip to content

Commit 25c850c

Browse files
committed
F-Script 2.1
1 parent bb1724a commit 25c850c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2440
-485
lines changed

F-Script/FScriptAppController.m

+32-19
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ - (void)loadSystemFrameworks // Contributed by Cedric Luthi
176176

177177
for (NSString *systemFrameworksPath in systemFrameworksPaths)
178178
{
179-
for (NSString *framework in [[NSFileManager defaultManager] directoryContentsAtPath:systemFrameworksPath])
179+
for (NSString *framework in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:systemFrameworksPath error:NULL])
180180
{
181181
NSBundle *frameworkBundle = [NSBundle bundleWithPath:[systemFrameworksPath stringByAppendingPathComponent:framework]];
182182
if ([frameworkBundle preflightAndReturnError:nil])
@@ -222,33 +222,46 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
222222

223223
if (!repositoryPath || ![fileManager fileExistsAtPath:repositoryPath isDirectory:&b])
224224
{
225+
NSError *error = nil;
225226
NSString *applicationSupportDirectoryPath = findPathToFileInLibraryWithinUserDomain(@"Application Support");
227+
BOOL repositoryCreated = NO;
226228

227229
if (!applicationSupportDirectoryPath)
228230
{
229231
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
230232

231233
if ([pathArray count] > 0)
232-
[fileManager createDirectoryAtPath:[[pathArray objectAtIndex:0] stringByAppendingPathComponent:@"Application Support"] attributes:nil];
234+
[fileManager createDirectoryAtPath:[[pathArray objectAtIndex:0] stringByAppendingPathComponent:@"Application Support"] withIntermediateDirectories:NO attributes:nil error:NULL];
233235
}
234236

235237
applicationSupportDirectoryPath = findPathToFileInLibraryWithinUserDomain(@"Application Support");
236238

237239
if (applicationSupportDirectoryPath)
238-
{
240+
{
239241
repositoryPath = [applicationSupportDirectoryPath stringByAppendingPathComponent:@"F-Script"];
240-
[fileManager createDirectoryAtPath:repositoryPath attributes:nil];
241-
[fileManager createDirectoryAtPath:[repositoryPath stringByAppendingPathComponent:@"classes"] attributes:nil];
242-
if ([[NSUserDefaults standardUserDefaults] respondsToSelector:@selector(setObject:forKey:inDomain:)])
243-
[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath" inDomain:NSGlobalDomain]; // This is an undocumented Cocoa API in Mac OS X 10.1
242+
243+
[fileManager createDirectoryAtPath:[repositoryPath stringByAppendingPathComponent:@"classes"] withIntermediateDirectories:YES attributes:nil error:&error];
244+
245+
if (error)
246+
NSLog(@"Failed to create the repository: %@", error);
244247
else
245-
[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath"];
246-
[[NSUserDefaults standardUserDefaults] setObject:[repositoryPath stringByAppendingPathComponent:@"journal.txt"] forKey:@"FScriptJournalName"];
247-
[[NSUserDefaults standardUserDefaults] synchronize];
248+
{
249+
repositoryCreated = YES;
250+
if ([[NSUserDefaults standardUserDefaults] respondsToSelector:@selector(setObject:forKey:inDomain:)])
251+
[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath" inDomain:NSGlobalDomain]; // This is an undocumented Cocoa API in Mac OS X 10.1
252+
else
253+
[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath"];
254+
[[NSUserDefaults standardUserDefaults] setObject:[repositoryPath stringByAppendingPathComponent:@"journal.txt"] forKey:@"FScriptJournalName"];
255+
[[NSUserDefaults standardUserDefaults] synchronize];
256+
}
248257
}
249-
else
258+
else
250259
{
251260
NSLog(@"Failed to create the repository in the user's \"Application Support\" directory.");
261+
}
262+
263+
if (!repositoryCreated)
264+
{
252265
NSInteger choice = NSRunAlertPanel(@"Instalation" , @"F-Script is about to create a directory named \"FScriptRepository\" in your home directory. This directory will be used as a repository for things like extension bundles for F-Script and a journal file.", @"create the repository", @"don't create the repository", @"create the repository elsewhere...");
253266

254267
if (choice == NSAlertOtherReturn || choice == NSAlertDefaultReturn)
@@ -265,20 +278,20 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
265278
}
266279
else repositoryPath = [NSHomeDirectory() stringByAppendingPathComponent:@"FScriptRepository"];
267280

268-
if (repositoryPath)
281+
error = nil;
282+
[fileManager createDirectoryAtPath:[repositoryPath stringByAppendingPathComponent:@"classes"] withIntermediateDirectories:YES attributes:nil error:&error];
283+
if (error)
284+
NSLog(@"Failed to create the repository: %@", error);
285+
else
269286
{
270-
287+
repositoryCreated = YES;
271288
if ([[NSUserDefaults standardUserDefaults] respondsToSelector:@selector(setObject:forKey:inDomain:)])
272289
[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath" inDomain:NSGlobalDomain]; // This is an undocumented Cocoa API in Mac OS X 10.1
273290
else
274291
[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath"];
275-
276-
//[[NSUserDefaults standardUserDefaults] setObject:repositoryPath forKey:@"FScriptRepositoryPath"];
277-
[fileManager createDirectoryAtPath:repositoryPath attributes:nil];
278-
[fileManager createDirectoryAtPath:[repositoryPath stringByAppendingPathComponent:@"classes"] attributes:nil];
279-
280292
[[NSUserDefaults standardUserDefaults] setObject:[repositoryPath stringByAppendingPathComponent:@"journal.txt"] forKey:@"FScriptJournalName"];
281-
}
293+
[[NSUserDefaults standardUserDefaults] synchronize];
294+
}
282295
}
283296
}
284297
}

F-Script/fs_main.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
int main(int argc, const char **argv)
55
{
66
RestartWithCorrectGarbageCollectionSettingIfNecessary();
7-
8-
return NSApplicationMain(argc, argv);
7+
return NSApplicationMain(argc, argv);
98
}
109

0 commit comments

Comments
 (0)