PostgreSQL Source Code: src/common/pgfnames.c Source File (original) (raw)
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef FRONTEND
17#else
19#endif
20
22
23#ifndef FRONTEND
24#define pg_log_warning(...) elog(WARNING, __VA_ARGS__)
25#else
27#endif
28
29
30
31
32
33
34
35
36char **
38{
41 char **filenames;
42 int numnames = 0;
43 int fnsize = 200;
44
46 if (dir == NULL)
47 {
48 pg_log_warning("could not open directory \"%s\": %m", path);
49 return NULL;
50 }
51
52 filenames = (char **) palloc(fnsize * sizeof(char *));
53
54 while (errno = 0, (file = readdir(dir)) != NULL)
55 {
56 if (strcmp(file->d_name, ".") != 0 && strcmp(file->d_name, "..") != 0)
57 {
58 if (numnames + 1 >= fnsize)
59 {
60 fnsize *= 2;
61 filenames = (char **) repalloc(filenames,
62 fnsize * sizeof(char *));
63 }
65 }
66 }
67
68 if (errno)
69 pg_log_warning("could not read directory \"%s\": %m", path);
70
71 filenames[numnames] = NULL;
72
74 pg_log_warning("could not close directory \"%s\": %m", path);
75
76 return filenames;
77}
78
79
80
81
82
83
84
85void
87{
88 char **fn;
89
90 for (fn = filenames; *fn; fn++)
92
94}
struct dirent * readdir(DIR *)
DIR * opendir(const char *)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void pgfnames_cleanup(char **filenames)
#define pg_log_warning(...)
char ** pgfnames(const char *path)
static void * fn(void *arg)