diff --git a/AdvancedCppV2/Presentation/exercises/files/main.cpp b/AdvancedCppV2/Presentation/exercises/files/main.cpp index 66f041d..bf795f4 100644 --- a/AdvancedCppV2/Presentation/exercises/files/main.cpp +++ b/AdvancedCppV2/Presentation/exercises/files/main.cpp @@ -58,17 +58,17 @@ int main() { std::cout << "File write time is " << std::asctime(std::localtime(&time)); }; - std::vector paths; + std::vector> paths; for (const auto& entry : fs::directory_iterator(fs::current_path().string() + "/project")) { if (fs::is_regular_file(entry.path())) { - paths.push_back(entry.path()); + paths.push_back(std::make_pair(entry.path(), fs::last_write_time(entry.path()))); } } - std::sort(paths.begin(), paths.end(), [](fs::path a, fs::path b) {return fs::last_write_time(a) > fs::last_write_time(b);}); + std::sort(paths.begin(), paths.end(), [](auto a, auto b) {return ( a > b );}); - std::cout << "Last modified file is: " << paths.front() << '\n'; - print_last_write_time(std::filesystem::last_write_time(paths.front())); - std::cout << "files which were longest unmodified: " << paths.back() << std::endl; - print_last_write_time(std::filesystem::last_write_time(paths.back())); + std::cout << "Last modified file is: " << paths.front().first << '\n'; + print_last_write_time(std::filesystem::last_write_time(paths.front().first)); + std::cout << "files which were longest unmodified: " << paths.back().first << std::endl; + print_last_write_time(std::filesystem::last_write_time(paths.back().first)); }