Revision: 4410
http://skim-app.svn.sourceforge.net/skim-app/?rev=4410&view=rev
Author: hofman
Date: 2008-08-15 09:19:08 +0000 (Fri, 15 Aug 2008)
Log Message:
-----------
Add app bundle paths to the PATH environment rather than explicitly looking in
the bundle for sync support.
Modified Paths:
--------------
trunk/NSTask_SKExtensions.h
trunk/NSTask_SKExtensions.m
trunk/SKPDFDocument.m
Modified: trunk/NSTask_SKExtensions.h
===================================================================
--- trunk/NSTask_SKExtensions.h 2008-08-14 23:42:02 UTC (rev 4409)
+++ trunk/NSTask_SKExtensions.h 2008-08-15 09:19:08 UTC (rev 4410)
@@ -41,5 +41,6 @@
@interface NSTask (SKExtensions)
+ (NSTask *)launchedTaskWithLaunchPath:(NSString *)launchPath
arguments:(NSArray *)arguments currentDirectoryPath:(NSString *)directoryPath;
++ (NSTask *)launchedTaskWithLaunchPath:(NSString *)launchPath
arguments:(NSArray *)arguments currentDirectoryPath:(NSString *)directoryPath
environment:(NSDictionary *)environment;
+ (BOOL)runTaskWithLaunchPath:(NSString *)launchPath arguments:(NSArray
*)arguments currentDirectoryPath:(NSString *)directoryPath;
@end
Modified: trunk/NSTask_SKExtensions.m
===================================================================
--- trunk/NSTask_SKExtensions.m 2008-08-14 23:42:02 UTC (rev 4409)
+++ trunk/NSTask_SKExtensions.m 2008-08-15 09:19:08 UTC (rev 4410)
@@ -42,10 +42,17 @@
@implementation NSTask (SKExtensions)
+ (NSTask *)launchedTaskWithLaunchPath:(NSString *)launchPath
arguments:(NSArray *)arguments currentDirectoryPath:(NSString *)directoryPath {
+ return [self launchedTaskWithLaunchPath:launchPath arguments:arguments
currentDirectoryPath:directoryPath environment:nil];
+}
+
++ (NSTask *)launchedTaskWithLaunchPath:(NSString *)launchPath
arguments:(NSArray *)arguments currentDirectoryPath:(NSString *)directoryPath
environment:(NSDictionary *)environment {
NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath:launchPath];
- [task setCurrentDirectoryPath:directoryPath];
+ if (directoryPath)
+ [task setCurrentDirectoryPath:directoryPath];
+ if (environment)
+ [task setEnvironment:environment];
[task setArguments:arguments];
[task setStandardOutput:[NSFileHandle fileHandleWithNullDevice]];
[task setStandardError:[NSFileHandle fileHandleWithNullDevice]];
Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m 2008-08-14 23:42:02 UTC (rev 4409)
+++ trunk/SKPDFDocument.m 2008-08-15 09:19:08 UTC (rev 4410)
@@ -1409,54 +1409,30 @@
NSString *editorPreset = [[NSUserDefaults standardUserDefaults]
objectForKey:SKTeXEditorPresetKey];
NSString *editorCmd = [[NSUserDefaults standardUserDefaults]
objectForKey:SKTeXEditorCommandKey];
NSMutableString *cmdString = [[[[NSUserDefaults standardUserDefaults]
objectForKey:SKTeXEditorArgumentsKey] mutableCopy] autorelease];
+ NSEnumerator *pathEnum = [[[NSApp delegate]
applicationSupportDirectories] objectEnumerator];
+ NSString *appSupportPath;
NSMutableDictionary *environment = [[[[NSProcessInfo processInfo]
environment] mutableCopy] autorelease];
+ NSMutableArray *paths = [NSMutableArray arrayWithArray:[[environment
objectForKey:@"PATH"] componentsSeparatedByString:@":"]];
+ if ([paths containsObject:@"/usr/bin"] == NO)
+ [paths addObject:@"/usr/bin"];
+ if ([paths containsObject:@"/usr/local/bin"] == NO)
+ [paths addObject:@"/usr/local/bin"];
if ([editorPreset isEqualToString:@""] == NO) {
NSString *appPath = [[NSWorkspace sharedWorkspace]
fullPathForApplication:editorPreset];
if (appPath) {
- NSFileManager *fm = [NSFileManager defaultManager];
NSBundle *appBundle = [NSBundle bundleWithPath:appPath];
- NSString *toolPath;
- if ((toolPath = [@"/usr/bin"
stringByAppendingPathComponent:editorCmd]) &&
- [fm isExecutableFileAtPath:toolPath]) {
- editorCmd = toolPath;
- } else if ((toolPath = [@"/usr/local/bin"
stringByAppendingPathComponent:editorCmd]) &&
- [fm isExecutableFileAtPath:toolPath]) {
- editorCmd = toolPath;
- } else if (toolPath = [appBundle pathForResource:editorCmd
ofType:nil]) {
- editorCmd = toolPath;
- } else if (toolPath = [appBundle
pathForAuxiliaryExecutable:editorCmd]) {
- editorCmd = toolPath;
- } else if (toolPath = [appBundle
pathForAuxiliaryExecutable:[@"bin" stringByAppendingPathComponent:editorCmd]]) {
- // Emacs has its tool in Emacs.app/Contents/MacOS/bin/
- editorCmd = toolPath;
- } else if ((toolPath = [[appBundle sharedSupportPath]
stringByAppendingPathComponent:editorCmd]) &&
- [fm isExecutableFileAtPath:toolPath]) {
- editorCmd = toolPath;
- } else if ((toolPath = [[[appBundle sharedSupportPath]
stringByAppendingPathComponent:@"bin"]
stringByAppendingPathComponent:editorCmd]) &&
- [fm isExecutableFileAtPath:toolPath]) {
- editorCmd = toolPath;
- } else if ((toolPath = [[appBundle resourcePath]
stringByAppendingPathComponent:editorCmd]) &&
- [fm isExecutableFileAtPath:toolPath]) {
- editorCmd = toolPath;
- } else if ((toolPath = [[[appBundle resourcePath]
stringByAppendingPathComponent:@"bin"]
stringByAppendingPathComponent:editorCmd]) &&
- [fm isExecutableFileAtPath:toolPath]) {
- editorCmd = toolPath;
- }
+ [paths addObjectsFromArray:[NSArray arrayWithObjects:
+ [appBundle resourcePath], [[appBundle resourcePath]
stringByAppendingPathComponent:@"bin"],
+ [appBundle sharedSupportPath], [[appBundle
sharedSupportPath] stringByAppendingPathComponent:@"bin"],
+ [[[appBundle executablePath]
stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bin"],
nil]];
}
- } else {
- NSString *path = [environment objectForKey:@"PATH"];
- NSMutableArray *paths = [NSMutableArray
arrayWithObjects:@"/usr/local/bin", nil];
- NSEnumerator *pathEnum = [[[NSApp delegate]
applicationSupportDirectories] objectEnumerator];
- NSString *appSupportPath;
- if ([path length])
- [paths insertObject:path atIndex:0];
- while (appSupportPath = [pathEnum nextObject]) {
- [paths addObject:appSupportPath];
- [paths addObject:[appSupportPath
stringByAppendingPathComponent:@"Scripts"]];
- }
- [environment setObject:[paths componentsJoinedByString:@":"]
forKey:@"PATH"];
}
+ while (appSupportPath = [pathEnum nextObject]) {
+ [paths addObject:appSupportPath];
+ [paths addObject:[appSupportPath
stringByAppendingPathComponent:@"Scripts"]];
+ }
+ [environment setObject:[paths componentsJoinedByString:@":"]
forKey:@"PATH"];
NSRange range = NSMakeRange(0, 0);
unichar prevChar, nextChar;
@@ -1497,7 +1473,7 @@
[cmdString insertString:@"/usr/bin/osascript " atIndex:0];
}
- [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray
arrayWithObjects:@"-c", cmdString, nil] currentDirectoryPath:[file
stringByDeletingLastPathComponent]];
+ [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray
arrayWithObjects:@"-c", cmdString, nil] currentDirectoryPath:[file
stringByDeletingLastPathComponent] environment:environment];
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit