File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change 14
14
#include <dirent.h>
15
15
#include <sys/stat.h>
16
16
17
- /*
18
- * selects function for scandir.
19
- * Select all files except hidden.
20
- */
21
- static int selects (const struct dirent * dir )
22
- {
23
- return dir -> d_name [0 ] != '.' ;
24
- }
25
-
26
17
/*
27
18
* Initialize backup catalog.
28
19
*/
@@ -31,14 +22,16 @@ do_init(void)
31
22
{
32
23
char path [MAXPGPATH ];
33
24
char arclog_path_dir [MAXPGPATH ];
34
- struct dirent * * dp ;
35
25
int results ;
36
26
37
- if (access (backup_path , F_OK ) == 0 )
27
+ results = pg_check_dir (backup_path );
28
+ if (results == 4 ) /* exists and not empty*/
29
+ elog (ERROR , "backup catalog already exist and it's not empty" );
30
+ else if (results == -1 ) /*trouble accessing directory*/
38
31
{
39
- results = scandir ( backup_path , & dp , selects , NULL ) ;
40
- if ( results != 0 )
41
- elog ( ERROR , "backup catalog already exist and it's not empty" );
32
+ int errno_tmp = errno ;
33
+ elog ( ERROR , "cannot open backup catalog directory \"%s\": %s" ,
34
+ backup_path , strerror ( errno_tmp ) );
42
35
}
43
36
44
37
/* create backup catalog root directory */
You can’t perform that action at this time.
0 commit comments