projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanup: remove plugin-common.h
[babeltrace.git]
/
tests
/
lib
/
common.c
diff --git
a/tests/lib/common.c
b/tests/lib/common.c
index 3f418e6d3b9d408fcab6bd2e032c947b0bee131b..1878d777d3eba4b78f43523a4dcc8f48fd8719a0 100644
(file)
--- a/
tests/lib/common.c
+++ b/
tests/lib/common.c
@@
-21,38
+21,30
@@
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
-#include <babeltrace/compat/dirent.h>
-#include <babeltrace/compat/limits.h>
-#include <sys/stat.h>
+#include <dirent.h>
+#include <ftw.h>
-void recursive_rmdir(const char *path)
-{
- struct dirent *entry;
- DIR *dir = opendir(path);
+#define RMDIR_NFDOPEN 8
- if (!dir) {
- perror("# opendir");
- return;
+static
+int nftw_recursive_rmdir(const char *file, const struct stat *sb, int flag,
+ struct FTW *s)
+{
+ switch (flag) {
+ case FTW_F:
+ unlink(file);
+ break;
+ case FTW_DP:
+ rmdir(file);
+ break;
}
}
- while ((entry = readdir(dir))) {
- struct stat st;
- char filename[PATH_MAX];
-
- if (snprintf(filename, sizeof(filename), "%s/%s",
- path, entry->d_name) <= 0) {
- continue;
- }
-
- if (stat(filename, &st)) {
- continue;
- }
+ return 0;
+}
- if (S_ISREG(st.st_mode)) {
- unlinkat(bt_dirfd(dir), entry->d_name, 0);
- }
- }
+void recursive_rmdir(const char *path)
+{
+ int nftw_flags = FTW_PHYS | FTW_DEPTH;
- rmdir(path);
- closedir(dir);
+ nftw(path, nftw_recursive_rmdir, RMDIR_NFDOPEN, nftw_flags);
}
}
This page took
0.029242 seconds
and
4
git commands to generate.