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 12:53:18 -0700
- Thread-topic: How to programmatically mount a disk/volume using only a given file path?
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/Conceptu
> al/FileSystemProgrammingGUide/AccessingFilesandDirectories/AccessingFilesandDi
> 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-vo
>> 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