2018-10-10 09:53:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-12-03 23:27:16 +00:00
|
|
|
#include "AKString.h"
|
2018-10-10 09:53:07 +00:00
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
class MappedFile {
|
|
|
|
public:
|
|
|
|
MappedFile() { }
|
2019-01-31 16:31:23 +00:00
|
|
|
explicit MappedFile(String&& file_name);
|
2018-10-10 09:53:07 +00:00
|
|
|
MappedFile(MappedFile&&);
|
|
|
|
~MappedFile();
|
|
|
|
|
2019-01-31 16:31:23 +00:00
|
|
|
bool is_valid() const { return m_map != (void*)-1; }
|
2018-10-10 09:53:07 +00:00
|
|
|
|
|
|
|
void* pointer() { return m_map; }
|
|
|
|
const void* pointer() const { return m_map; }
|
2019-01-31 16:31:23 +00:00
|
|
|
size_t file_length() const { return m_file_length; }
|
2018-10-10 09:53:07 +00:00
|
|
|
|
|
|
|
private:
|
2019-01-31 16:31:23 +00:00
|
|
|
String m_file_name;
|
|
|
|
size_t m_file_length { 0 };
|
2018-10-10 09:53:07 +00:00
|
|
|
int m_fd { -1 };
|
|
|
|
void* m_map { (void*)-1 };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::MappedFile;
|
|
|
|
|