mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-03-19 09:02:02 +00:00
Convenience method to find executables, by Richard Frith-Macdonald
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@37587 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ea418f3ff1
commit
d6cf2a702d
2 changed files with 40 additions and 1 deletions
|
@ -330,6 +330,42 @@ static PCFileManager *_mgr = nil;
|
|||
return YES;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Find Executable
|
||||
// Tries to find the first matching executable tool fromt he given, nil-terminated
|
||||
// list. Returns the full path for it.
|
||||
// ===========================================================================
|
||||
- (NSString*) findExecutableToolFrom: (NSArray*)candidates
|
||||
{
|
||||
NSFileManager *manager;
|
||||
NSEnumerator *relPath;
|
||||
NSEnumerator *pathEnumerator;
|
||||
NSString *directory;
|
||||
|
||||
manager = [NSFileManager defaultManager];
|
||||
pathEnumerator = [NSSearchPathForDirectoriesInDomains(NSDeveloperDirectory, NSAllDomainsMask, YES) objectEnumerator];
|
||||
|
||||
while (nil != (directory = [pathEnumerator nextObject]))
|
||||
{
|
||||
NSEnumerator *candidateEnumerator = [candidates objectEnumerator];
|
||||
NSString *candidate;
|
||||
|
||||
while (nil != (candidate = [candidateEnumerator nextObject]))
|
||||
{
|
||||
NSString *path = [directory stringByAppendingPathComponent: candidate];
|
||||
|
||||
NSLog(@"final candidate path is: %@", path);
|
||||
|
||||
if ([manager isExecutableFileAtPath: path])
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCFileManager (UInterface)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
|
||||
|
||||
Copyright (C) 2000-2004 Free Software Foundation
|
||||
Copyright (C) 2000-2014 Free Software Foundation
|
||||
|
||||
Authors: Philippe C.D. Robert
|
||||
Serg Stoyan
|
||||
|
@ -112,6 +112,9 @@ enum {
|
|||
|
||||
- (BOOL)moveFile:(NSString *)file intoDirectory:(NSString *)directory;
|
||||
|
||||
// find an executable from list and return full path
|
||||
- (NSString*) findExecutableToolFrom: (NSArray*)candidates;
|
||||
|
||||
@end
|
||||
|
||||
@interface PCFileManager (UInterface)
|
||||
|
|
Loading…
Reference in a new issue