2010-10-17 21:50:55 +02:00
|
|
|
|
|
2014-12-02 03:21:37 +01:00
|
|
|
|
|
2010-10-17 21:50:55 +02:00
|
|
|
|
int cmd_cd(char dir[])
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char temp[256];
|
|
|
|
|
unsigned result;
|
|
|
|
|
|
|
|
|
|
if (NULL == dir)
|
|
|
|
|
{
|
2010-10-21 01:58:36 +02:00
|
|
|
|
#if LANG_ENG
|
|
|
|
|
printf(" cd <directory>\n\r");
|
|
|
|
|
#elif LANG_RUS
|
2013-10-13 12:47:59 +02:00
|
|
|
|
printf(" cd <<3C><>४<EFBFBD><E0A5AA><EFBFBD><EFBFBD><EFBFBD>>\n\r");
|
2010-10-21 01:58:36 +02:00
|
|
|
|
#endif
|
2013-02-17 16:22:51 +01:00
|
|
|
|
return TRUE;
|
2010-10-17 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( 0 == strcmp(dir, ".") )
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2014-12-02 03:21:37 +01:00
|
|
|
|
if ( ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) )
|
2010-10-17 21:50:55 +02:00
|
|
|
|
{
|
|
|
|
|
cur_dir[strlen(cur_dir)-1]='\0';
|
|
|
|
|
dir_truncate(cur_dir);
|
2014-12-02 03:21:37 +01:00
|
|
|
|
set_cwd(cur_dir);
|
2013-10-26 20:53:48 +02:00
|
|
|
|
return TRUE;
|
2010-10-17 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( '/' == dir[0])
|
|
|
|
|
{
|
|
|
|
|
if ( dir_check(dir) )
|
|
|
|
|
{
|
|
|
|
|
strcpy(cur_dir, dir);
|
2014-12-02 03:21:37 +01:00
|
|
|
|
set_cwd(cur_dir);
|
2010-10-17 21:50:55 +02:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strcpy(temp, cur_dir);
|
2014-12-02 03:21:37 +01:00
|
|
|
|
if (cur_dir[strlen(cur_dir)-1] != '/')
|
2011-12-15 19:06:01 +01:00
|
|
|
|
strcat(temp, "/");
|
2010-10-17 21:50:55 +02:00
|
|
|
|
strcat(temp, dir);
|
|
|
|
|
|
|
|
|
|
if ( dir_check(temp) )
|
|
|
|
|
{
|
2011-12-15 19:06:01 +01:00
|
|
|
|
|
2010-10-17 21:50:55 +02:00
|
|
|
|
strcpy(cur_dir, temp);
|
2014-12-02 03:21:37 +01:00
|
|
|
|
set_cwd(cur_dir);
|
2010-10-17 21:50:55 +02:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2013-02-24 11:33:37 +01:00
|
|
|
|
|