kolibrios/programs/system/shell/modules/module_executable.c
siemargl 46ae9b5169 fix touch and much more
git-svn-id: svn://kolibrios.org@6826 a494cfbc-eb01-0410-851d-a64ba20cac60
2017-01-06 21:23:13 +00:00

70 lines
1.3 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// ===========================================================
int executable_run(char cmd[], char args[])
{
char exec[FILENAME_MAX];
int result;
if ( '/' == cmd[0]) // ¥á«¨ ¯ãâì  ¡á®«îâ­ë©
{
strcpy(exec, cmd);
if ( !file_check(exec) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ä ©« 
{
file_not_found(cmd);
return FALSE;
}
}
else
{
strcpy(exec, cur_dir); // ¯à®¢¥à塞 ä ©« ¢ ⥪ã饬 ª â «®£¥
if (exec[strlen(exec)-1] != '/')
strcat(exec, "/"); // add slash
strcat(exec, cmd);
if ( !file_check(exec) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ä ©« 
{
strcpy(exec, "/rd/1/"); // ¯à®¢¥à塞 ä ©« ­  ¢¨àâã «ì­®¬ ¤¨áª¥
strcat(exec, cmd);
if ( !file_check(exec) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ä ©« 
{
file_not_found(cmd);
return FALSE;
}
}
}
if ( script_check(exec) )
return script_run(exec, args);
/* § ¯ã᪠¯à®£à ¬¬ë */
result = program_run(exec, args);
if (result > 0)
{
if ( !program_console(result) )
{
LAST_PID = result;
#if LANG_ENG
printf (" '%s' started. PID = %d\n\r", cmd, result);
#elif LANG_RUS
printf (" '%s' § ¯ã饭. PID = %d\n\r", cmd, result);
#endif
}
return TRUE;
}
else
{
file_not_found(cmd);
return FALSE;
}
}
/// ===========================================================