• 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: Checking a path for isDirectory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking a path for isDirectory


  • Subject: Re: Checking a path for isDirectory
  • From: j o a r <email@hidden>
  • Date: Tue, 14 Aug 2001 14:35:28 +0200

On Tuesday, August 14, 2001, at 02:22 , Chris Mar wrote:

I'm having problems checking a path to see if its a directory, I know path
is correct because I'm using it to build bundles for files, but I want to
skip over directories. This code just doesn't seem to work, I was wondering
if
anyone had problems like this in the past. I'm using 10.0.4 and the
developer tools from WWDC.

I use this code, and it seems to work:
("theFileManager" in my code is a reference to the default manager for this thread, exactly like in your code)

// Make sure that the path is accessible and that the folder it points to exists
- (BOOL)validateFolderPath:(NSString *)thePath
{
// NSLog(@"Enter: validateFolderPath: %@", thePath);

{
BOOL isFile = FALSE;
BOOL isFolder = FALSE;

isFile = [theFileManager fileExistsAtPath:thePath isDirectory:&isFolder];
// NSLog(@"Is file: %d, is folder: %d", isFile, isFolder);

if (isFile && isFolder) {
return TRUE;
} else {
// Is this a symbolic link?
NSDictionary *tempDict = [theFileManager fileAttributesAtPath:thePath traverseLink:NO];

if ([tempDict objectForKey:NSFileType] == NSFileTypeSymbolicLink) {
// NSLog(@"Folder at path is symbolic link.");
// Recursion! :)
return [self validateFolderPath:[thePath stringByResolvingSymlinksInPath]];
} else {
NSLog(@"Folder at path [%@] is neither folder nor link to folder. Bad things will happen!", thePath);
return FALSE;
}
}
}
}


Good luck,

j oa r


References: 
 >Checking a path for isDirectory (From: "Chris Mar" <email@hidden>)

  • Prev by Date: Checking a path for isDirectory
  • Next by Date: Problems with NSInvocation - arguments misplaced? [long]
  • Previous by thread: Checking a path for isDirectory
  • Next by thread: Re: Fun with AuthorizationExecuteWithPrivileges...
  • Index(es):
    • Date
    • Thread