• 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: Rename files containing a slash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rename files containing a slash


  • Subject: Re: Rename files containing a slash
  • From: Charles Srstka <email@hidden>
  • Date: Mon, 21 Oct 2002 21:40:55 -0500

To attempt to clear up the confusion a little here:

The one and only character that cannot be used in a filename is not the slash, but the colon, on HFS+ partitions, as it is the path delimiter for that file system. However, the POSIX API, used by all the BSD commands used at the Terminal as well as Cocoa apps, uses slashes to delimit folders in paths. The system works around this by actually allowing slash characters to be stored but displaying them as colons to the POSIX API, and vice versa, so that programs that expect the slash to be prohibited and the colon to be allowed will work without modification. But the Carbon API's, which are also on top of POSIX, then swap the characters *again* so that the slash character is once again allowed, for the benefit of apps ported from the Mac OS, where slashes were allowed and colons were not.

So, the original poster's problem was that he was using a Cocoa API to get the path, and a Carbon API to deal with it. The correct solution would not be to swap the characters manually as some have suggested but rather to simply use the same API to deal with the path as you use to get it.

Thus, either renaming the file with Cocoa (via the -[NSFileManager movePath:toPath:handler:] method) or getting the path from Carbon in the first place will solve your problem. Since it looks like you're taking in an NSString, it's probably easiest just to use NSFileManager.

Charles

On Monday, October 21, 2002, at 03:27 PM, Ondra Cada wrote:

On Monday, October 21, 2002, at 08:47 , Finlay Dobbie wrote:

A filename can't contain a slash. It is the *one* character which is dsiabled for filenames.

Actually, : is also disallowed

No it is not: just do try.

(it's the HFS native path separator, in fact).

Might be (I know next to nothing of HFS), but if so, luckily lower levels of software do hide that thing.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Rename files containing a slash
      • From: Lorenzo Puleo <email@hidden>
References: 
 >Re: Rename files containing a slash (From: Ondra Cada <email@hidden>)

  • Prev by Date: Document Model
  • Next by Date: Re: [NSTableView selectedCell] crash
  • Previous by thread: Re: Rename files containing a slash
  • Next by thread: Re: Rename files containing a slash
  • Index(es):
    • Date
    • Thread