mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-27 16:59:41 +03:00
94572b7fe1
git-svn-id: svn://kolibrios.org@2323 a494cfbc-eb01-0410-851d-a64ba20cac60
55 lines
775 B
C
55 lines
775 B
C
|
|
int cmd_cd(char dir[])
|
|
{
|
|
|
|
char temp[256];
|
|
unsigned result;
|
|
|
|
if (NULL == dir)
|
|
{
|
|
#if LANG_ENG
|
|
printf(" cd <directory>\n\r");
|
|
#elif LANG_RUS
|
|
printf(" cd <äèðåêòîðèÿ>\n\r");
|
|
#endif
|
|
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);
|
|
if (cur_dir[strlen(cur_dir)-1] != '/')
|
|
strcat(temp, "/");
|
|
strcat(temp, dir);
|
|
|
|
if ( dir_check(temp) )
|
|
{
|
|
|
|
strcpy(cur_dir, temp);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
}
|