mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +00:00
AK: Make MappedFile store why it is invalid
This makes AK::MappedFile save the errno either open() or mmap() failed with.
This commit is contained in:
parent
d04c833002
commit
6131417904
2 changed files with 12 additions and 2 deletions
|
@ -33,8 +33,9 @@ namespace AK {
|
|||
|
||||
class MappedFile {
|
||||
AK_MAKE_NONCOPYABLE(MappedFile);
|
||||
|
||||
public:
|
||||
MappedFile() {}
|
||||
MappedFile() { }
|
||||
explicit MappedFile(const StringView& file_name);
|
||||
MappedFile(MappedFile&&);
|
||||
~MappedFile();
|
||||
|
@ -42,6 +43,11 @@ public:
|
|||
MappedFile& operator=(MappedFile&&);
|
||||
|
||||
bool is_valid() const { return m_map != (void*)-1; }
|
||||
int errno_if_invalid() const
|
||||
{
|
||||
ASSERT(!is_valid());
|
||||
return m_errno;
|
||||
}
|
||||
void unmap();
|
||||
|
||||
void* data() { return m_map; }
|
||||
|
@ -51,6 +57,7 @@ public:
|
|||
private:
|
||||
size_t m_size { 0 };
|
||||
void* m_map { (void*)-1 };
|
||||
int m_errno { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue