On 30 Apr 2009, at 05:02, Charles Srstka wrote:

Carbon and the Finder are displaying the filenames as is, as HFS allows slashes to be in a filename, and the colon is the separator. Cocoa and the BSD layer, on the other hand, do swap the slashes and colons. Presumably the idea is to display slashes in a filename as whatever the path separator is supposed to be, so that the path can be a standard UNIX path - my guess is that if you had a file on an NTFS volume with a slash in its filename, Cocoa would interpret the slash as a backslash. I don't have an NTFS disk to test that with, though.

Just to clear things up:

1. Cocoa and the "BSD layer" are *not* swapping the slashes and colons. They use the filenames that they are given by the kernel.

2. The HFS+ filesystem implementation *inside the kernel* does map slashes in filenames to colons. It has to, because the kernel parses path strings (which it must do in order to support symlinks and mount points), and it requires that the separator is "/".

3. AFAIK the Carbon layer maps them back again. Carbon's filesystem functions are implemented on top of the BSD layer, not alongside it as some people assume (OK, OK, there is the ".vol" special folder and there are a couple of additional entry-points that Carbon uses that are really SPI rather than API, but they're still BSD-level things).

4. NTFS does not support slashes in filenames (or at least, not on Windows, which is arguably the same thing). Furthermore, Windows (contrary to popular belief) is quite happy to use the slash as a path separator; I sometimes wish that fact was more widely known, because it would save us from reams of unnecessary code to substitute forward slashes with backslashes.

(It might help people to think of the substitution of on-disk "/" characters with ":"s as being entirely an issue of character encoding.)

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

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