Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. int cmd_touch(char file[])
  3. {
  4.         kol_struct70    k70;
  5.         char            temp[FILENAME_MAX];
  6.         unsigned        result;
  7.  
  8.         if (NULL == file || strlen(file) == 0) {
  9.                 printf(CMD_TOUCH_USAGE);
  10.                 return TRUE;
  11.         }
  12.  
  13.         if (  ( 0 == strcmp(file, ".") ) || ( 0 == strcmp(file, "..") ) || ( 0 == strcmp(cur_dir, "/")) )  {
  14.                 return FALSE;
  15.         }
  16.  
  17.         if ( '/' == file[0]) {
  18.                 strcpy(temp, file);
  19.  
  20.                 if ( !file_check(temp) )
  21.                         k70.p00 = 2;
  22.                 else
  23.                         k70.p00 = 3;
  24.         } else {
  25.                 strcpy(temp, cur_dir);
  26.                 if (temp[strlen(temp)-1] != '/')
  27.                         strcat(temp, "/"); // add slash
  28.                 strcat(temp, file);
  29.                 if ( !file_check(temp) )
  30.                         k70.p00 = 2;
  31.                 else
  32.                         k70.p00 = 3;
  33.         }
  34.  
  35.         k70.p04 = 0;
  36.         //k70.p08 = 0;
  37.         k70.p12 = 0;
  38.         k70.p16 = 0;
  39.         k70.p20 = 0;
  40.         k70.p21 = temp;
  41.  
  42.         //printf("try to touch [%s], fn70(%d)\n\r", temp, k70.p00);
  43.  
  44.         result = kol_file_70(&k70);
  45.  
  46.         if (0 == result)
  47.                 return TRUE;
  48.         else
  49.                 return FALSE;
  50.  
  51. }
  52.