renaming a file with special/reserved characters in name
renaming a file with special/reserved characters in name
- Subject: renaming a file with special/reserved characters in name
- From: Martin Wierschin <email@hidden>
- Date: Wed, 25 Feb 2009 16:47:02 -0800
Hello everyone,
Forgive me if this has already been answered, but my searches through
the archive didn't turn up anything.
The situation is that I need to allow users to rename files within my
application. The name of the file is displayed in an NSTableView, and
the delegate method "tableView:setObjectValue:etc" triggers the
underlying file to be renamed.
A problem arises when a file contains special/reserved characters,
eg: the dreaded backslash/colon. There's the handy -[NSFileManager
displayNameAtPath:] which seems to convert colons in paths to
backslashes for display, but no inverse. How am I to convert whatever
name the user has entered to a form suitable for use with
"stringByAppendingPathComponent:"?
Likewise, what about validation? I don't believe a user can use a
colon ":" on an HFS file system (at least my Finder doesn't allow
it). I would expect a method on NSFileManager like
"pathNameForDisplayName:" that returns nil if the name is illegal on
the underlying file system. I hate to hardcode any of these characters.
Thanks for any help,
~Martin
_______________________________________________
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