mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
Relocate helper function, only used by tmpfiles
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
2 files changed
+17
-16
No files matched your search
@@ -207,22 +207,6 @@ static inline char *fgetval(const char *line, const char *key, char *sep)
|
|||||||
return realloc(copy, len);
|
return realloc(copy, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int is_dir_empty(const char *path)
|
|
||||||
{
|
|
||||||
struct dirent **namelist;
|
|
||||||
int num;
|
|
||||||
|
|
||||||
num = scandir(path, &namelist, NULL, NULL);
|
|
||||||
if (num < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < num; i++)
|
|
||||||
free(namelist[i]);
|
|
||||||
free(namelist);
|
|
||||||
|
|
||||||
return num >= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* FINIT_HELPERS_H_ */
|
#endif /* FINIT_HELPERS_H_ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "config.h" /* Generated by configure script */
|
#include "config.h" /* Generated by configure script */
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
#include <ftw.h>
|
#include <ftw.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
@@ -68,6 +69,22 @@ int kerndebug;
|
|||||||
int c_flag = 0;
|
int c_flag = 0;
|
||||||
int r_flag = 0;
|
int r_flag = 0;
|
||||||
|
|
||||||
|
static int is_dir_empty(const char *path)
|
||||||
|
{
|
||||||
|
struct dirent **namelist;
|
||||||
|
int num;
|
||||||
|
|
||||||
|
num = scandir(path, &namelist, NULL, NULL);
|
||||||
|
if (num < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
free(namelist[i]);
|
||||||
|
free(namelist);
|
||||||
|
|
||||||
|
return num >= 3;
|
||||||
|
}
|
||||||
|
|
||||||
static int glob_do(const char *path, int (*cb)(const char *))
|
static int glob_do(const char *path, int (*cb)(const char *))
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user