• 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
Directory enumeration gives wrong file type for aliases
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Directory enumeration gives wrong file type for aliases


  • Subject: Directory enumeration gives wrong file type for aliases
  • From: Gabriel Zachmann <email@hidden>
  • Date: Fri, 07 Oct 2016 16:21:55 +0100

I am trying to enumerate the contents of a directory (aka folder) using NSDirectoryEnumerator.
My problem is that the file attributes always returns NSFileTypeRegular,
no matter whether it is an alias/symlink or a regular file.

You can see my code below.

I have tried to retrieve the file attributes with attributesOfItemAtPath:error: , and with fileAttributes,
both dictionaries returned by those methods are exactly the same, AFAICS.

According to the documentation
   https://developer.apple.com/reference/foundation/nsfilemanager/1410452-attributesofitematpath?language=objc
I would at least attributesOfItemAtPath:error expect to show NSFileTypeSymbolicLink for the aliases and symlinks.

Could some kind soul please shed some light on this? or give me a hint?

Thanks a lot in advance.

Best regards,
Gabriel.


My code:

- (void) scanDirectoryByHand: (NSString*) dir
{
    NSDirectoryEnumerator *	enumerator = [fmanager_ enumeratorAtPath: dir];
    for ( NSString * file in enumerator )
    {
        fattrs = [fmanager_ attributesOfItemAtPath: [dir stringByAppendingPathComponent: file] error: NULL];
        fattrs = [enumerator fileAttributes];
        NSString * filetype = [fattrs objectForKey: NSFileType];
        if ( ! [filetype isEqualToString: NSFileTypeRegular] ||
             [NSNumber numberWithBool: YES] == [fattrs objectForKey: NSFileExtensionHidden] )


_______________________________________________

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: Directory enumeration gives wrong file type for aliases
      • From: Quincey Morris <email@hidden>
    • Re: Directory enumeration gives wrong file type for aliases
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Can a Spotlight search follow aliases / symlinks?
  • Next by Date: Re: How to count Atoms
  • Previous by thread: Can a Spotlight search follow aliases / symlinks?
  • Next by thread: Re: Directory enumeration gives wrong file type for aliases
  • Index(es):
    • Date
    • Thread