UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MappedFileHandle.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
7#include "Stats/Stats.h"
8
9
13
14// Note on threading. Like the rest of the filesystem platform abstraction, these methods are threadsafe, but it is expected you are not concurrently _using_ these data structures.
15
17{
18 const uint8* MappedPtr;
19 size_t MappedSize;
20 FString DebugFilename;
21 size_t DebugOffsetRelativeToFile;
22
23 UE_FORCEINLINE_HINT void CheckInvariants()
24 {
25 check(MappedPtr && MappedSize);
26 }
27
28public:
29
31 : MappedPtr(InMappedPtr)
32 , MappedSize(InMappedSize)
33 , DebugFilename(InDebugFilename)
34 , DebugOffsetRelativeToFile(InDebugOffsetRelativeToFile)
35 {
36 CheckInvariants();
39 }
40
47
48
53 inline const uint8* GetMappedPtr()
54 {
55 CheckInvariants();
56 return MappedPtr;
57 }
58
63 {
64 CheckInvariants();
65 return MappedSize;
66 }
67
78
87 {
88 }
89
90 // Non-copyable
93};
94
96{
97 ENone = 0, // Do nothing
98 EPreloadHint = 1, // Preload the data. This is only a hint and might be ignored, see IMappedFileRegion::PreloadHint
99 EFileWritable = 2, // Make the mapped file writable. Requires OpenMappedEx to be called with OpenOptions set to EOpenReadFlags::AllowWrite.
100 // This will create a shared mapping on Unix platform to allow any writes to be flushed to disk
101};
102
104
105
113
115{
116 size_t MappedFileSize;
117
118public:
120 : MappedFileSize(InFileSize)
121 {
123 }
129
134 {
135 return MappedFileSize;
136 }
137
146
147 virtual void Flush(void)
148 {
149 }
150
151 // Non-copyable
154};
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
#define INC_MEMORY_STAT_BY(StatId, Amount)
Definition Stats.h:700
#define INC_DWORD_STAT(StatId)
Definition Stats.h:696
#define DEC_DWORD_STAT(StatId)
Definition Stats.h:701
#define DEC_MEMORY_STAT_BY(StatId, Amount)
Definition Stats.h:705
#define DECLARE_DWORD_ACCUMULATOR_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:684
#define DECLARE_MEMORY_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:687
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EMappedFileFlags
Definition MappedFileHandle.h:96
#define MAX_int64
Definition NumericLimits.h:26
uint32 Offset
Definition VulkanMemory.cpp:4033
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition MappedFileHandle.h:115
IMappedFileHandle(const IMappedFileHandle &)=delete
virtual ~IMappedFileHandle()
Definition MappedFileHandle.h:125
virtual void Flush(void)
Definition MappedFileHandle.h:147
IMappedFileHandle(size_t InFileSize)
Definition MappedFileHandle.h:119
IMappedFileHandle & operator=(const IMappedFileHandle &)=delete
UE_FORCEINLINE_HINT int64 GetFileSize() const
Definition MappedFileHandle.h:133
virtual IMappedFileRegion * MapRegion(int64 Offset=0, int64 BytesToMap=MAX_int64, FFileMappingFlags Flags=EMappedFileFlags::ENone)=0
Definition MappedFileHandle.h:17
const uint8 * GetMappedPtr()
Definition MappedFileHandle.h:53
virtual void PreloadHint(int64 PreloadOffset=0, int64 BytesToPreload=MAX_int64)
Definition MappedFileHandle.h:75
virtual void Flush(int64 FlushOffset=0, int64 BytesToFlush=MAX_int64)
Definition MappedFileHandle.h:86
IMappedFileRegion & operator=(const IMappedFileRegion &)=delete
int64 GetMappedSize()
Definition MappedFileHandle.h:62
virtual ~IMappedFileRegion()
Definition MappedFileHandle.h:41
IMappedFileRegion(const uint8 *InMappedPtr, size_t InMappedSize, const FString &InDebugFilename, size_t InDebugOffsetRelativeToFile)
Definition MappedFileHandle.h:30
IMappedFileRegion(const IMappedFileRegion &)=delete
Definition MappedFileHandle.h:107
FFileMappingFlags(EMappedFileFlags InFlags)
Definition MappedFileHandle.h:110
FFileMappingFlags(bool bPreloadHint)
Definition MappedFileHandle.h:109
EMappedFileFlags Flags
Definition MappedFileHandle.h:111
FFileMappingFlags()
Definition MappedFileHandle.h:108