On Oct 16, 2010, at 2:25 AM, Thorsten Lemke wrote:

> The NSSavePanel does replace upon close a / in the filename with a :
> How can I avoid this?

You can't.  Slashes are illegal characters in file names at the BSD/Posix 
layer, and thus in Cocoa.  The slash is the path separator characters.  It 
can't appear in file names.

At the GUI layer (the display of file names in the Finder, file dialogs, path 
controls, etc.), slashes are legal but colons are illegal.  This is a holdover 
from classic Mac OS, where the colon was the path separator character.

Therefore, the system swaps slashes for colons and vice versa as file names 
transition from one layer to the other.  Slashes in the GUI layer are replaced 
with colons in file names in Cocoa.  When Cocoa goes to display a file name, 
colons are replaced with slashes.  Although you think you don't want this, you 
do.  It is precisely what is necessary and expected by both the system and 
users.

(This doesn't happen in Carbon because Carbon still uses colons as path 
separators.)

Why do you find this worrisome?  I suspect you are doing something that you 
shouldn't be.  For example, you are displaying path strings to the user, rather 
than using -[NSFileManager displayNameAtPath:] or -[NSFileManager 
componentsToDisplayForPath:].  You should never display path or file name 
strings to the user, only display names.

Regards,
Ken

_______________________________________________

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