• 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
Creating directory at path, recursively
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating directory at path, recursively


  • Subject: Creating directory at path, recursively
  • From: Jean-Nicolas Jolivet <email@hidden>
  • Date: Thu, 13 Nov 2008 13:01:58 -0500

I know there's a method to do just that in Leopard, however I want my app to work on Tiger too, therefore I'm trying to put together a simple "createDirectoryRecursivelyAtPath" method, however for some reason it doesn't seem to work....

Here's a simplified version of my method:

- (void)createDirectoryRecursivelyAtPath:(NSString *)path
{
//check if the dir just above exists...
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDir;
NSString *directoryAbove = [path stringByDeletingLastPathComponent];
if ([fileManager fileExistsAtPath:directoryAbove isDirectory:&isDir] && isDir)
{
// Fine, create the dir...
[fileManager createDirectoryAtPath:path attributes:nil];
}
else
{
// call ourself with the directory above...
[self createDirectoryRecursivelyAtPath:directoryAbove];
}
}


Am I missing something? If I'm trying to create for example: /a/b/c (and none of them exists) only /a is created...

Jean-Nicolas Jolivet
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • RE: Creating directory at path, recursively
      • From: Etienne GuĂ©rard <email@hidden>
  • Prev by Date: Re: EXC_BAD_ACCESS with 10.5.5 AppKit on some MacPros
  • Next by Date: Re: NSConnection/NSMachPort and CPU Loads.
  • Previous by thread: Re: EXC_BAD_ACCESS with 10.5.5 AppKit on some MacPros
  • Next by thread: RE: Creating directory at path, recursively
  • Index(es):
    • Date
    • Thread