Use ScopedHandle for File::Handle

This commit is contained in:
ζeh Matt 2022-07-18 21:13:41 +03:00
parent 5078b6822a
commit 2014ea40b9
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
2 changed files with 11 additions and 1 deletions

View file

@ -29,7 +29,17 @@ namespace Platform::File {
size_t read(Handle handle, void* data, size_t size);
class ScopedHandle
{
Handle mHandle{ Handle::Invalid };
public:
ScopedHandle() = default;
ScopedHandle(Handle handle) : mHandle(handle) {}
~ScopedHandle() { close(mHandle); }
operator Handle() const { return mHandle; }
};
}
#endif // OPENMW_COMPONENTS_PLATFORM_FILE_HPP