diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:24:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:24:41 +0000 |
commit | a9bcc81f821d7c66f623779fa5147e728eb3c388 (patch) | |
tree | 98676963bcdd537ae5908a067a8eb110b93486a6 /winpr/libwinpr/file/test/TestFileDeleteFile.c | |
parent | Initial commit. (diff) | |
download | freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip |
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'winpr/libwinpr/file/test/TestFileDeleteFile.c')
-rw-r--r-- | winpr/libwinpr/file/test/TestFileDeleteFile.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/winpr/libwinpr/file/test/TestFileDeleteFile.c b/winpr/libwinpr/file/test/TestFileDeleteFile.c new file mode 100644 index 0000000..81f0599 --- /dev/null +++ b/winpr/libwinpr/file/test/TestFileDeleteFile.c @@ -0,0 +1,50 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <winpr/crt.h> +#include <winpr/file.h> +#include <winpr/windows.h> + +int TestFileDeleteFile(int argc, char* argv[]) +{ + BOOL rc = FALSE; + int fd = 0; + char validA[] = "/tmp/valid-test-file-XXXXXX"; + char validW[] = "/tmp/valid-test-file-XXXXXX"; + WCHAR* validWW = NULL; + const char invalidA[] = "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + WCHAR invalidW[sizeof(invalidA)] = { 0 }; + + ConvertUtf8NToWChar(invalidA, ARRAYSIZE(invalidA), invalidW, ARRAYSIZE(invalidW)); + + WINPR_UNUSED(argc); + WINPR_UNUSED(argv); + + rc = DeleteFileA(invalidA); + if (rc) + return -1; + + rc = DeleteFileW(invalidW); + if (rc) + return -1; + + fd = mkstemp(validA); + if (fd < 0) + return -1; + + rc = DeleteFileA(validA); + if (!rc) + return -1; + + fd = mkstemp(validW); + if (fd < 0) + return -1; + + validWW = ConvertUtf8NToWCharAlloc(validW, ARRAYSIZE(validW), NULL); + if (validWW) + rc = DeleteFileW(validWW); + free(validWW); + if (!rc) + return -1; + return 0; +} |