• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
detecting the USB drives
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

detecting the USB drives


  • Subject: detecting the USB drives
  • From: "Gurmit Teotia" <email@hidden>
  • Date: Tue, 21 Nov 2006 18:10:15 +0530

Hi

I'm detecting the USB drives in my application using NSWorkspace
class. Sample code is like this

      BOOL isRemovable,isWritable,isUnmountable;
	NSString *desc;
	NSString *type;

	NSWorkspace *shared=[NSWorkspace sharedWorkspace];

	NSLog(@"Checking for volumes");

	NSArray *mountedList=[shared mountNewRemovableMedia];

	NSEnumerator *enm=[mountedList objectEnumerator];
	NSString *str;

	while((str=(NSString *)[enm nextObject])!=nil){
		NSLog(str);

		if([shared getFileSystemInfoForPath:str isRemovable:&isRemovable
isWritable:&isWritable
							isUnmountable: &isUnmountable description:&desc type:&type ]){

			if (isRemovable && isWritable && isUnmountable) {
				NSLog(@"Usb drive");

                  }else{
                          NSLog(@"Not a usb drive");
		    }
		}
	}


Using above code I'm only able to detect the Usb drive which mount on /Volumes/USB DISK... but not those which mount on /Volumens/Flash Drive; these drives only have writable attribute.

Could someone suggest a better approach to this issue?

Regards,
Gurmit
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: detecting the USB drives
      • From: John Harte <email@hidden>
  • Prev by Date: Re: "-(BOOL)copyPath:(NSString *)source toPath:(NSString *)destination handler:(id)handler" doesnt work properly when file copied across network.
  • Next by Date: Re: KVO and relationships
  • Previous by thread: Re: "-(BOOL)copyPath:(NSString *)source toPath:(NSString *)destination handler:(id)handler" doesnt work properly when file copied across network.
  • Next by thread: Re: detecting the USB drives
  • Index(es):
    • Date
    • Thread