| 28 | static fs::path usersFsPath(const std::string& basePath) |
| 29 | { |
| 30 | return FilesystemPathFromUtf8(usersDir(basePath)); |
| 31 | } |
| 32 | |
| 33 | static void makeTreeWritable(const fs::path& path) |
| 34 | { |
| 35 | std::error_code ec; |
| 36 | if (fs::is_symlink(fs::symlink_status(path, ec))) |
| 37 | return; |
| 38 | |
| 39 | fs::permissions(path, fs::perms::owner_all, fs::perm_options::add, ec); |
| 40 | ec.clear(); |
| 41 | fs::recursive_directory_iterator entry(path, fs::directory_options::skip_permission_denied, ec); |
| 42 | const fs::recursive_directory_iterator end; |
| 43 | while (entry != end) |
| 44 | { |
| 45 | std::error_code permissionError; |
| 46 | if (!entry->is_symlink(permissionError)) |
| 47 | fs::permissions(entry->path(), fs::perms::owner_all, fs::perm_options::add, permissionError); |
| 48 | entry.increment(ec); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | namespace ProfileManager |
| 53 | { |
| 54 | |
| 55 | std::vector<ProfileInfo> EnumerateProfiles(const std::string& basePath) |
| 56 | { |
| 57 | std::vector<ProfileInfo> profiles; |
| 58 | fs::path uDir = usersFsPath(basePath); |
| 59 | |
| 60 | std::error_code ec; |
| 61 | if (!fs::is_directory(uDir, ec)) |
| 62 | return profiles; |
| 63 | |
| 64 | for (const auto& entry : fs::directory_iterator(uDir, ec)) |
no test coverage detected