mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-15 08:01:40 +00:00
Added new script search paths
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@19809 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2e7e5f3d37
commit
e9767d770e
3 changed files with 65 additions and 22 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2004 Aug 2 Stefan Urbanek
|
||||
|
||||
* Search for scripts in */Library/Scripts/*
|
||||
* stexec: use scripts manager to look for scripts in default locations. For
|
||||
this tool it is .../Library/Scripts/Shell or .../Library/StepTalk/Scripts/Shell
|
||||
|
||||
2004 Jul 26 Stefan Urbanek
|
||||
|
||||
* Added NSString containsString: to Foundation module.
|
||||
|
||||
2004 Jun 27 Stefan Urbanek
|
||||
|
||||
* Added examples:
|
||||
|
|
|
@ -135,6 +135,20 @@ process name.*/
|
|||
str = [path stringByAppendingPathComponent:@"Shared"];
|
||||
[scriptPaths addObject:str];
|
||||
}
|
||||
|
||||
/* Add same, but without StepTalk (only Library/Scripts) */
|
||||
enumerator = [paths objectEnumerator];
|
||||
|
||||
while( (path = [enumerator nextObject]) )
|
||||
{
|
||||
path = [path stringByAppendingPathComponent:@"Scripts"];
|
||||
|
||||
str = [path stringByAppendingPathComponent: scriptsDomainName];
|
||||
[scriptPaths addObject:str];
|
||||
|
||||
str = [path stringByAppendingPathComponent:@"Shared"];
|
||||
[scriptPaths addObject:str];
|
||||
}
|
||||
|
||||
enumerator = [[NSBundle allBundles] objectEnumerator];
|
||||
|
||||
|
@ -191,6 +205,7 @@ process name.*/
|
|||
{
|
||||
if( [manager fileExistsAtPath:path isDirectory:&isDir] && isDir )
|
||||
{
|
||||
// NSLog(@"VARLIOD %@", path);
|
||||
[scriptPaths addObject:path];
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +232,7 @@ process name.*/
|
|||
|
||||
while( (path = [pEnumerator nextObject]) )
|
||||
{
|
||||
// NSLog(@"IN %@", path);
|
||||
sEnumerator = [[manager directoryContentsAtPath:path] objectEnumerator];
|
||||
|
||||
while( (file = [sEnumerator nextObject]) )
|
||||
|
|
|
@ -116,16 +116,17 @@ const char *STExecutorCommonOptions =
|
|||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
STEnvironment *env;
|
||||
NSString *convLanguageName;
|
||||
NSString *source;
|
||||
|
||||
if( [manager fileExistsAtPath:file isDirectory:NO] )
|
||||
{
|
||||
NSString *source = [NSString stringWithContentsOfFile:file];
|
||||
source = [NSString stringWithContentsOfFile:file];
|
||||
|
||||
if(langName)
|
||||
{
|
||||
NSDebugLog(@"Using language %@", langName);
|
||||
|
||||
[conversation setLanguage:langName];
|
||||
convLanguageName = langName;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -133,31 +134,47 @@ const char *STExecutorCommonOptions =
|
|||
[file pathExtension]);
|
||||
|
||||
convLanguageName = [STLanguage languageNameForFileType:[file pathExtension]];
|
||||
[conversation setLanguage:convLanguageName];
|
||||
}
|
||||
|
||||
|
||||
if(conversation)
|
||||
{
|
||||
NSDebugLog(@"Executing file '%@'",file);
|
||||
|
||||
env = [conversation environment];
|
||||
[env setObject:args forName:@"Args"];
|
||||
[env setObject:env forName:@"Environment"];
|
||||
|
||||
[conversation runScriptFromString:source];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:STExecutorException
|
||||
format:@"Unable to create a StepTalk conversation."];
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
STScriptsManager *sm;
|
||||
STFileScript *script;
|
||||
|
||||
/* Try to find it in standard script locations */
|
||||
sm = [[STScriptsManager alloc] initWithDomainName:@"Shell"];
|
||||
|
||||
script = [sm scriptWithName:file];
|
||||
source = [script source];
|
||||
if(!source)
|
||||
{
|
||||
[NSException raise:STExecutorException
|
||||
format:@"Could not find script '%@'", file];
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
convLanguageName = [script language];
|
||||
}
|
||||
}
|
||||
|
||||
[conversation setLanguage:convLanguageName];
|
||||
|
||||
if(conversation)
|
||||
{
|
||||
NSDebugLog(@"Executing script '%@'",file);
|
||||
|
||||
env = [conversation environment];
|
||||
[env setObject:args forName:@"Args"];
|
||||
[env setObject:env forName:@"Environment"];
|
||||
|
||||
[conversation runScriptFromString:source];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:STExecutorException
|
||||
format:@"Could not find script '%@'", file];
|
||||
format:@"Unable to create a StepTalk conversation."];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue