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

Re: Creating directory at path, recursively


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

This is exactly what I need, but it's only available on 10.5 or later, hence why I'm trying to put a simple equivalent together...

JNJ

On 13-Nov-08, at 1:21 PM, Quincey Morris wrote:

On Nov 13, 2008, at 10:11, Etienne Guérard wrote:

You might want to do it this way:

- (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)
{
// call ourself with the directory above...
[self createDirectoryRecursivelyAtPath:directoryAbove];
}
// Now we enforced that the dir exist
// Fine, create the dir...
[fileManager createDirectoryAtPath:path attributes:nil];
}

Or even this way: [[NSFileManager defaultManger] createDirectoryAtPath: path withIntermediateDirectories: YES attributes: nil error: &error]?



_______________________________________________

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

_______________________________________________

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


References: 
 >Creating directory at path, recursively (From: Jean-Nicolas Jolivet <email@hidden>)
 >RE: Creating directory at path, recursively (From: Etienne Guérard <email@hidden>)
 >Re: Creating directory at path, recursively (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Weird bug in IB...
  • Next by Date: Re: Creating directory at path, recursively
  • Previous by thread: Re: Creating directory at path, recursively
  • Next by thread: Re: Creating directory at path, recursively
  • Index(es):
    • Date
    • Thread