2010-10-17 23:50:55 +04:00
|
|
|
|
|
|
|
|
|
int cmd_cd(char dir[])
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char temp[256];
|
|
|
|
|
unsigned result;
|
|
|
|
|
|
|
|
|
|
if (NULL == dir)
|
|
|
|
|
{
|
2010-10-21 03:58:36 +04:00
|
|
|
|
#if LANG_ENG
|
|
|
|
|
printf(" cd <directory>\n\r");
|
|
|
|
|
#elif LANG_RUS
|
|
|
|
|
printf(" cd <<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>\n\r");
|
|
|
|
|
#endif
|
2010-10-17 23:50:55 +04:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( 0 == strcmp(dir, ".") )
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if ( ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) )
|
|
|
|
|
{
|
|
|
|
|
cur_dir[strlen(cur_dir)-1]='\0';
|
|
|
|
|
dir_truncate(cur_dir);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( '/' == dir[0])
|
|
|
|
|
{
|
|
|
|
|
if ( dir_check(dir) )
|
|
|
|
|
{
|
|
|
|
|
strcpy(cur_dir, dir);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strcpy(temp, cur_dir);
|
|
|
|
|
strcat(temp, dir);
|
|
|
|
|
|
|
|
|
|
if ( dir_check(temp) )
|
|
|
|
|
{
|
|
|
|
|
strcpy(cur_dir, temp);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|