• 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
renaming a file with special/reserved characters in name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: renaming a file with special/reserved characters in name
      • From: Michael Ash <email@hidden>
  • Prev by Date: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Next by Date: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Previous by thread: Re: NSScrollView's content view doesn't un-hide
  • Next by thread: Re: renaming a file with special/reserved characters in name
  • Index(es):
    • Date
    • Thread