On 17 Mar 2010, at 13:35, gMail.com wrote:

> Hi, I have a file path
>  /Folder/filename.txt
> The API fileExistsAtPath says that it exists.
> Now I need to get its real case sensitive file name, which is indeed e.g.
> "FileName.txt"
> How can I get it in a fast way? I thought by its inode, but I can't really
> know how to do that.

The following seems to work on 10.6

        NSString* path = @"/etc/HOSTS";
        NSURL* url = [NSURL fileURLWithPath: path];
        NSError* error = nil;
        NSArray* keysIWant = [NSArray arrayWithObject: NSURLNameKey];
        NSDictionary* resources = [url resourceValuesForKeys: keysIWant error: 
&error];
        if (resources != nil)
        {
                NSString* actualPath = [resources objectForKey: NSURLNameKey];
                NSLog(@"%@", actualPath);
        }

Gives output: hosts



> 
> I know I can iterate along the contents of the parent directory and do a
> case insensitive match of each item, but this is too long. I need to check
> thousands files. Any fast idea?
> 
> 
> Regards
> --
> Leonardo
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
> 
> This email sent to a...@jeremyp.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to