diff options
author | dynaflash <[email protected]> | 2011-04-25 14:23:37 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2011-04-25 14:23:37 +0000 |
commit | c510a6e18cfee78560a0006dde859872bec4db8e (patch) | |
tree | c53e532e9a07ab302de40cc30c34c4a40b7f033d /macosx/HBDVDDetector.m | |
parent | f4e7ce61efc03ee84672ea3f68a36b312fc523a4 (diff) |
MacGui: Simplify HBDVDDetector bsdName creation
- Instead of lazily populating bsdName identically in two places, why not just have its accessor do it.
- As per patch provided by blindjimmy https://reviews.handbrake.fr/r/78/
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3956 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBDVDDetector.m')
-rw-r--r-- | macosx/HBDVDDetector.m | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/macosx/HBDVDDetector.m b/macosx/HBDVDDetector.m index 81a854597..be2fbbe0d 100644 --- a/macosx/HBDVDDetector.m +++ b/macosx/HBDVDDetector.m @@ -16,7 +16,7 @@ @interface HBDVDDetector (Private) -- (NSString *)bsdNameForPath; +- (NSString *)bsdName; - (BOOL)pathHasVideoTS; - (BOOL)deviceIsDVD; - (io_service_t)getIOKitServiceForBSDName; @@ -58,21 +58,13 @@ - (BOOL)isVideoDVD { - if( !bsdName ) - { - bsdName = [[self bsdNameForPath] retain]; - } return ( [self pathHasVideoTS] && [self deviceIsDVD] ); } - (NSString *)devicePath { - if( !bsdName ) - { - bsdName = [[self bsdNameForPath] retain]; - } - return [NSString stringWithFormat:@"/dev/%@", bsdName]; + return [NSString stringWithFormat:@"/dev/%@", [self bsdName]]; } @end @@ -80,12 +72,17 @@ @implementation HBDVDDetector (Private) -- (NSString *)bsdNameForPath +- (NSString *)bsdName { + if ( bsdName ) + { + return bsdName; + } + OSStatus err; FSRef ref; err = FSPathMakeRef( (const UInt8 *) [path fileSystemRepresentation], - &ref, NULL ); + &ref, NULL ); if( err != noErr ) { return nil; @@ -123,7 +120,8 @@ return nil; } - return [NSString stringWithUTF8String:(const char *)volumeParms.vMDeviceID]; + bsdName = [[NSString stringWithUTF8String:(const char *)volumeParms.vMDeviceID] retain]; + return bsdName; } @@ -157,16 +155,16 @@ - (io_service_t)getIOKitServiceForBSDName { CFMutableDictionaryRef matchingDict; - matchingDict = IOBSDNameMatching( kIOMasterPortDefault, 0, [bsdName UTF8String] ); + matchingDict = IOBSDNameMatching( kIOMasterPortDefault, 0, [[self bsdName] UTF8String] ); if( matchingDict == NULL ) { return IO_OBJECT_NULL; } - + // Fetch the object with the matching BSD node name. There should only be // one match, so IOServiceGetMatchingService is used instead of // IOServiceGetMatchingServices to simplify the code. - return IOServiceGetMatchingService( kIOMasterPortDefault, matchingDict ); + return IOServiceGetMatchingService( kIOMasterPortDefault, matchingDict ); } |