6 #include <winpr/crypto.h>
7 #include <winpr/file.h>
8 #include <winpr/path.h>
10 static UINT32 prand(UINT32 max)
15 winpr_RAND(&tmp,
sizeof(tmp));
16 return tmp % (max - 1) + 1;
19 int TestPathMakePath(
int argc,
char* argv[])
26 char delim = PathGetSeparatorA(0);
27 char* base = GetKnownPath(KNOWN_PATH_TEMP);
34 (void)fprintf(stderr,
"Failed to get temporary directory!\n");
38 baseLen = strlen(base);
40 for (
int x = 0; x < 5; x++)
42 (void)sprintf_s(tmp, ARRAYSIZE(tmp),
"%08" PRIX32, prand(UINT32_MAX));
43 path = GetCombinedPath(base, tmp);
48 (void)fprintf(stderr,
"GetCombinedPath failed!\n");
55 printf(
"Creating path %s\n", path);
56 success = winpr_PathMakePath(path, NULL);
60 (void)fprintf(stderr,
"MakePath failed!\n");
65 success = winpr_PathFileExists(path);
69 (void)fprintf(stderr,
"MakePath lied about success!\n");
74 while (strlen(path) > baseLen)
76 if (!winpr_RemoveDirectory(path))
78 (void)fprintf(stderr,
"winpr_RemoveDirectory %s failed!\n", path);
83 cur = strrchr(path, delim);
90 printf(
"%s success!\n", __func__);