how to get list of connected removable drive?

Discussion in 'Mac Programming' started by mkristain, Aug 22, 2011.

  1. mkristain macrumors regular

    Joined:
    Aug 18, 2011
    #1
    hello

    i want to get connected removable device list,please anybody help me to do this.

    thanks.
     
  2. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #3
    i have tried to get how many removable drives are connected to mac.

    coz when i use this

    Code:
    struct statfs *buf = NULL;
    	unsigned ii, count = 0;
    	
    	count = getmntinfo(&buf, 0);
    	for (ii=0; ii<count; ii++)
    	{
    		char *volName = buf[ii].f_mntonname;
    		printf("Volume: %s\n", volName);
    	}
    
    its give all mounted drives not only valid strorage drives.
     
  3. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #4
    If this is an actual Mac app, look at the documentation for the NSWorkspace class.
     
  4. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #5
    can u please more specific about NSWorkspace because there is so many methods and functions in this class so i don't understand which one is use for this.

    if possible can u please provide me any sample app.

    thanks and appreciate ur all suggestion and help.
     
  5. LostSoul80 macrumors 68020

    LostSoul80

    Joined:
    Jan 25, 2009
  6. mkristain, Aug 23, 2011
    Last edited: Aug 23, 2011

    mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011
    #7
    i am get the list by this
    Code:
    NSArray *removableDrivesPaths = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
    
    but its also display mounted drive of .dmg

    i just want only removable drives like i connected a drive to mac.
     
  7. Comrade Yeti macrumors newbie

    Joined:
    Nov 3, 2010
    #8
    Sounds like you need to start investigating the attributes of the mountedRemovableMedia... start going through the documentation (which someone already provided) and see how you can tell the difference between a mounted .dmg and a mounted external drive.
     

Share This Page