Cogs.Core
MMapBackedFileContents.h
1#pragma once
2
3#if !defined( EMSCRIPTEN )
4
5#include "FileContents.h"
6#include "FileHandle.h"
7
8namespace Cogs {
10 FileHandle::Ptr file;
11 std::string path;
12
13 MMapBackedFileContents(const uint8_t* ptr,
14 size_t size,
15 const FileHandle::Ptr& file,
16 const std::string& path,
17 FileContentsHints hints) : FileContents(ptr, size, hints), file(file), path(path) {}
18
19 ~MMapBackedFileContents() override = default;
20
21 [[nodiscard]] Memory::MemoryBuffer take() override { return takeCopy(); }
22 [[nodiscard]] StringView origin() override { return path; }
23 };
24}
25
26#endif
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
FileContentsHints
Definition: FileContents.h:11
Abstract base class storing data read from a file.
Definition: FileContents.h:20
size_t size
Number of data bytes.
Definition: FileContents.h:29
const uint8_t * ptr
Start of buffer storing file data. Use.
Definition: FileContents.h:27
Memory::MemoryBuffer take() override
Take ownership of underlying memorybuffer if exists.