2018-10-10 11:53:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-07-11 15:14:30 +02:00
|
|
|
#include <AK/Noncopyable.h>
|
|
|
|
#include <AK/StringView.h>
|
2018-10-10 11:53:07 +02:00
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
class MappedFile {
|
2019-07-11 15:14:30 +02:00
|
|
|
AK_MAKE_NONCOPYABLE(MappedFile);
|
2018-10-10 11:53:07 +02:00
|
|
|
public:
|
2019-05-28 11:53:16 +02:00
|
|
|
MappedFile() {}
|
2019-06-02 14:58:02 +02:00
|
|
|
explicit MappedFile(const StringView& file_name);
|
2018-10-10 11:53:07 +02:00
|
|
|
MappedFile(MappedFile&&);
|
|
|
|
~MappedFile();
|
|
|
|
|
2019-04-03 13:51:49 +02:00
|
|
|
MappedFile& operator=(MappedFile&&);
|
|
|
|
|
2019-01-31 17:31:23 +01:00
|
|
|
bool is_valid() const { return m_map != (void*)-1; }
|
2019-04-03 13:51:49 +02:00
|
|
|
void unmap();
|
2018-10-10 11:53:07 +02:00
|
|
|
|
|
|
|
void* pointer() { return m_map; }
|
|
|
|
const void* pointer() const { return m_map; }
|
2019-04-03 14:15:35 +02:00
|
|
|
size_t size() const { return m_size; }
|
2018-10-10 11:53:07 +02:00
|
|
|
|
|
|
|
private:
|
2019-04-03 14:15:35 +02:00
|
|
|
size_t m_size { 0 };
|
2018-10-10 11:53:07 +02:00
|
|
|
void* m_map { (void*)-1 };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::MappedFile;
|