/// Extract a particular information from the disk partition dictionary from a key, generate a string value output␊ |
-(NSString*) createStringValueWithKey: (NSString*) key␊ |
{␊ |
␉␉if (err) return @"";␊ |
␉␉CFTypeRef o = [descDict objectForKey: key];␊ |
␉␉if (o==nil) return @"";␊ |
␉␉return (NSString*) CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), o);␊ |
␉if (err) return @"";␊ |
␉CFTypeRef o = [descDict objectForKey: key];␊ |
␉if (o==nil) return @"";␊ |
␉CFStringRef sref = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), o);␊ |
␉NSString* s = [[((NSString*) sref) copy] autorelease];␊ |
␉CFRelease(sref);␊ |
␉return s;␊ |
}␊ |
␊ |
/// main extraction method create a dictionary containing all needed information from disk arbitration API␊ |
|
␉␉if (disk == NULL) err = EINVAL;␊ |
␉}␊ |
␉␊ |
␉[self cleanup];␊ |
␊ |
␉if (err == 0) {␊ |
␉␉descDict = (NSDictionary*) DADiskCopyDescription(disk);␊ |
␉␉[descDict retain];␊ |
␉␉␊ |
␉␉if (descDict == NULL) err = EINVAL;␊ |
␉␉CFDictionaryRef␉dr = DADiskCopyDescription(disk);␊ |
␉␉if (dr!=NULL)␊ |
␉␉{␊ |
␉␉␉self.descDict = [((NSDictionary*) dr) copy];␊ |
␉␉␉CFRelease(dr);␊ |
␉␉␉if (self.descDict == NULL) err = EINVAL;␊ |
␉␉}␊ |
␉}␊ |
␊ |
␉if (err == 0) {␊ |
␉␉self.vUUID = [self createStringValueWithKey: @"DAVolumeUUID"];␊ |
␉␉self.vName = [self createStringValueWithKey: @"DAVolumeName"];␊ |
␉␉self.vAliasName = self.vName; // by default renamed = original part name ␊ |
␉␉self.vKind = [self createStringValueWithKey: @"DAVolumeKind"];␊ |
␉␉self.mediaPath = [self createStringValueWithKey: @"DAMediaPath"];␊ |
␉␉self.devProtocol = [self createStringValueWithKey: @"DADeviceProtocol"];␊ |
|
␉␉devInternal = (bool) [[descDict objectForKey: @"DADeviceInternal"] boolValue];␊ |
␉␉mediaRemovable = (bool) [[descDict objectForKey: @"DAMediaRemovable"] boolValue];␊ |
␉␉␊ |
␉␉self.vAliasName = self.vName; // by default renamed = original part name ␊ |
␉}␊ |
␉␊ |
␉// Clean up.␊ |
|
␉␉␉}␊ |
␉␉␉if (session!=nil) CFRelease(session);␊ |
␉}␊ |
␉␊ |
␉[partArr release];␊ |
␉return arr;␊ |
}␊ |
␊ |
|
␉return self;␊ |
}␊ |
␊ |
/// release created objects␊ |
-(void) dealloc␊ |
-(void) cleanup␊ |
{␊ |
␉if (descDict != nil) [descDict release];␊ |
␊ |
␉if (descDict != nil) CFRelease(descDict);␊ |
␉if (bsdName != nil) [bsdName release];␊ |
␉if (vUUID != nil) [vUUID release];␊ |
␉if (vKind != nil) [vKind release];␊ |
␉if (vName != nil) [vName release];␊ |
␉if (mediaPath != nil) [mediaPath release];␊ |
␉if (devProtocol != nil) [devProtocol release];␊ |
␉if (vAliasName != nil) [vAliasName release];␊ |
␉bsdName = vUUID = vKind = vName = mediaPath = devProtocol = vAliasName = nil;␊ |
␉descDict = nil;␊ |
}␊ |
␊ |
␉if (vAliasName != nil) [vAliasName release];␊ |
␉␊ |
/// release created objects␊ |
-(void) dealloc␊ |
{␊ |
␉[self cleanup];␊ |
␉[super dealloc];␊ |
}␊ |
␊ |