Get universal name of /Volumes

Discussion in 'Mac Programming' started by imranpundeer, Jun 24, 2009.

  1. macrumors newbie

    Joined:
    Jan 10, 2009
    #1
    Hi Friends,
    I am searching an API that will provide me the Universal name of /Volume mounted network path.
    Ex: if i have a network path like smb://10.112.41.26/Bkup then i will get the path in MAC programming like this /Volumes/Bkup. Buit i want the actual path of /Volumes/Bkup that is //10.112.41.26/Bkup.

    Any help would be appriciated.

    Regards,
    Shadab
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    smb certainly isn't universal. Are you saying that you want the samba path to a volume?

    -Lee
     
  3. thread starter macrumors newbie

    Joined:
    Jan 10, 2009
    #3
    Hi Lee,
    Thanks for the reply.
    I couldn't understand the samba path.
    I want the actual Network path of /Volume/Bkup as i mentioned in my post.
    Mean i want to detect that the actual path is connected or not if Network path has been unmounted.

    Regards,
    Imran.
     
  4. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    You could try looping through the mounted volumes via getmntinfo() and then use FSCopyURLForVolume() to get the URL for the volume. I've done this before to determine whether a volume is an iDisk, or ftp, etc., so it should work for you.
     
  5. thread starter macrumors newbie

    Joined:
    Jan 10, 2009
    #5
    Hi,
    Thanks for the helpfull suggestion i got the solution and the code is below-
    void getVolumeNameForPath(char* path)
    {
    int err=0;
    CFStringRef str;
    FSRef ref;
    FSCatalogInfo catInfo;
    CFURLRef url;

    err = FSPathMakeRef((UInt8 *) path, &ref, NULL);
    assert(err == noErr);

    err = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catInfo,
    NULL, NULL, NULL);


    err = FSCopyURLForVolume(catInfo.volume, &url);

    str = CFURLGetString(url);
    }

    str will give full Netwirk path name includeing smb.

    Thanks :)
     

Share This Page