Skip to content

Commit 0dfb0f1

Browse files
committed
Removed method -[SSYOtherApper majorVersionOfBundlePath:] because you can use class methods in SSYVersionTriplet which are better.
1 parent 910fd31 commit 0dfb0f1

File tree

2 files changed

+3
-73
lines changed

2 files changed

+3
-73
lines changed

SSYOtherApper.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#import <Cocoa/Cocoa.h>
22

3+
#import "SSYVersionTriplet.h"
4+
35
extern NSString* const SSYOtherApperErrorDomain ;
46

57
extern NSString* const SSYOtherApperKeyPid ;
@@ -146,24 +148,6 @@ __attribute__((visibility("default"))) @interface SSYOtherApper : NSObject {}
146148
*/
147149
+ (SSYOtherApperProcessState)stateOfPid:(pid_t)pid ;
148150

149-
/*!
150-
@brief Returns the major version which is believed to be the version of the
151-
package at a given bundle path, or 0 if no such version could be found
152-
153-
@result First, tries to parse the answer from
154-
of the given
155-
bundlePath, and if that fails tries CFBundleVersion. Usually the former is the one
156-
you want. For example, today I find…
157-
158-
CFBundleShortVersionString CFBundleVersion
159-
-------------------------- ---------------
160-
* Firefox 23.0a2 2313.5.17
161-
* Safari 6.0.5 8536.30.1
162-
163-
Given the above Info.plists, this method would return 23 for Firefox and 6 for Safari.
164-
*/
165-
+ (NSInteger)majorVersionOfBundlePath:(NSString*)bundlePath ;
166-
167151
/*!
168152
@brief Returns the unix process ID (pid) of any process whose last path
169153
component matches a given process name, and whose user id is the same

SSYOtherApper.m

+1-55
Original file line numberDiff line numberDiff line change
@@ -437,60 +437,6 @@ + (SSYOtherApperProcessState)stateOfPid:(pid_t)pid {
437437
return processState ;
438438
}
439439

440-
+ (NSInteger)majorVersionOfBundlePath:(NSString*)bundlePath {
441-
NSString* infoPlistPath = [bundlePath stringByAppendingPathComponent:@"Contents"] ;
442-
infoPlistPath = [infoPlistPath stringByAppendingPathComponent:@"Info.plist"] ;
443-
NSData* data = [NSData dataWithContentsOfFile:infoPlistPath] ;
444-
NSDictionary* infoDic = nil ;
445-
if (data) {
446-
NSError* error = nil ;
447-
infoDic = [NSPropertyListSerialization propertyListWithData:data
448-
options:NSPropertyListImmutable
449-
format:NULL
450-
error:&error] ;
451-
// Documentation of this method is vague, but it appears to be
452-
// better to check for error != nil than infoDic == nil.
453-
if (error) {
454-
NSLog(@"Internal Error 425-2349 %@", error) ;
455-
}
456-
}
457-
458-
NSString* string ;
459-
NSInteger majorVersion ;
460-
if (infoDic) {
461-
string = [infoDic objectForKey:@"CFBundleShortVersionString"] ;
462-
majorVersion = [string majorVersion] ;
463-
464-
if (majorVersion == 0) {
465-
string = [infoDic objectForKey:@"CFBundleVersion"] ;
466-
majorVersion = [string majorVersion] ;
467-
}
468-
}
469-
else {
470-
// This scheme was the only one used until BookMacster 1.6.5.
471-
// It was found that this gives an outdated answer when Firefox is updated,
472-
// until Firefox was launched and quit again.
473-
// This is due to the same bug that plagues Path Finder.
474-
// Actually, the bug is documented, in +[NSBundle bundleWithPath],
475-
// "This method allocates and initializes the returned object if there is no
476-
// existing NSBundle associated with fullPath, in which case it returns the
477-
// existing object" (which, if bundlePath has been updated since this
478-
// app launched, is going to be the old bundle). So now we only
479-
// use this scheme if all else has failed.
480-
NSBundle* bundle = [NSBundle bundleWithPath:bundlePath] ;
481-
482-
string = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"] ;
483-
majorVersion = [string majorVersion] ;
484-
485-
if (majorVersion == 0) {
486-
string = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ;
487-
majorVersion = [string majorVersion] ;
488-
}
489-
}
490-
491-
return majorVersion ;
492-
}
493-
494440
+ (pid_t)pidOfProcessNamed:(NSString*)processName
495441
user:(NSString*)user {
496442
NSArray* infos = [self pidsExecutablesFull:NO] ;
@@ -932,7 +878,7 @@ + (void)killProcessPID:(pid_t)pid
932878
*/
933879

934880
/* The following two methods, written during different years, could be
935-
refactored to use some commone code, if one would want to do the testing. */
881+
refactored to use some common code, if one would want to do the testing. */
936882

937883
+ (BOOL)killThisUsersProcessWithPid:(pid_t)pid
938884
sig:(int)sig

0 commit comments

Comments
 (0)