summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
37566b7)
dirent->d_type is Linux specific while 'stat' is part of POSIX
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <fcntl.h>
#include <babeltrace/compat/dirent.h>
#include "tap/tap.h"
#include <fcntl.h>
#include <babeltrace/compat/dirent.h>
#include "tap/tap.h"
#define METADATA_LINE_SIZE 512
#define SEQUENCE_TEST_LENGTH 10
#define METADATA_LINE_SIZE 512
#define SEQUENCE_TEST_LENGTH 10
struct dirent *entry;
while ((entry = readdir(trace_dir))) {
struct dirent *entry;
while ((entry = readdir(trace_dir))) {
- if (entry->d_type == DT_REG) {
+ struct stat st;
+ char filename[PATH_MAX];
+
+ if (snprintf(filename, sizeof(filename), "%s/%s",
+ trace_path, entry->d_name) <= 0) {
+ continue;
+ }
+
+ if (stat(entry->d_name, &st)) {
+ continue;
+ }
+
+ if (S_ISREG(st.st_mode)) {
unlinkat(bt_dirfd(trace_dir), entry->d_name, 0);
}
}
unlinkat(bt_dirfd(trace_dir), entry->d_name, 0);
}
}