• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
createDirectoryAtPath anomaly between system versions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

createDirectoryAtPath anomaly between system versions?


  • Subject: createDirectoryAtPath anomaly between system versions?
  • From: Antonio Nunes <email@hidden>
  • Date: Wed, 5 Jul 2006 10:47:37 +0100

Hi,

Is anybody aware of a change/bug-fix somewhere between 10.4.3 and 10.4.7 where creating a directory in applicationWillFinishLaunching works in 10.4.7 but not in 10.4.3?

On my PowerBook running 10.4.7 everything works fine, but on my iBook running 10.4.3 the directory is not created, even though to the code it looks like it does. Surprisingly [fileManager createDirectoryAtPath:myAppDirectoryPath attributes:nil] returns successfully, so my code doesn't see the error until later when it looks for the app's directory in the application support folder and finds it is not there.

On 10.4.3 I can successfully create the directory a moment later in applicationDidFinishLaunching. But I really need it before that. The folowing code is called from applicationWillFinishLaunching:

- (NSString *) createMyAppApplicationSupportDirectoryIfNeededWithDomainMask:(int) domainMask
{
BOOL isDir, exists, success = NO;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *myAppDirectoryPath = nil;


NSArray *paths = NSSearchPathForDirectoriesInDomains (NSApplicationSupportDirectory, domainMask, YES);

if ([paths count] > 0) {
myAppDirectoryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"MyApp"];
exists = [fileManager fileExistsAtPath:myAppDirectoryPath isDirectory:&isDir];
if (!isDir) {
// There is no MyApp directory so create it
success = [fileManager createDirectoryAtPath:myAppDirectoryPath attributes:nil];
if (!success) {
myAppDirectoryPath = nil;
NSRunAlertPanel(@"MyApp",
NSLocalizedString(@"Could not create MyApp directory", @"Could not create the \"MyApp\" directory in %@"),
NSLocalizedString(@"OK", @"OK"),
NULL, NULL,
[myAppDirectoryPath stringByDeletingLastPathComponent]);
}
} // if (!isDir)
} else {
NSRunAlertPanel(@"MyApp",
NSLocalizedString(@"AppSupportDirectoryMissing", @"The Application Support folder is missing."),
NSLocalizedString(@"OK", @"OK"),
NULL, NULL);
}


	return myAppDirectoryPath;
}

Thanks,
António

-----------------------------------------------------------
What you have inside you expresses itself through both your
choice of words and the level of energy you assign to them.
The more healed, whole and connected you feel inside,
the more healing your words will be.

--Rita Goswami
-----------------------------------------------------------


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: [SOLVED] createDirectoryAtPath anomaly between system versions?
      • From: Antonio Nunes <email@hidden>
  • Prev by Date: Permissions in an app bundle
  • Next by Date: Re: Permissions in an app bundle
  • Previous by thread: Re: Permissions in an app bundle
  • Next by thread: Re: [SOLVED] createDirectoryAtPath anomaly between system versions?
  • Index(es):
    • Date
    • Thread