Cogs.Foundation
Loading...
Searching...
No Matches
MMapBackedFileContents.h
Go to the documentation of this file.
1#pragma once
2
3#if !defined( EMSCRIPTEN )
4
5#include "FileContents.h"
6#include "FileHandle.h"
7
8namespace Cogs {
11 std::string path;
12
14 size_t size,
15 const FileHandle::Ptr& file,
16 const std::string& 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
std::shared_ptr< FileHandle > Ptr
Definition: FileHandle.h:17
Definition: MemoryBuffer.h:23
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Main Cogs namespace.
Definition: MortonCode.h:5
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
Memory::MemoryBuffer takeCopy()
Definition: FileContents.cpp:3
const uint8_t * ptr
Start of buffer storing file data. Use.
Definition: FileContents.h:27
FileContentsHints hints
Definition: FileContents.h:31
Definition: MMapBackedFileContents.h:9
StringView origin() override
Definition: MMapBackedFileContents.h:22
FileHandle::Ptr file
Definition: MMapBackedFileContents.h:10
Memory::MemoryBuffer take() override
Take ownership of underlying memorybuffer if exists.
Definition: MMapBackedFileContents.h:21
~MMapBackedFileContents() override=default
std::string path
Definition: MMapBackedFileContents.h:11
MMapBackedFileContents(const uint8_t *ptr, size_t size, const FileHandle::Ptr &file, const std::string &path, FileContentsHints hints)
Definition: MMapBackedFileContents.h:13