Skip to content

Commit

Permalink
Fix d_type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-steinegger committed Jun 25, 2023
1 parent 04e0ec8 commit d1d1b86
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/strucclustutils/structcreatedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <iostream>
#include <dirent.h>
#include <sys/stat.h>

#ifdef HAVE_GCS
#include "google/cloud/storage/client.h"
Expand Down Expand Up @@ -261,11 +262,15 @@ int createdb(int argc, const char **argv, const Command& command) {
}
while (dirent* entry = readdir(handle)) {
std::string filename(entry->d_name);

if (filename != "." && filename !="..") {
if (entry->d_type == DT_DIR) {
dirs.push_back(dir+"/"+filename);
std::string fullpath = dir + "/" + filename;
struct stat info;
stat(fullpath.c_str(), &info);
if (info.st_mode & S_IFDIR) {
dirs.push_back(fullpath);
} else {
par.filenames.push_back(dir+"/"+filename);
par.filenames.push_back(fullpath);
}
}
}
Expand Down

0 comments on commit d1d1b86

Please sign in to comment.