mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 06:32:56 +00:00
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:
parent
cbf6a79f07
commit
6320253c94
1 changed files with 5 additions and 16 deletions
|
@ -439,16 +439,16 @@ MakeFullPath(TCHAR * DirPath)
|
||||||
p += 2;
|
p += 2;
|
||||||
while (*p == _T('\\'))
|
while (*p == _T('\\'))
|
||||||
p++; /* skip drive root */
|
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);
|
_tcsncpy(path, DirPath, n);
|
||||||
path[n] = _T('\0');
|
path[n] = _T('\0');
|
||||||
if( !CreateDirectory(path, NULL) &&
|
if( !CreateDirectory(path, NULL) &&
|
||||||
(GetLastError() != ERROR_ALREADY_EXISTS))
|
(GetLastError() != ERROR_ALREADY_EXISTS))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
p++;
|
} while (p != NULL);
|
||||||
}
|
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param)
|
||||||
{
|
{
|
||||||
LPTSTR dir; /* pointer to the directory to change to */
|
LPTSTR dir; /* pointer to the directory to change to */
|
||||||
LPTSTR place; /* used to search for the \ when no space is used */
|
LPTSTR place; /* used to search for the \ when no space is used */
|
||||||
LPTSTR new_dir, *p = NULL;
|
LPTSTR *p = NULL;
|
||||||
INT argc;
|
INT argc;
|
||||||
nErrorLevel = 0;
|
nErrorLevel = 0;
|
||||||
if (!_tcsncmp (param, _T("/?"), 2))
|
if (!_tcsncmp (param, _T("/?"), 2))
|
||||||
|
@ -516,17 +516,6 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param)
|
||||||
return 1;
|
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 (!MakeFullPath(dir))
|
||||||
{
|
{
|
||||||
if(GetLastError() == ERROR_PATH_NOT_FOUND)
|
if(GetLastError() == ERROR_PATH_NOT_FOUND)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue