mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
/D /Z are implement in ros cmd copy by BrandonTurner but reactos CopyFile and CopyFileEx does not support it yet, for /D are COPY_FILE_ALLOW_DECRYPTED_DESTNATION for decypt the file when it copy to dest and /Z are COPY_FILE_RESTARTABLE for network. so it is working in windows
svn path=/trunk/; revision=16601
This commit is contained in:
parent
0f1a1d9269
commit
14733418a7
1 changed files with 65 additions and 6 deletions
|
@ -35,19 +35,19 @@
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COPY_ASCII = 0x001, /* /A */
|
COPY_ASCII = 0x001, /* /A */
|
||||||
COPY_DECRYPT = 0x004, /* /D : Not Impleneted */
|
COPY_DECRYPT = 0x004, /* /D */
|
||||||
COPY_VERIFY = 0x008, /* /V : Dummy, Never will be Impleneted */
|
COPY_VERIFY = 0x008, /* /V : Dummy, Never will be Impleneted */
|
||||||
COPY_SHORTNAME = 0x010, /* /N : Not Impleneted */
|
COPY_SHORTNAME = 0x010, /* /N : Not Impleneted */
|
||||||
COPY_NO_PROMPT = 0x020, /* /Y */
|
COPY_NO_PROMPT = 0x020, /* /Y */
|
||||||
COPY_PROMPT = 0x040, /* /-Y */
|
COPY_PROMPT = 0x040, /* /-Y */
|
||||||
COPY_RESTART = 0x080, /* /Z : Not Impleneted */
|
COPY_RESTART = 0x080, /* /Z */
|
||||||
COPY_BINARY = 0x100, /* /B */
|
COPY_BINARY = 0x100, /* /B */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BUFF_SIZE 16384 /* 16k = max buffer size */
|
#define BUFF_SIZE 16384 /* 16k = max buffer size */
|
||||||
|
|
||||||
|
|
||||||
int copy (LPTSTR source, LPTSTR dest, int append, DWORD lpdwFlags)
|
int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], int append, DWORD lpdwFlags)
|
||||||
{
|
{
|
||||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||||
FILETIME srctime;
|
FILETIME srctime;
|
||||||
|
@ -59,6 +59,9 @@ int copy (LPTSTR source, LPTSTR dest, int append, DWORD lpdwFlags)
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
DWORD i;
|
DWORD i;
|
||||||
BOOL bEof = FALSE;
|
BOOL bEof = FALSE;
|
||||||
|
TCHAR TrueDest[MAX_PATH];
|
||||||
|
TCHAR TempSrc[MAX_PATH];
|
||||||
|
TCHAR * FileName;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("checking mode\n"));
|
DebugPrintf (_T("checking mode\n"));
|
||||||
|
@ -84,9 +87,46 @@ int copy (LPTSTR source, LPTSTR dest, int append, DWORD lpdwFlags)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("copy: flags has %s\n"),
|
DebugPrintf (_T("copy: flags has %s\n"),
|
||||||
*lpdwFlags & ASCII ? "ASCII" : "BINARY");
|
*lpdwFlags & COPY_ASCII ? "ASCII" : "BINARY");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Check to see if /D or /Z are true, if so we need a middle
|
||||||
|
man to copy the file too to allow us to use CopyFileEx later */
|
||||||
|
if(lpdwFlags & COPY_DECRYPT)
|
||||||
|
{
|
||||||
|
GetEnvironmentVariable(_T("TEMP"),TempSrc,MAX_PATH);
|
||||||
|
_tcscat(TempSrc,_T("\\"));
|
||||||
|
FileName = _tcsrchr(source,_T('\\'));
|
||||||
|
FileName++;
|
||||||
|
_tcscat(TempSrc,FileName);
|
||||||
|
/* This is needed to be on the end to prevent an error
|
||||||
|
if the user did "copy /D /Z foo bar then it would be copied
|
||||||
|
too %TEMP%\foo here and when %TEMP%\foo when it sets it up
|
||||||
|
for COPY_RESTART, this would mean it is copying to itself
|
||||||
|
which would error when it tried to open the handles for ReadFile
|
||||||
|
and WriteFile */
|
||||||
|
_tcscat(TempSrc,_T(".decrypt"));
|
||||||
|
if(!CopyFileEx(source, TempSrc, NULL, NULL, FALSE, COPY_FILE_ALLOW_DECRYPTED_DESTINATION))
|
||||||
|
{
|
||||||
|
nErrorLevel = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_tcscpy(source, TempSrc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(lpdwFlags & COPY_RESTART)
|
||||||
|
{
|
||||||
|
_tcscpy(TrueDest, dest);
|
||||||
|
GetEnvironmentVariable(_T("TEMP"),dest,MAX_PATH);
|
||||||
|
_tcscat(dest,_T("\\"));
|
||||||
|
FileName = _tcsrchr(TrueDest,_T('\\'));
|
||||||
|
FileName++;
|
||||||
|
_tcscat(dest,FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!IsExistingFile (dest))
|
if (!IsExistingFile (dest))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -216,6 +256,25 @@ int copy (LPTSTR source, LPTSTR dest, int append, DWORD lpdwFlags)
|
||||||
#endif
|
#endif
|
||||||
SetFileAttributes (dest, dwAttrib);
|
SetFileAttributes (dest, dwAttrib);
|
||||||
|
|
||||||
|
/* Now finish off the copy if needed with CopyFileEx */
|
||||||
|
if(lpdwFlags & COPY_RESTART)
|
||||||
|
{
|
||||||
|
if(!CopyFileEx(dest, TrueDest, NULL, NULL, FALSE, COPY_FILE_RESTARTABLE))
|
||||||
|
{
|
||||||
|
nErrorLevel = 1;
|
||||||
|
DeleteFile(dest);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Take care of file in the temp folder */
|
||||||
|
DeleteFile(dest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lpdwFlags & COPY_DECRYPT)
|
||||||
|
DeleteFile(TempSrc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue