Re: to get handle to "File/1.jpg"
Re: to get handle to "File/1.jpg"
- Subject: Re: to get handle to "File/1.jpg"
- From: "Michael Ash" <email@hidden>
- Date: Wed, 26 Nov 2008 12:50:38 -0500
On Wed, Nov 26, 2008 at 11:41 AM, Gregory Weston <email@hidden> wrote:
> Michael Ash wrote:
>
>>> Hi,
>>> How do I obtain a NSFileHandle to this file which has a forward slash in
>>> the
>>> name to be able to write to this file.
>>> Supplying the path to NSFileHandle with filename in quotes also fails.
>>
>> Filenames cannot have slashes in them. If you think that your file has
>> one, then you are wrong. Very likely you think that it does because
>> Finder or other GUI apps are showing it to you that way. This is a
>> lie. A file which they display as having a / actually has a :, and the
>> character has been swapped dynamically. The slash is reserved as the
>> path separator and cannot be used as part of a filename.
>
> Nonsense. What's "actually" there depends on the underlying file system. If
> the file is on an HFS-variant volume there can be a slash in the name (but
> can't be a colon). If that wasn't the case it would be impossible to share
> media meaningfully with pre-X Mac OS and other software that reads HFS. The
> various file system APIs do the translation as necessary between colon and
> slash. The OP's issue is not that the name doesn't really have a slash in
> it; it's that he's using an API that expects POSIX style paths.
>From the perspective of userland Mac OS X code, what I said was
correct. The kernel presents a uniform file API with the
characteristics stated. That the HFS+ filesystem driver happens to
perform additional translations underneath is an irrelevant
implementation detail. Note that the colon/slash translation for
Carbon file APIs happens in userland no matter what filesystem you're
on, whether it's something like HFS+ which can store / but not :, or
whether it's something like UFS which can store : directly.
More to the point, from the perspective of both the Cocoa APIs and the
low-level POSIX APIs that every other userland API goes through,
filenames can contain : but they cannot ever contain /.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden