1
0
kolibrios/programs/system/shell/module_executable.c
Kirill Lipatov (Leency) 939f824d96 Shell 0.4 from Albom
git-svn-id: svn://kolibrios.org@959 a494cfbc-eb01-0410-851d-a64ba20cac60
2008-12-14 11:55:46 +00:00

61 lines
1.1 KiB
C

/// ===========================================================
int executable_run(char cmd[], char args[])
{
char exec[256];
char error_starting[]={" No such command '%s'.\n\r"};
int result;
if ( '/' == cmd[0]) // åñëè ïóòü àáñîëáòíûé
{
strcpy(exec, cmd);
if ( !file_check(exec) ) // ïðîâåðÿåì ñóùåñòâîâàíèå ôàéëà
{
printf(error_starting, cmd);
return FALSE;
}
}
else
{
strcpy(exec, cur_dir); // ïðîâåðÿåì ôàéë â òåêóùåì êàòàëîãå
strcat(exec, cmd);
if ( !file_check(exec) ) // ïðîâåðÿåì ñóùåñòâîâàíèå ôàéëà
{
strcpy(exec, "/rd/1/"); // ïðîâåðÿåì ôàéë íà âèðòóàëüíîì äèñêå
strcat(exec, cmd);
if ( !file_check(exec) ) // ïðîâåðÿåì ñóùåñòâîâàíèå ôàéëà
{
printf(error_starting, cmd);
return FALSE;
}
}
}
if ( script_check(exec) )
{
return script_run(exec, args);
}
/* çàïóñê ïðîãðàììû */
result = program_run(exec, args);
if (result > 0)
{
printf (" '%s' started. PID = %d\n\r", cmd, result);
return TRUE;
}
else
{
printf(error_starting, cmd);
return FALSE;
}
}
/// ===========================================================