Added RemoveDirectoryA, clean up test directories.
This commit is contained in:
parent
7403cdc60c
commit
db7753bc8b
@ -291,6 +291,9 @@ WINPR_API BOOL FindClose(HANDLE hFindFile);
|
||||
WINPR_API BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
WINPR_API BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
WINPR_API BOOL RemoveDirectoryA(LPCSTR lpPathName);
|
||||
WINPR_API BOOL RemoveDirectoryW(LPCWSTR lpPathName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -302,6 +305,7 @@ WINPR_API BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecu
|
||||
#define FindFirstFileEx FindFirstFileExW
|
||||
#define FindNextFile FindNextFileW
|
||||
#define CreateDirectory CreateDirectoryW
|
||||
#define RemoveDirectory RemoveDirectoryW
|
||||
#else
|
||||
#define CreateFile CreateFileA
|
||||
#define DeleteFile DeleteFileA
|
||||
@ -309,6 +313,7 @@ WINPR_API BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecu
|
||||
#define FindFirstFileEx FindFirstFileExA
|
||||
#define FindNextFile FindNextFileA
|
||||
#define CreateDirectory CreateDirectoryA
|
||||
#define RemoveDirectory RemoveDirectoryA
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -788,7 +788,20 @@ BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttribu
|
||||
|
||||
BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL RemoveDirectoryA(LPCSTR lpPathName)
|
||||
{
|
||||
if (!rmdir(lpPathName))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL RemoveDirectoryW(LPCWSTR lpPathName)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3,14 +3,18 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/path.h>
|
||||
|
||||
int TestPathMakePath(int argc, char* argv[])
|
||||
{
|
||||
int x;
|
||||
size_t baseLen;
|
||||
BOOL success;
|
||||
char tmp[64];
|
||||
char* path;
|
||||
char* cur;
|
||||
char delim = PathGetSeparatorA(0);
|
||||
char* base = GetKnownPath(KNOWN_PATH_TEMP);
|
||||
if (!base)
|
||||
{
|
||||
@ -18,6 +22,7 @@ int TestPathMakePath(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
baseLen = strlen(base);
|
||||
srand(time(NULL));
|
||||
for (x=0; x<5; x++)
|
||||
{
|
||||
@ -49,9 +54,22 @@ int TestPathMakePath(int argc, char* argv[])
|
||||
free (path);
|
||||
return -1;
|
||||
}
|
||||
free (path);
|
||||
|
||||
printf("%s success!", __FUNCTION__);
|
||||
while (strlen(path) > baseLen)
|
||||
{
|
||||
if (!RemoveDirectoryA(path))
|
||||
{
|
||||
fprintf(stderr, "RemoveDirectoryA %s failed!\n", path);
|
||||
free (path);
|
||||
return -1;
|
||||
}
|
||||
cur = strrchr(path, delim);
|
||||
if (cur)
|
||||
*cur = '\0';
|
||||
}
|
||||
|
||||
free (path);
|
||||
printf("%s success!\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user