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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user