mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fix copy command
svn path=/trunk/; revision=12710
This commit is contained in:
parent
2ee2dcfd7e
commit
38c0b28279
6 changed files with 31 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cmd.c,v 1.20 2004/11/08 02:16:06 weiden Exp $
|
/* $Id$
|
||||||
*
|
*
|
||||||
* CMD.C - command-line interface.
|
* CMD.C - command-line interface.
|
||||||
*
|
*
|
||||||
|
@ -1151,7 +1151,7 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
{
|
{
|
||||||
if (!_tcsicmp (argv[i], _T("/p")))
|
if (!_tcsicmp (argv[i], _T("/p")))
|
||||||
{
|
{
|
||||||
if (!IsValidFileName (_T("\\autoexec.bat")))
|
if (!IsExistingFile (_T("\\autoexec.bat")))
|
||||||
{
|
{
|
||||||
#ifdef INCLUDE_CMD_DATE
|
#ifdef INCLUDE_CMD_DATE
|
||||||
cmd_date (_T(""), _T(""));
|
cmd_date (_T(""), _T(""));
|
||||||
|
@ -1216,11 +1216,11 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run cmdstart.bat */
|
/* run cmdstart.bat */
|
||||||
if (IsValidFileName (_T("cmdstart.bat")))
|
if (IsExistingFile (_T("cmdstart.bat")))
|
||||||
{
|
{
|
||||||
ParseCommandLine (_T("cmdstart.bat"));
|
ParseCommandLine (_T("cmdstart.bat"));
|
||||||
}
|
}
|
||||||
else if (IsValidFileName (_T("\\cmdstart.bat")))
|
else if (IsExistingFile (_T("\\cmdstart.bat")))
|
||||||
{
|
{
|
||||||
ParseCommandLine (_T("\\cmdstart.bat"));
|
ParseCommandLine (_T("\\cmdstart.bat"));
|
||||||
}
|
}
|
||||||
|
@ -1234,7 +1234,7 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
p = _tcsrchr (commandline, _T('\\')) + 1;
|
p = _tcsrchr (commandline, _T('\\')) + 1;
|
||||||
_tcscpy (p, _T("cmdstart.bat"));
|
_tcscpy (p, _T("cmdstart.bat"));
|
||||||
|
|
||||||
if (IsValidFileName (_T("commandline")))
|
if (IsExistingFile (_T("commandline")))
|
||||||
{
|
{
|
||||||
ConErrPrintf (_T("Running %s...\n", commandline));
|
ConErrPrintf (_T("Running %s...\n", commandline));
|
||||||
ParseCommandLine (commandline);
|
ParseCommandLine (commandline);
|
||||||
|
@ -1268,12 +1268,12 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
static VOID Cleanup (int argc, TCHAR *argv[])
|
static VOID Cleanup (int argc, TCHAR *argv[])
|
||||||
{
|
{
|
||||||
/* run cmdexit.bat */
|
/* run cmdexit.bat */
|
||||||
if (IsValidFileName (_T("cmdexit.bat")))
|
if (IsExistingFile (_T("cmdexit.bat")))
|
||||||
{
|
{
|
||||||
ConErrPrintf (_T("Running cmdexit.bat...\n"));
|
ConErrPrintf (_T("Running cmdexit.bat...\n"));
|
||||||
ParseCommandLine (_T("cmdexit.bat"));
|
ParseCommandLine (_T("cmdexit.bat"));
|
||||||
}
|
}
|
||||||
else if (IsValidFileName (_T("\\cmdexit.bat")))
|
else if (IsExistingFile (_T("\\cmdexit.bat")))
|
||||||
{
|
{
|
||||||
ConErrPrintf (_T("Running \\cmdexit.bat...\n"));
|
ConErrPrintf (_T("Running \\cmdexit.bat...\n"));
|
||||||
ParseCommandLine (_T("\\cmdexit.bat"));
|
ParseCommandLine (_T("\\cmdexit.bat"));
|
||||||
|
@ -1289,7 +1289,7 @@ static VOID Cleanup (int argc, TCHAR *argv[])
|
||||||
p = _tcsrchr (commandline, _T('\\')) + 1;
|
p = _tcsrchr (commandline, _T('\\')) + 1;
|
||||||
_tcscpy (p, _T("cmdexit.bat"));
|
_tcscpy (p, _T("cmdexit.bat"));
|
||||||
|
|
||||||
if (IsValidFileName (_T("commandline")))
|
if (IsExistingFile (_T("commandline")))
|
||||||
{
|
{
|
||||||
ConErrPrintf (_T("Running %s...\n"), commandline);
|
ConErrPrintf (_T("Running %s...\n"), commandline);
|
||||||
ParseCommandLine (commandline);
|
ParseCommandLine (commandline);
|
||||||
|
|
|
@ -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
|
* CMD.H - header file for the modules in CMD.EXE
|
||||||
*
|
*
|
||||||
|
@ -309,8 +309,8 @@ LPTSTR *split (LPTSTR, LPINT, BOOL);
|
||||||
VOID freep (LPTSTR *);
|
VOID freep (LPTSTR *);
|
||||||
LPTSTR _stpcpy (LPTSTR, LPTSTR);
|
LPTSTR _stpcpy (LPTSTR, LPTSTR);
|
||||||
BOOL IsValidPathName (LPCTSTR);
|
BOOL IsValidPathName (LPCTSTR);
|
||||||
BOOL IsValidFileName (LPCTSTR);
|
BOOL IsExistingFile (LPCTSTR);
|
||||||
BOOL IsValidDirectory (LPCTSTR);
|
BOOL IsExistingDirectory (LPCTSTR);
|
||||||
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||||
#ifndef __REACTOS__
|
#ifndef __REACTOS__
|
||||||
HWND GetConsoleWindow(VOID);
|
HWND GetConsoleWindow(VOID);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: copy.c,v 1.6 2004/11/08 02:16:06 weiden Exp $
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPY.C -- copy internal command.
|
* COPY.C -- copy internal command.
|
||||||
*
|
*
|
||||||
|
@ -53,16 +53,6 @@ static VOID DeleteFileList (LPFILES);
|
||||||
static INT Overwrite (LPTSTR);
|
static INT Overwrite (LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
|
||||||
IsDirectory (LPTSTR fn)
|
|
||||||
{
|
|
||||||
if (!IsValidFileName (fn))
|
|
||||||
return FALSE;
|
|
||||||
return (GetFileAttributes (fn) & FILE_ATTRIBUTE_DIRECTORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
||||||
{
|
{
|
||||||
|
@ -362,7 +352,7 @@ int copy (LPTSTR source, LPTSTR dest, int append, LPDWORD lpdwFlags)
|
||||||
*lpdwFlags & ASCII ? "ASCII" : "BINARY");
|
*lpdwFlags & ASCII ? "ASCII" : "BINARY");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!IsValidFileName (dest))
|
if (!IsExistingFile (dest))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("opening/creating\n"));
|
DebugPrintf (_T("opening/creating\n"));
|
||||||
|
@ -529,8 +519,12 @@ SetupCopy (LPFILES sources, TCHAR **p, BOOL bMultiple,
|
||||||
/* Force a clean full path
|
/* Force a clean full path
|
||||||
*/
|
*/
|
||||||
GetFullPathName( sources->szFile, 128, (LPTSTR) &temp, NULL);
|
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);
|
hFind = FindFirstFile ((TCHAR*)&temp, &find);
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
|
@ -554,7 +548,7 @@ SetupCopy (LPFILES sources, TCHAR **p, BOOL bMultiple,
|
||||||
|
|
||||||
// printf("Merge %s, filename %s\n", from_merge, find.cFileName);
|
// printf("Merge %s, filename %s\n", from_merge, find.cFileName);
|
||||||
|
|
||||||
if (IsDirectory (from_merge))
|
if (IsExistingDirectory (from_merge))
|
||||||
{
|
{
|
||||||
|
|
||||||
// printf("Merge DIR\n");
|
// printf("Merge DIR\n");
|
||||||
|
@ -576,7 +570,7 @@ SetupCopy (LPFILES sources, TCHAR **p, BOOL bMultiple,
|
||||||
sources->dwFlag & ASCII ? _T(", ASCII") : _T(", BINARY"));
|
sources->dwFlag & ASCII ? _T(", ASCII") : _T(", BINARY"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (IsValidFileName (real_dest) && !bAll)
|
if (IsExistingFile (real_dest) && !bAll)
|
||||||
{
|
{
|
||||||
/* Don't prompt in a batch file */
|
/* Don't prompt in a batch file */
|
||||||
if (bc != NULL)
|
if (bc != NULL)
|
||||||
|
@ -696,7 +690,7 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
||||||
if (bDestFound)
|
if (bDestFound)
|
||||||
{
|
{
|
||||||
_tsplitpath (dest.szFile, drive_d, dir_d, file_d, ext_d);
|
_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);
|
// printf("A szFile= %s, Dir = %s, File = %s, Ext = %s\n", dest.szFile, dir_d, file_d, ext_d);
|
||||||
_tcscat (dir_d, file_d);
|
_tcscat (dir_d, file_d);
|
||||||
|
@ -736,7 +730,7 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
||||||
else if (!bDestFound && !bMultiple)
|
else if (!bDestFound && !bMultiple)
|
||||||
{
|
{
|
||||||
_tsplitpath (sources->szFile, drive_d, dir_d, file_d, ext_d);
|
_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);
|
// printf("B File = %s, Ext = %s\n", file_d, ext_d);
|
||||||
|
|
||||||
|
@ -750,7 +744,7 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tsplitpath(sources->szFile, drive_d, dir_d, file_d, ext_d);
|
_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);
|
// printf("C File = %s, Ext = %s\n", file_d, ext_d);
|
||||||
|
|
||||||
|
|
|
@ -348,16 +348,17 @@ BOOL IsValidPathName (LPCTSTR pszPath)
|
||||||
* Checks if a file exists (accessible)
|
* Checks if a file exists (accessible)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL IsValidFileName (LPCTSTR pszPath)
|
BOOL IsExistingFile (LPCTSTR pszPath)
|
||||||
{
|
{
|
||||||
DWORD attr = GetFileAttributes (pszPath);
|
DWORD attr = GetFileAttributes (pszPath);
|
||||||
return (attr != 0xFFFFFFFF && (! (attr & FILE_ATTRIBUTE_DIRECTORY)) );
|
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) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
|
||||||
{
|
{
|
||||||
/* source is file */
|
/* source is file */
|
||||||
|
|
||||||
if (IsValidFileName (szDestPath))
|
if (IsExistingFile (szDestPath))
|
||||||
{
|
{
|
||||||
/* destination exists */
|
/* destination exists */
|
||||||
if (GetFileAttributes (szDestPath) & FILE_ATTRIBUTE_DIRECTORY)
|
if (GetFileAttributes (szDestPath) & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
|
|
@ -117,7 +117,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
if (pExtension)
|
if (pExtension)
|
||||||
_tcscat(szPathBuffer, pExtension);
|
_tcscat(szPathBuffer, pExtension);
|
||||||
|
|
||||||
if (IsValidFileName (szPathBuffer))
|
if (IsExistingFile (szPathBuffer))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
|
@ -140,7 +140,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
if (pExtension)
|
if (pExtension)
|
||||||
_tcscat (szPathBuffer, pExtension);
|
_tcscat (szPathBuffer, pExtension);
|
||||||
|
|
||||||
if (IsValidFileName (szPathBuffer))
|
if (IsExistingFile (szPathBuffer))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
|
@ -190,7 +190,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
if (pExtension)
|
if (pExtension)
|
||||||
_tcscat (szPathBuffer, pExtension);
|
_tcscat (szPathBuffer, pExtension);
|
||||||
|
|
||||||
if (IsValidFileName (szPathBuffer))
|
if (IsExistingFile (szPathBuffer))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
|
|
Loading…
Reference in a new issue