Check to see if a folder or file is already there when makign a folder. Set correct...
authorBrandon Turner <turnerb7@msu.edu>
Tue, 4 Oct 2005 14:56:38 +0000 (14:56 +0000)
committerBrandon Turner <turnerb7@msu.edu>
Tue, 4 Oct 2005 14:56:38 +0000 (14:56 +0000)
svn path=/trunk/; revision=18266

reactos/subsys/system/cmd/En.rc
reactos/subsys/system/cmd/internal.c
reactos/subsys/system/cmd/resource.h

index bf8b1c7..d95cb26 100644 (file)
@@ -571,6 +571,7 @@ STRING_CHCP_ERROR4,          "Invalid code page\n"
 STRING_CHOICE_ERROR,         "Invalid option. Expected format: /C[:]options"
 STRING_CHOICE_ERROR_TXT,     "Invalid option. Expected format: /T[:]c,nn"
 STRING_CHOICE_ERROR_OPTION,  "Illegal Option: %s"
+STRING_MD_ERROR,                        "A subdirectory or file ass already exists.\n"
 STRING_CMD_ERROR1,           "Can't redirect input from file %s\n"
 STRING_CMD_ERROR2,           "Error creating temporary file for pipe data\n"
 STRING_CMD_ERROR3,           "Can't redirect to file %s\n"
index de22c89..ed470f0 100644 (file)
@@ -433,7 +433,7 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param)
        LPTSTR place;   /* used to search for the \ when no space is used */
        LPTSTR *p = NULL;
        INT argc;
-
+       nErrorLevel = 0;
        if (!_tcsncmp (param, _T("/?"), 2))
        {
                ConOutResPaging(TRUE,STRING_MKDIR_HELP);
@@ -479,10 +479,17 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param)
        if (_tcslen (dir) >= 2 && dir[_tcslen (dir) - 1] == _T('\\'))
                dir[_tcslen(dir) - 1] = _T('\0');
 
+       if(IsExistingDirectory(dir) || IsExistingFile(dir))
+       {
+               ConErrResPuts(STRING_MD_ERROR);
+               freep(p);
+               nErrorLevel = 1;
+               return 1;
+       }
        if (!CreateDirectory (dir, NULL))
        {
                ErrorMessage (GetLastError(), _T("MD"));
-
+               nErrorLevel = 1;
                freep (p);
                return 1;
        }
index 9d13e8b..34c4670 100644 (file)
 #define STRING_EXPECTED_NUMBER_OR_VARIABLE 722
 #define STRING_SYNTAX_COMMAND_INCORRECT    723
 #define STRING_RMDIR_HELP2                                724
+#define STRING_MD_ERROR                                           725
 
 
 /* These strings are language independent (cmd.rc) */