In mkdir, don't add a backslash to the end - it can trick CreateDirectory into creating a dir with the name of a DOS device (even in Windows).

svn path=/trunk/; revision=34810
This commit is contained in:
Jeffrey Morlan 2008-07-26 17:15:37 +00:00
parent cbf6a79f07
commit 6320253c94

View file

@ -439,16 +439,16 @@ MakeFullPath(TCHAR * DirPath)
p += 2;
while (*p == _T('\\'))
p++; /* skip drive root */
while ((p = _tcschr(p, _T('\\'))) != NULL)
do
{
n = p - DirPath + 1;
p = _tcschr(p, _T('\\'));
n = p ? p++ - DirPath : _tcslen(DirPath);
_tcsncpy(path, DirPath, n);
path[n] = _T('\0');
if( !CreateDirectory(path, NULL) &&
(GetLastError() != ERROR_ALREADY_EXISTS))
return FALSE;
p++;
}
} while (p != NULL);
if (GetLastError() == ERROR_ALREADY_EXISTS)
SetLastError(ERROR_SUCCESS);
@ -463,7 +463,7 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param)
{
LPTSTR dir; /* pointer to the directory to change to */
LPTSTR place; /* used to search for the \ when no space is used */
LPTSTR new_dir, *p = NULL;
LPTSTR *p = NULL;
INT argc;
nErrorLevel = 0;
if (!_tcsncmp (param, _T("/?"), 2))
@ -516,17 +516,6 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param)
return 1;
}
/* Add a \ at the end of the path is there isnt on already */
if (dir[_tcslen (dir) - 1] != _T('\\'))
{
new_dir = cmd_realloc(dir, (_tcslen (dir) + 2) * sizeof(TCHAR));
if (new_dir != NULL)
{
p[0] = dir = new_dir;
_tcscat(dir,_T("\\"));
}
}
if (!MakeFullPath(dir))
{
if(GetLastError() == ERROR_PATH_NOT_FOUND)