27 #define pg_log_warning(...) elog(WARNING, __VA_ARGS__)
28 #define LOG_LEVEL WARNING
29 #define OPENDIR(x) AllocateDir(x)
30 #define CLOSEDIR(x) FreeDir(x)
33 #define LOG_LEVEL PG_LOG_WARNING
34 #define OPENDIR(x) opendir(x)
35 #define CLOSEDIR(x) closedir(x)
50 rmtree(
const char *path,
bool rmtopdir)
56 size_t dirnames_size = 0;
57 size_t dirnames_capacity = 8;
58 char **dirnames =
palloc(
sizeof(
char *) * dirnames_capacity);
67 while (errno = 0, (de =
readdir(dir)))
69 if (strcmp(de->
d_name,
".") == 0 ||
70 strcmp(de->
d_name,
"..") == 0)
84 if (dirnames_size == dirnames_capacity)
87 sizeof(
char *) * dirnames_capacity * 2);
88 dirnames_capacity *= 2;
90 dirnames[dirnames_size++] =
pstrdup(pathbuf);
93 if (unlink(pathbuf) != 0 && errno != ENOENT)
111 for (
size_t i = 0;
i < dirnames_size; ++
i)
113 if (!
rmtree(dirnames[
i],
true))
120 if (rmdir(path) != 0)
struct dirent * readdir(DIR *)
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * repalloc(void *pointer, Size size)
bool rmtree(const char *path, bool rmtopdir)
#define pg_log_warning(...)