From 81ff664e0cc15f152f41efc9b0e0bfa7bf56b231 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 13 Aug 2006 19:12:53 +0000 Subject: [PATCH] Dmitry Philippov: Add more tests for delayed file operations svn path=/trunk/; revision=23569 --- .../testsets/smss/movefile/movefile.cpp | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/reactos/base/applications/testsets/smss/movefile/movefile.cpp b/reactos/base/applications/testsets/smss/movefile/movefile.cpp index 89c446d0fe4..c3f6d4f303e 100644 --- a/reactos/base/applications/testsets/smss/movefile/movefile.cpp +++ b/reactos/base/applications/testsets/smss/movefile/movefile.cpp @@ -83,10 +83,12 @@ int Generate() char sBuf[255]; DWORD dwSize; HANDLE hFile = NULL; + BOOL fReturnValue; + char *szxReplacedFile = "c:\\testFileIsReplaced"; + char *szxMovedFileWithRepl = "c:\\testFileShouldBeMovedW"; char *szxMovedFile = "c:\\testFileShouldBeMoved"; char *szxNewMovedFile = "c:\\testFileIsMoved"; - char *szxDeletedFile = "c:\\testFileShouldBeDeleted"; memset(sBuf, 0xaa, sizeof(sBuf)); @@ -123,15 +125,44 @@ int Generate() WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL); CloseHandle(hFile); + hFile = CreateFile( + szxReplacedFile, + FILE_ALL_ACCESS, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(NULL == hFile) { + printf("Can't create the %s file, err=%ld \n", szxReplacedFile, GetLastError()); + return 1; + } + WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL); + CloseHandle(hFile); + + + hFile = CreateFile( + szxMovedFileWithRepl, + FILE_ALL_ACCESS, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(NULL == hFile) { + printf("Can't create the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError()); + return 1; + } + WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL); + CloseHandle(hFile); - BOOL fReturnValue; fReturnValue = MoveFileEx( szxDeletedFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT); if( !fReturnValue ) { - printf("Can't move the %s file, err=%ld \n", szxMovedFile, GetLastError()); + printf("Can't move the %s file, err=%ld \n", szxDeletedFile, GetLastError()); return 1; } @@ -148,6 +179,17 @@ int Generate() ShowRegValue(); + fReturnValue = MoveFileEx( + szxMovedFileWithRepl, + szxReplacedFile, + MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING); + if( !fReturnValue ) { + printf("Can't move the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError()); + return 1; + } + + ShowRegValue(); + return 0; }