Re: How to programmatically mount a disk/volume using only a given file path?
Re: How to programmatically mount a disk/volume using only a given file path?
- Subject: Re: How to programmatically mount a disk/volume using only a given file path?
- From: Tennis Stringer Dude <email@hidden>
- Date: Thu, 03 Jan 2013 14:14:11 -0700
- Thread-topic: How to programmatically mount a disk/volume using only a given file path?
Interesting.
iTunes stores paths in its "iTunes Music Library.xml" for other programs to
use (such as Keynote, iMovie, etc.). But based on your statement and some
tests I performed, the paths to audio files on unmounted volumes cannot be
accessed by these programs without manually mounting the volume.
How should I go about programmatically accessing these audio files then? Is
there a way to access the bookmarks stored by iTunes? Even if they're
located in the .itl?
Or perhaps there is a way to derive from the path stored in the xml, what
volume needs to be mounted in order to access the file?
-Jared
On 1/3/13 1:12 PM, "Shantonu Sen" <email@hidden> wrote:
> When you originally had the volume mounted, create a bookmark to the file
> (instead of saving a URL, save a bookmark). Later, when you want to access the
> file, resolve the bookmark.
>
> URLs are not persistent, you should not be using them do save paths and later
> reconstitute a handle to the file if you want the semantics you're looking
> for.
>
> Shantonu
>
> On Jan 3, 2013, at 11:53 AM, Tennis Stringer Dude
> <email@hidden> wrote:
>
>> Hi Shantonu,
>>
>> So I took a stab at using bookmarks to accomplish this. Below is my code:
>>
>> CFURLRef path = CFURLCreateFromFileSystemRepresentation(NULL, (const
>> unsigned char *)url.c_str(), url.length(), false);
>> CFErrorRef outError;
>> CFDataRef bookmark = CFURLCreateBookmarkData(NULL, path,
>> kCFURLBookmarkCreationSuitableForBookmarkFile, NULL, NULL, &outError);
>> printf("%ld\r\n", CFErrorGetCode(outError));
>> CFURLCreateByResolvingBookmarkData(NULL, bookmark,
>> kCFURLBookmarkCreationSuitableForBookmarkFile, NULL, NULL, NULL, &outError);
>> printf("%ld\r\n", CFErrorGetCode(outError));
>>
>> So I'm taking a file path in the format "/Volumes/..." that is then
>> converted to "file://localhost/Volumes/..." by
>> CFURLCreateFromFileSystemRepresentation. I then attempt to create a bookmark
>> with this CFURLRef. Unfortunately this returns null and the error given is
>> 260 (i.e. KCFURLReadNoSuchResourceError = 260 // Read error (no such file)).
>>
>> Are you certain that using bookmarks is supposed to automatically mount the
>> volume? More specifically, network attached volumes?
>>
>> -Jared
>>
>>
>> On 1/2/13 7:25 PM, "Shantonu Sen" <email@hidden> wrote:
>>
>>> Use bookmarks:
>>> <http://developer.apple.com/library/Mac/#documentation/FileManagement/Concep
>>> tu
>>> al/FileSystemProgrammingGUide/AccessingFilesandDirectories/AccessingFilesand
>>> Di
>>> rectories.html#//apple_ref/doc/uid/TP40010672-CH3-SW10>
>>>
>>> Shantonu
>>>
>>> On Jan 2, 2013, at 5:03 PM, Tennis Stringer Dude
>>> <email@hidden> wrote:
>>>
>>>> Hello,
>>>>
>>>> I have a list of file paths. These paths may lead to files on unmounted
>>>> Volumes. How can I programmatically tell the OS to mount the volume before
>>>> I
>>>> try to access the file?
>>>>
>>>> I know this is possible somehow, as iTunes appears to do it. For example,
>>>> if
>>>> I initiate playback of a song located on an unmounted network attached
>>>> volume in iTunes, the volume is mounted automatically for me.
>>>>
>>>> Is the OS supposed to mount the volume automatically for me if I attempt to
>>>> open the file programmatically at the specified path? In my testing, it
>>>> appears the answer is no. Or do I need to mount the drive manually using
>>>> the
>>>> Disk Arbitration framework or something similar?
>>>>
>>>> If I need to use the Disk Arbitration framework, can you cite sample code?
>>>>
>>>> P.S.: I listed this question on stackoverflow at [1] about a month ago with
>>>> no response. Decided to try here as well.
>>>>
>>>> [1]
>>>>
http://stackoverflow.com/questions/13426063/programmatically-mount-a-disk-v>>>>
o
>>>> lume-using-only-a-given-file-path-in-mac-os-x
>>>>
>>>> -Jared
>>>>
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Filesystem-dev mailing list (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden