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?


> So far I have tried
> 
>       NSURL *vol = [NSURL urlWithString:@"/Volumes/Bob"];     
>       id volId;
> 
>       [vol getResourceValue:&volId
>               forKey: NSURLVolumeIdentifierKey
>               error:&err];
> 
> But can't see how to use the opaque volId object result;

It's opaque by design.  It's only useful for comparing to another volume's 
identifier with -isEqual:.  That's it.  It's for when you have two URL objects 
and you want to determine if they're on the same volume.

-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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to