Subversion Repositories Kolibri OS

Rev

Rev 6826 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. /// ===========================================================
  3.  
  4. int executable_run(char cmd[], char args[])
  5. {
  6.  
  7.         char    exec[FILENAME_MAX];
  8.         int             result;
  9.  
  10.         if ( '/' == cmd[0]) // if path is absolute
  11.         {
  12.                 strcpy(exec, cmd);
  13.                 if (!file_check(exec) ) // check file existense
  14.                 {
  15.                         file_not_found(cmd);
  16.                         return FALSE;
  17.                 }
  18.         }
  19.         else
  20.         {
  21.                 strcpy(exec, cur_dir); // check file in current directory
  22.                 if (exec[strlen(exec)-1] != '/')
  23.                         strcat(exec, "/"); // add slash
  24.                 strcat(exec, cmd);
  25.                
  26.                 if ( !file_check(exec) ) // check file existense
  27.                 {
  28.                         strcpy(exec, "/rd/1/"); // check file on virtual disk
  29.                         strcat(exec, cmd);
  30.                         if ( !file_check(exec) ) // check file existense
  31.                         {
  32.                                 file_not_found(cmd);
  33.                                 return FALSE;
  34.                         }
  35.                 }
  36.         }
  37.  
  38.         // if file exists:
  39.  
  40.         // try to run as a program
  41.         result = program_run(exec, args);
  42.         if (result > 0)
  43.         {
  44.                 if ( !program_console(result)  )
  45.                 {
  46.                                 LAST_PID = result;
  47.                         #if LANG_ENG
  48.                                 printf ("  '%s' started. PID = %d\n\r", cmd, result);
  49.                         #elif LANG_RUS
  50.                                 printf ("  '%s' § ¯ã饭. PID = %d\n\r", cmd, result);
  51.                         #endif
  52.                 }
  53.                 return TRUE;
  54.         }
  55.         else   
  56.         {
  57.                 if ( script_check(exec) ) // if file is a valid script
  58.                 {
  59.                         return script_run(exec, args);
  60.                 } else
  61.                 {
  62.                         #if LANG_ENG
  63.                                 printf ("Error in '%s' : script must start with #SHS line\n\r", cmd);
  64.                         #elif LANG_RUS
  65.                                 printf ("Žè¨¡ª  ¢ '%s' : áªà¨¯â ¤®«¦¥­ ­ ç¨­ âìáï á® áâà®çª¨ #SHS\n\r", cmd);
  66.                         #endif
  67.                         return FALSE;
  68.                 }
  69.         }
  70.  
  71. }
  72.  
  73. /// ===========================================================
  74.  
  75.