Support directories (instead of crashing)
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #include <sys/ioctl.h> | ||||
| #include <experimental/filesystem> | ||||
|  | ||||
| #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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 stefan.haustein@gmail.com
					stefan.haustein@gmail.com