Port: Replace dirent->d_type by stat S_ISREG
[babeltrace.git] / tests / lib / test_ctf_writer.c
index f15ad43784ac3d811bbf966523ebe24e2b1777d6..007423d1870c5cbfa39b989fe70828832b86f8d8 100644 (file)
@@ -42,6 +42,7 @@
 #include "tap/tap.h"
 #include <math.h>
 #include <float.h>
+#include <sys/stat.h>
 
 #define METADATA_LINE_SIZE 512
 #define SEQUENCE_TEST_LENGTH 10
@@ -3297,7 +3298,19 @@ int main(int argc, char **argv)
 
        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);
                }
        }
This page took 0.024714 seconds and 4 git commands to generate.