Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. int cmd_cd(char dir[])
  3. {
  4.  
  5. char temp[256];
  6. unsigned result;
  7.  
  8. if (NULL == dir)
  9.         {
  10.         printf("  cd directory\n\r");
  11.         return FALSE;
  12.         }
  13.  
  14. if ( 0 == strcmp(dir, ".") )
  15.         return FALSE;
  16.  
  17. if (  ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) )
  18.         {
  19.         cur_dir[strlen(cur_dir)-1]='\0';
  20.         dir_truncate(cur_dir);
  21.         return FALSE;
  22.         }
  23.  
  24. if ( '/' == dir[0])
  25.         {
  26.         if ( dir_check(dir) )
  27.                 {
  28.                 strcpy(cur_dir, dir);
  29.                 return TRUE;
  30.                 }
  31.         return FALSE;
  32.         }
  33. else
  34.         {
  35.         strcpy(temp, cur_dir);
  36.         strcat(temp, dir);
  37.  
  38.         if ( dir_check(temp) )
  39.                 {
  40.                 strcpy(cur_dir, temp);
  41.                 return TRUE;
  42.                 }
  43.  
  44.         return FALSE;
  45.         }
  46.  
  47. }
  48.