refactor: phase 6 cleanup — RAII handles and io::restore split

- AccountProfileHandle RAII wrapper in handles.hpp; applied in
  account.cpp (getUser, iconPath) replacing manual accountProfileClose
- FILE* in iconPath replaced with existing FileHandle RAII wrapper
- io::restore split into clearSaveRoot + extractAndCommit static helpers;
  public signature unchanged
- sendAll/recvAll kept as bool — callers don't propagate the error string,
  Result<void> would add noise without benefit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-03 14:56:38 +03:00
parent 836956394a
commit 6f8ede035f
4 changed files with 187 additions and 43 deletions
+19
View File
@@ -49,4 +49,23 @@ struct FileHandle {
}
};
// RAII wrapper for AccountProfile — auto-closes on destruction.
struct AccountProfileHandle {
AccountProfile profile{};
bool valid{false};
AccountProfileHandle() = default;
~AccountProfileHandle() {
if (valid)
accountProfileClose(&profile);
} // NOLINT(modernize-use-equals-default)
AccountProfileHandle(const AccountProfileHandle&) = delete;
AccountProfileHandle& operator=(const AccountProfileHandle&) = delete;
AccountProfile* get() {
return &profile;
}
};
} // namespace nxst