Re: Rename files containing a slash
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.