On Thu, Feb 26, 2009 at 2:29 AM, Martin Wierschin <mar...@nisus.com> wrote:
>> Except it doesn't, because each filesystem is different. The above is
>> true for HFS+, it is NOT true for FAT32, which has a whole bunch of
>> other characters which are illegal.
>>
>> This is the bad news: there is NO way to tell what those characters are.
>
> It seems totally crazy that there isn't an API for this, Cocoa or not. Oh
> well, obviously one must code to handle a failure in the rename operation,
> so this actually simplifies my task. I still have to hardcode the magic
> conversion of slashes to colons- a shame.

There *can't* be an API for it. Take the case of NFS. NFS has no
character set restrictions beyond the basics that apply to all UNIXen.
But the underlying filesystem that the NFS server is writing things to
may well have more restrictions. You could have an NFS server that
serves files off a FAT32 drive, for example. Or a special NFS server
that requires every third byte of a filename to be an even number.
There is simply no way to communicate this back to the client.

In addition to mapping / to :, I also recommend explicitly stripping
NULs. This may sound useless, but it's not. A user can get a NUL into
a string by copy/pasting from a program which generates them. This
isn't as impossible as it may seem. Once a NUL has found its way into
your program, on the Cocoa side of things it's simply a do-nothing
character that just doesn't take up any space or draw anything. But
when it goes off to the POSIX side of things it will truncate the
string! For example, this string:

@"Hello\x00World"

Will look like this:

@"HelloWorld"

But it will write to this file:

@"Hello"

I've had it happen and it was foolishly annoying to track down.
Definitely worth removing even if it almost never appears.

Mike
_______________________________________________

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