diff --git a/AdvancedCppV2/Presentation/exercises/files/main.cpp b/AdvancedCppV2/Presentation/exercises/files/main.cpp index 52702a3..833c662 100644 --- a/AdvancedCppV2/Presentation/exercises/files/main.cpp +++ b/AdvancedCppV2/Presentation/exercises/files/main.cpp @@ -30,6 +30,18 @@ void printPermissionsForDir() { } void changePermissions() { + for (const auto& entry : fs::directory_iterator(fs::current_path().string() + "/project")) { + if (fs::is_regular_file(entry.path())) { + fs::perms p = fs::perms::none; + using per = fs::perms; + if(entry.path().extension() == ".exe"){ + p = per::owner_all | per::group_read | per::group_write | per::others_read | per::others_write; + } else if(entry.path().extension() == ".cpp" || entry.path().extension() == ".hpp"){ + p = per::owner_read | per::owner_write | per::group_read | per::others_read; + } + fs::permissions(entry.path(), p); + } + } } int main() { @@ -49,4 +61,4 @@ int main() { std::cout << "files which were longest unmodified: \n"; // Print it here */ -} \ No newline at end of file +}