Author: jmorlan
Date: Mon Dec 22 17:50:53 2008
New Revision: 38289
URL:
http://svn.reactos.org/svn/reactos?rev=38289&view=rev
Log:
- cmd_mkdir: Give an error message if the directory already exists (Bug 3961)
- Also, allow multiple directories to be created by one invocation
Modified:
trunk/reactos/base/shell/cmd/internal.c
Modified: trunk/reactos/base/shell/cmd/internal.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/internal.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] Mon Dec 22 17:50:53 2008
@@ -431,6 +431,12 @@
TCHAR *p = DirPath;
INT n;
+ if (CreateDirectory(DirPath, NULL))
+ return TRUE;
+ else if (GetLastError() != ERROR_PATH_NOT_FOUND)
+ return FALSE;
+
+ /* got ERROR_PATH_NOT_FOUND, so try building it up one component at a time */
if (p[0] && p[1] == _T(':'))
p += 2;
while (*p == _T('\\'))
@@ -445,8 +451,6 @@
(GetLastError() != ERROR_ALREADY_EXISTS))
return FALSE;
} while (p != NULL);
- if (GetLastError() == ERROR_ALREADY_EXISTS)
- SetLastError(ERROR_SUCCESS);
return TRUE;
}
@@ -457,55 +461,42 @@
*/
INT cmd_mkdir (LPTSTR param)
{
- LPTSTR dir; /* pointer to the directory to change to */
- LPTSTR *p = NULL;
- INT argc;
- nErrorLevel = 0;
+ LPTSTR *p;
+ INT argc, i;
if (!_tcsncmp (param, _T("/?"), 2))
{
ConOutResPaging(TRUE,STRING_MKDIR_HELP);
return 0;
}
-
- p = split (param, &argc, FALSE);
- if (argc > 1)
- {
- /*JPP 20-Jul-1998 use standard error message */
- error_too_many_parameters (param);
- freep (p);
- return 1;
- }
- else
- dir = p[0];
-
- if (!dir)
- {
- ConErrResPuts (STRING_ERROR_REQ_PARAM_MISSING);
+ p = split (param, &argc, FALSE);
+ if (argc == 0)
+ {
+ ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING);
nErrorLevel = 1;
- if(p != NULL)
- freep (p);
+ freep(p);
return 1;
}
- if (!MakeFullPath(dir))
- {
- if(GetLastError() == ERROR_PATH_NOT_FOUND)
- {
- ConErrResPuts(STRING_MD_ERROR2);
- }
- else
- {
- ErrorMessage (GetLastError(), _T("MD"));
- }
- nErrorLevel = 1;
- freep (p);
- return 1;
- }
+ nErrorLevel = 0;
+ for (i = 0; i < argc; i++)
+ {
+ if (!MakeFullPath(p[i]))
+ {
+ if(GetLastError() == ERROR_PATH_NOT_FOUND)
+ {
+ ConErrResPuts(STRING_MD_ERROR2);
+ }
+ else
+ {
+ ErrorMessage (GetLastError(), _T("MD"));
+ }
+ nErrorLevel = 1;
+ }
+ }
freep (p);
-
- return 0;
+ return nErrorLevel;
}
#endif