Re: How to discover the volume id to use in a File Reference URL
Re: How to discover the volume id to use in a File Reference URL
- Subject: Re: How to discover the volume id to use in a File Reference URL
- From: Ben Staveley-Taylor <email@hidden>
- Date: Tue, 24 Sep 2013 09:24:11 +0100
Thanks, Ken.
The reason I want to do this is to discover the textual path of a file given its file ID (and a volume name). The only way I could come up with to do this was to create a file reference NSURL and then convert it to a file path URL with [NSURL filePathURL]. If there is a better way to do that then that would be great.
You're right, if I create a file reference URL for the volume then I can see the volume ID number I need in its absolute string so that is a workaround for now. But as you have now pointed out the URL format is supposed to be opaque, so that is clearly a fragile solution.
So I suppose my real question is how to find the path for a file by its id (its fileSystemFileNumber attribute). I am aware that a file might have multiple paths if there are hard links to it.
-- Ben.
On 24 Sep 2013, at 09:04, Ken Thomases <email@hidden> wrote:
> On Sep 23, 2013, at 11:14 AM, Ben Staveley-Taylor wrote:
>
>> Does anyone know how to get the volume ID number to use in a reference URL?
>>
>> I am working with file reference URLs as returned by - (NSURL *)fileReferenceURL. These have this textual form:
>>
>> file:///.file/id=<volume_id>.<file_id>/
>> e.g. file:///.file/id=6571367.2773272/
>>
>> I want to compose a reference URL for a file whose file_id I know.
>
> Why would you want to do that?
>
> In any case, it's not supported. From "NSURL and CFURL Release Notes: File Reference URLs" <https://developer.apple.com/library/mac/releasenotes/Cocoa/RN-NSURL/#//apple_ref/doc/uid/TP40007753-CH1-DontLinkElementID_2>:
>
> "The syntax of a file reference URL should be considered opaque, and may change from release to release."
>
>
>> I know the textual path of the volume it is on (e.g "/Volumes/Bob"). I can't figure out how to get the volume ID to use from the volume name or path
>
> I hesitate to suggest this, but have you tried creating an NSURL for a file path on the volume and then asking it for its file-reference-URL form?
>
> ...
> -Ken
>
_______________________________________________
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