|
10 | 10 |
|
11 | 11 | #include <qCheck.hpp>
|
12 | 12 |
|
| 13 | +void ProcessInputPath(Settings& CurSettings, const std::filesystem::path& Path) |
| 14 | +{ |
| 15 | + if( !std::filesystem::exists(Path) ) |
| 16 | + { |
| 17 | + std::fprintf(stderr, "Path does not exist: %s\n", Path.c_str()); |
| 18 | + return; |
| 19 | + } |
| 20 | + std::error_code CurError; |
| 21 | + // Regular files only, for now, other files will be specially handled |
| 22 | + // later |
| 23 | + if( std::filesystem::is_regular_file(Path, CurError) ) |
| 24 | + { |
| 25 | + CurSettings.InputFiles.emplace_back(Path); |
| 26 | + } |
| 27 | + else if( |
| 28 | + CurSettings.Recursive && std::filesystem::is_directory(Path, CurError) ) |
| 29 | + { |
| 30 | + for( const std::filesystem::directory_entry& DirectoryEntry : |
| 31 | + std::filesystem::recursive_directory_iterator(Path) ) |
| 32 | + { |
| 33 | + ProcessInputPath(CurSettings, DirectoryEntry.path()); |
| 34 | + } |
| 35 | + } |
| 36 | + else |
| 37 | + { |
| 38 | + std::fprintf(stderr, "Error opening path: %s\n", Path.c_str()); |
| 39 | + } |
| 40 | +} |
| 41 | + |
13 | 42 | int main(int argc, char* argv[])
|
14 | 43 | {
|
15 | 44 | Settings CurSettings = {};
|
@@ -68,22 +97,7 @@ int main(int argc, char* argv[])
|
68 | 97 | for( std::intmax_t i = 0; i < argc; ++i )
|
69 | 98 | {
|
70 | 99 | const std::filesystem::path CurPath(argv[i]);
|
71 |
| - if( !std::filesystem::exists(CurPath) ) |
72 |
| - { |
73 |
| - std::fprintf(stderr, "File does not exist: %s\n", argv[i]); |
74 |
| - continue; |
75 |
| - } |
76 |
| - std::error_code CurError; |
77 |
| - // Regular files only, for now, other files will be specially handled |
78 |
| - // later |
79 |
| - if( std::filesystem::is_regular_file(CurPath, CurError) ) |
80 |
| - { |
81 |
| - CurSettings.InputFiles.emplace_back(CurPath); |
82 |
| - } |
83 |
| - else |
84 |
| - { |
85 |
| - std::fprintf(stderr, "Error opening file: %s\n", argv[i]); |
86 |
| - } |
| 100 | + ProcessInputPath(CurSettings, CurPath); |
87 | 101 | }
|
88 | 102 |
|
89 | 103 | return CurSettings.Check ? CheckSFV(CurSettings) : GenerateSFV(CurSettings);
|
|
0 commit comments