| 20 | |
| 21 | namespace mdf { |
| 22 | void CreateFileList::MakeFileList(const std::vector<std::string>& input_files) { |
| 23 | // Parse out the directories first |
| 24 | try { |
| 25 | files_ok_ = true; |
| 26 | for (const auto& input : input_files) { |
| 27 | path input_path(input); |
| 28 | if (!exists(input_path)) { |
| 29 | MDF_ERROR() << "The input path/file doesn't exist. File: " << input; |
| 30 | files_ok_ = false; |
| 31 | } else if (is_directory(input_path)) { |
| 32 | directories_.emplace_back(input_path.string()); |
| 33 | } else if (is_regular_file(input_path)) { |
| 34 | const auto file = input_path.string(); |
| 35 | const bool mdf = IsMdfFile(file); |
| 36 | if (!mdf) { |
| 37 | MDF_ERROR() << "The file isn't an MDF file. File: " << file; |
| 38 | files_ok_ = false; |
| 39 | continue; |
| 40 | } |
| 41 | |
| 42 | files_.emplace_back(file); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | for (const auto& dir : directories_) { |
| 47 | path input_dir(dir); |
| 48 | for (const directory_entry& dir_entry : |
| 49 | recursive_directory_iterator(input_dir)) { |
| 50 | if (!dir_entry.is_regular_file()) { |
| 51 | continue; |
| 52 | } |
| 53 | const auto file = dir_entry.path().string(); |
| 54 | const bool mdf = IsMdfFile(file); |
| 55 | if (!mdf) { |
| 56 | // This is not considered an error as above. |
| 57 | continue; |
| 58 | } |
| 59 | |
| 60 | files_.emplace_back(file); |
| 61 | } |
| 62 | } |
| 63 | } catch (const std::exception& err) { |
| 64 | MDF_ERROR() << "File/Directory syntax error. Error: " << err.what(); |
| 65 | files_ok_ = false; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | void CreateFileList::ConvertMdfFile(const std::string& file) { |
| 70 | const auto& arguments = ProgramArgument::Instance(); |