Skip to content

Commit dd28f2c

Browse files
mmankgtoubassi
authored andcommitted
fix for compiling with mingw mingw does not support DT_REG flag of struct direntry.
1 parent 8696ed4 commit dd28f2c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cpp/fzip/src/fzip.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,17 @@ void parseArgs(int argc, const char **argv) {
313313
usage(string("Cannot opendir ") + arg);
314314
}
315315

316+
316317
while ((dp = readdir(dirp)) != NULL) {
317-
if (dp->d_type == DT_REG) {
318-
paths.push_back(string(arg) + "/" + dp->d_name);
319-
}
318+
struct stat st;
319+
std::string path = string(arg) + "/" + dp->d_name;
320+
if(0 == stat(path.c_str(), &st)){
321+
if (S_ISREG(st.st_mode)) {
322+
paths.push_back(path);
323+
}
324+
}else{
325+
usage(string("Cannot stat ") + arg);
326+
}
320327
}
321328

322329
closedir(dirp);

0 commit comments

Comments
 (0)