diff options
author | Pierre Joye <pierre.php@gmail.com> | 2016-07-11 16:53:58 +0700 |
---|---|---|
committer | Pierre Joye <pierre.php@gmail.com> | 2016-07-11 16:53:58 +0700 |
commit | ddd30d73a4c48aa6536756274054acc4f8fec2d0 (patch) | |
tree | 2d670b5493492e19657484b7d707853554c216c8 /tests/gdtest | |
parent | 705e29a4502d873b12d66700a034db7a48dc38ab (diff) | |
download | libgd-ddd30d73a4c48aa6536756274054acc4f8fec2d0.tar.gz |
implement clean_dir on windows
Diffstat (limited to 'tests/gdtest')
-rw-r--r-- | tests/gdtest/gdtest.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/gdtest/gdtest.c b/tests/gdtest/gdtest.c index e25d8be..ea9ed97 100644 --- a/tests/gdtest/gdtest.c +++ b/tests/gdtest/gdtest.c @@ -20,6 +20,10 @@ #include <sys/types.h> #endif +#ifdef _WIN32 +# include "readdir.h" +#endif + #include "gd.h" #include "gdtest.h" @@ -75,7 +79,20 @@ static void _clean_dir(const char *dir) if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue; +#ifdef _WIN32 + { + WIN32_FILE_ATTRIBUTE_DATA data; + if (!GetFileAttributesEx(de->d_name, GetFileExInfoStandard, &data)) { + continue; + } + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + _clean_dir(de->d_name); + } else { + unlink(de->d_name); + } + } +#else if (lstat(de->d_name, &st) != 0) continue; @@ -83,6 +100,7 @@ static void _clean_dir(const char *dir) _clean_dir(de->d_name); else unlink(de->d_name); +#endif } if (chdir("..")) { |