mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Use ScopedHandle for File::Handle
This commit is contained in:
parent
5078b6822a
commit
2014ea40b9
2 changed files with 11 additions and 1 deletions
|
@ -22,7 +22,7 @@ namespace Files
|
||||||
private:
|
private:
|
||||||
std::size_t mOrigin;
|
std::size_t mOrigin;
|
||||||
std::size_t mSize;
|
std::size_t mSize;
|
||||||
Platform::File::Handle mFile{ Platform::File::Handle::Invalid };
|
Platform::File::ScopedHandle mFile;
|
||||||
char mBuffer[8192]{ 0 };
|
char mBuffer[8192]{ 0 };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,17 @@ namespace Platform::File {
|
||||||
|
|
||||||
size_t read(Handle handle, void* data, size_t size);
|
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
|
#endif // OPENMW_COMPONENTS_PLATFORM_FILE_HPP
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue