kolibrios-gitea/programs/system/shell/modules/module_executable.c
Nasarus 3256dedea8 Shell 0.4.4 (All)
git-svn-id: svn://kolibrios.org@1665 a494cfbc-eb01-0410-851d-a64ba20cac60
2010-10-17 19:50:55 +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;
}
}
/// ===========================================================