Fix copy command
Modified: trunk/reactos/subsys/system/cmd/cmd.c
Modified: trunk/reactos/subsys/system/cmd/cmd.h
Modified: trunk/reactos/subsys/system/cmd/copy.c
Modified: trunk/reactos/subsys/system/cmd/misc.c
Modified: trunk/reactos/subsys/system/cmd/move.c
Modified: trunk/reactos/subsys/system/cmd/where.c
_____
Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c 2005-01-01 22:10:23 UTC
(rev 12709)
+++ trunk/reactos/subsys/system/cmd/cmd.c 2005-01-01 22:53:21 UTC
(rev 12710)
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.20 2004/11/08 02:16:06 weiden Exp $
+/* $Id$
*
* CMD.C - command-line interface.
*
@@ -1151,7 +1151,7 @@
{
if (!_tcsicmp (argv[i], _T("/p")))
{
- if (!IsValidFileName
(_T("\\autoexec.bat")))
+ if (!IsExistingFile
(_T("\\autoexec.bat")))
{
#ifdef INCLUDE_CMD_DATE
cmd_date (_T(""), _T(""));
@@ -1216,11 +1216,11 @@
}
/* run cmdstart.bat */
- if (IsValidFileName (_T("cmdstart.bat")))
+ if (IsExistingFile (_T("cmdstart.bat")))
{
ParseCommandLine (_T("cmdstart.bat"));
}
- else if (IsValidFileName (_T("\\cmdstart.bat")))
+ else if (IsExistingFile (_T("\\cmdstart.bat")))
{
ParseCommandLine (_T("\\cmdstart.bat"));
}
@@ -1234,7 +1234,7 @@
p = _tcsrchr (commandline, _T('\\')) + 1;
_tcscpy (p, _T("cmdstart.bat"));
- if (IsValidFileName (_T("commandline")))
+ if (IsExistingFile (_T("commandline")))
{
ConErrPrintf (_T("Running %s...\n",
commandline));
ParseCommandLine (commandline);
@@ -1268,12 +1268,12 @@
static VOID Cleanup (int argc, TCHAR *argv[])
{
/* run cmdexit.bat */
- if (IsValidFileName (_T("cmdexit.bat")))
+ if (IsExistingFile (_T("cmdexit.bat")))
{
ConErrPrintf (_T("Running cmdexit.bat...\n"));
ParseCommandLine (_T("cmdexit.bat"));
}
- else if (IsValidFileName (_T("\\cmdexit.bat")))
+ else if (IsExistingFile (_T("\\cmdexit.bat")))
{
ConErrPrintf (_T("Running \\cmdexit.bat...\n"));
ParseCommandLine (_T("\\cmdexit.bat"));
@@ -1289,7 +1289,7 @@
p = _tcsrchr (commandline, _T('\\')) + 1;
_tcscpy (p, _T("cmdexit.bat"));
- if (IsValidFileName (_T("commandline")))
+ if (IsExistingFile (_T("commandline")))
{
ConErrPrintf (_T("Running %s...\n"),
commandline);
ParseCommandLine (commandline);
_____
Modified: trunk/reactos/subsys/system/cmd/cmd.h
--- trunk/reactos/subsys/system/cmd/cmd.h 2005-01-01 22:10:23 UTC
(rev 12709)
+++ trunk/reactos/subsys/system/cmd/cmd.h 2005-01-01 22:53:21 UTC
(rev 12710)
@@ -1,4 +1,4 @@
-/* $Id: cmd.h,v 1.5 2004/06/21 18:57:22 weiden Exp $
+/* $Id$
*
* CMD.H - header file for the modules in CMD.EXE
*
@@ -309,8 +309,8 @@
VOID freep (LPTSTR *);
LPTSTR _stpcpy (LPTSTR, LPTSTR);
BOOL IsValidPathName (LPCTSTR);
-BOOL IsValidFileName (LPCTSTR);
-BOOL IsValidDirectory (LPCTSTR);
+BOOL IsExistingFile (LPCTSTR);
+BOOL IsExistingDirectory (LPCTSTR);
BOOL FileGetString (HANDLE, LPTSTR, INT);
#ifndef __REACTOS__
HWND GetConsoleWindow(VOID);
_____
Modified: trunk/reactos/subsys/system/cmd/copy.c
--- trunk/reactos/subsys/system/cmd/copy.c 2005-01-01 22:10:23 UTC
(rev 12709)
+++ trunk/reactos/subsys/system/cmd/copy.c 2005-01-01 22:53:21 UTC
(rev 12710)
@@ -1,4 +1,4 @@
-/* $Id: copy.c,v 1.6 2004/11/08 02:16:06 weiden Exp $
+/* $Id$
*
* COPY.C -- copy internal command.
*
@@ -53,17 +53,7 @@
static INT Overwrite (LPTSTR);
-
static BOOL
-IsDirectory (LPTSTR fn)
-{
- if (!IsValidFileName (fn))
- return FALSE;
- return (GetFileAttributes (fn) & FILE_ATTRIBUTE_DIRECTORY);
-}
-
-
-static BOOL
DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
{
if (!_tcsicmp (arg, _T("/-Y")))
@@ -362,7 +352,7 @@
*lpdwFlags & ASCII ? "ASCII" :
"BINARY");
#endif
- if (!IsValidFileName (dest))
+ if (!IsExistingFile (dest))
{
#ifdef _DEBUG
DebugPrintf (_T("opening/creating\n"));
@@ -529,8 +519,12 @@
/* Force a clean full path
*/
GetFullPathName( sources->szFile, 128, (LPTSTR) &temp,
NULL);
+ if (IsExistingDirectory(temp))
+ {
+ _tcscat(temp, _T("\\*"));
+ }
- _tsplitpath (sources->szFile, drive_s, dir_s, file_s,
ext_s);
+ _tsplitpath (temp, drive_s, dir_s, file_s, ext_s);
hFind = FindFirstFile ((TCHAR*)&temp, &find);
if (hFind == INVALID_HANDLE_VALUE)
@@ -554,7 +548,7 @@
// printf("Merge %s, filename %s\n", from_merge,
find.cFileName);
- if (IsDirectory (from_merge))
+ if (IsExistingDirectory (from_merge))
{
// printf("Merge DIR\n");
@@ -576,7 +570,7 @@
sources->dwFlag & ASCII
? _T(", ASCII") : _T(", BINARY"));
#endif
- if (IsValidFileName (real_dest) && !bAll)
+ if (IsExistingFile (real_dest) && !bAll)
{
/* Don't prompt in a batch file */
if (bc != NULL)
@@ -696,7 +690,7 @@
if (bDestFound)
{
_tsplitpath (dest.szFile, drive_d, dir_d, file_d,
ext_d);
- if (IsDirectory (dest.szFile))
+ if (IsExistingDirectory (dest.szFile))
{
// printf("A szFile= %s, Dir = %s, File = %s, Ext = %s\n",
dest.szFile, dir_d, file_d, ext_d);
_tcscat (dir_d, file_d);
@@ -736,7 +730,7 @@
else if (!bDestFound && !bMultiple)
{
_tsplitpath (sources->szFile, drive_d, dir_d, file_d,
ext_d);
- if (IsDirectory (sources->szFile))
+ if (IsExistingDirectory (sources->szFile))
{
// printf("B File = %s, Ext = %s\n", file_d, ext_d);
@@ -750,7 +744,7 @@
else
{
_tsplitpath(sources->szFile, drive_d, dir_d, file_d,
ext_d);
- if (IsDirectory (sources->szFile))
+ if (IsExistingDirectory (sources->szFile))
{
// printf("C File = %s, Ext = %s\n", file_d, ext_d);
_____
Modified: trunk/reactos/subsys/system/cmd/misc.c
--- trunk/reactos/subsys/system/cmd/misc.c 2005-01-01 22:10:23 UTC
(rev 12709)
+++ trunk/reactos/subsys/system/cmd/misc.c 2005-01-01 22:53:21 UTC
(rev 12710)
@@ -348,16 +348,17 @@
* Checks if a file exists (accessible)
*/
-BOOL IsValidFileName (LPCTSTR pszPath)
+BOOL IsExistingFile (LPCTSTR pszPath)
{
DWORD attr = GetFileAttributes (pszPath);
return (attr != 0xFFFFFFFF && (! (attr &
FILE_ATTRIBUTE_DIRECTORY)) );
}
-BOOL IsValidDirectory (LPCTSTR pszPath)
+BOOL IsExistingDirectory (LPCTSTR pszPath)
{
- return (GetFileAttributes (pszPath) & FILE_ATTRIBUTE_DIRECTORY);
+ DWORD attr = GetFileAttributes (pszPath);
+ return (attr != 0xFFFFFFFF && (attr & FILE_ATTRIBUTE_DIRECTORY)
);
}
_____
Modified: trunk/reactos/subsys/system/cmd/move.c
--- trunk/reactos/subsys/system/cmd/move.c 2005-01-01 22:10:23 UTC
(rev 12709)
+++ trunk/reactos/subsys/system/cmd/move.c 2005-01-01 22:53:21 UTC
(rev 12710)
@@ -179,7 +179,7 @@
{
/* source is file */
- if (IsValidFileName (szDestPath))
+ if (IsExistingFile (szDestPath))
{
/* destination exists */
if (GetFileAttributes
(szDestPath) & FILE_ATTRIBUTE_DIRECTORY)
_____
Modified: trunk/reactos/subsys/system/cmd/where.c
--- trunk/reactos/subsys/system/cmd/where.c 2005-01-01 22:10:23 UTC
(rev 12709)
+++ trunk/reactos/subsys/system/cmd/where.c 2005-01-01 22:53:21 UTC
(rev 12710)
@@ -117,7 +117,7 @@
if (pExtension)
_tcscat(szPathBuffer, pExtension);
- if (IsValidFileName (szPathBuffer))
+ if (IsExistingFile (szPathBuffer))
{
#ifdef _DEBUG
DebugPrintf (_T("Found: \'%s\'\n"),
szPathBuffer);
@@ -140,7 +140,7 @@
if (pExtension)
_tcscat (szPathBuffer, pExtension);
- if (IsValidFileName (szPathBuffer))
+ if (IsExistingFile (szPathBuffer))
{
#ifdef _DEBUG
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
@@ -190,7 +190,7 @@
if (pExtension)
_tcscat (szPathBuffer, pExtension);
- if (IsValidFileName (szPathBuffer))
+ if (IsExistingFile (szPathBuffer))
{
#ifdef _DEBUG
DebugPrintf (_T("Found: \'%s\'\n"),
szPathBuffer);