diff --git a/src/main/cpp/Makefile b/src/main/cpp/Makefile index 2cd121f..e3b7754 100644 --- a/src/main/cpp/Makefile +++ b/src/main/cpp/Makefile @@ -1,10 +1,10 @@ default: tiv tiv.o: tiv.cpp CImg.h - g++ -std=c++11 -Wall -fexceptions -O2 -c tiv.cpp -o tiv.o + g++ -std=c++17 -Wall -fpermissive -fexceptions -O2 -c tiv.cpp -o tiv.o tiv : tiv.o - g++ tiv.o -o tiv -pthread -s + g++ tiv.o -o tiv -lstdc++fs -pthread -s install: tiv cp tiv /usr/local/bin/tiv diff --git a/src/main/cpp/tiv.cpp b/src/main/cpp/tiv.cpp index ff1cd4d..783723c 100644 --- a/src/main/cpp/tiv.cpp +++ b/src/main/cpp/tiv.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #define cimg_display 0 #include "CImg.h" @@ -435,10 +436,19 @@ int main(int argc, char* argv[]) { } else if (arg[0] == '-') { std::cerr << "Unrecognized argument: " << arg << std::endl; } else { - file_names.push_back(arg); + if (std::experimental::filesystem::is_directory(arg)) { + for (auto & p : std::experimental::filesystem::directory_iterator(arg)) { + if (std::experimental::filesystem::is_regular_file(p.path())) { + file_names.push_back(p.path().string()); + } + } + } else { + file_names.push_back(arg); + } } } + if (mode == FULL_SIZE || (mode == AUTO && file_names.size() == 1)) { for (unsigned int i = 0; i < file_names.size(); i++) { try {