Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
IPlatformFileLogWrapper.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Map.h"
6#include "Containers/UnrealString.h"
7#include "CoreTypes.h"
8#include "GenericPlatform/GenericPlatformFile.h"
9#include "HAL/CriticalSection.h"
10#include "HAL/PlatformMisc.h"
11#include "HAL/PlatformTime.h"
12#include "Logging/LogCategory.h"
13#include "Logging/LogMacros.h"
14#include "Math/Color.h"
15#include "Misc/DateTime.h"
16#include "Misc/ScopeLock.h"
17#include "Templates/UniquePtr.h"
18#include "Trace/Detail/Channel.h"
19
21class FOutputDevice;
22class IAsyncReadFileHandle;
23class IMappedFileHandle;
24
25/**
26 * Wrapper to log the low level file system
27**/
29
30extern bool bSuppressFileLog;
31
32#define FILE_LOG(CategoryName, Verbosity, Format, ...)
33 if (!bSuppressFileLog)
34 {
35 bSuppressFileLog = true;
36 UE_LOG(CategoryName, Verbosity, Format, ##__VA_ARGS__);
37 bSuppressFileLog = false;
38 }
39
41
43{
48#endif
49public:
50
51 FLoggedFileHandle(IFileHandle* InFileHandle, const TCHAR* InFilename, FLoggedPlatformFile& InOwner);
53
54 virtual int64 Tell() override
55 {
56 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Tell %s"), *Filename);
57 double StartTime = FPlatformTime::Seconds();
58 int64 Result = FileHandle->Tell();
59 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
60 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Tell return %lld [%fms]"), Result, ThisTime);
61 return Result;
62 }
63 virtual bool Seek(int64 NewPosition) override
64 {
65 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Seek %s %lld"), *Filename, NewPosition);
66 double StartTime = FPlatformTime::Seconds();
67 bool Result = FileHandle->Seek(NewPosition);
68 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
69 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Seek return %d [%fms]"), int32(Result), ThisTime);
70 return Result;
71 }
72 virtual bool SeekFromEnd(int64 NewPositionRelativeToEnd) override
73 {
74 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("SeekFromEnd %s %lld"), *Filename, NewPositionRelativeToEnd);
75 double StartTime = FPlatformTime::Seconds();
76 bool Result = FileHandle->SeekFromEnd(NewPositionRelativeToEnd);
77 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
78 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("SeekFromEnd return %d [%fms]"), int32(Result), ThisTime);
79 return Result;
80 }
81 virtual bool Read(uint8* Destination, int64 BytesToRead) override
82 {
83 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Read %s %lld"), *Filename, BytesToRead);
84 double StartTime = FPlatformTime::Seconds();
85 bool Result = FileHandle->Read(Destination, BytesToRead);
86 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
87 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Read return %d [%fms]"), int32(Result), ThisTime);
88 return Result;
89 }
90 virtual bool Write(const uint8* Source, int64 BytesToWrite) override
91 {
92 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Write %s %lld"), *Filename, BytesToWrite);
93 double StartTime = FPlatformTime::Seconds();
94 bool Result = FileHandle->Write(Source, BytesToWrite);
95 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
96 FILE_LOG(LogPlatformFile, VeryVerbose, TEXT("Write return %d [%fms]"), int32(Result), ThisTime);
97 return Result;
98 }
99 virtual int64 Size() override
100 {
101 FILE_LOG(LogPlatformFile, Verbose, TEXT("Size %s"), *Filename);
102 double StartTime = FPlatformTime::Seconds();
103 int64 Result = FileHandle->Size();
104 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
105 FILE_LOG(LogPlatformFile, Verbose, TEXT("Size return %lld [%fms]"), Result, ThisTime);
106 return Result;
107 }
108 virtual bool Flush(const bool bFullFlush = false) override
109 {
110 FILE_LOG(LogPlatformFile, Verbose, TEXT("Flush %s %s"), *Filename, (bFullFlush ? TEXT("full") : TEXT("partial")));
111 double StartTime = FPlatformTime::Seconds();
112 bool bResult = FileHandle->Flush(bFullFlush);
113 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
114 FILE_LOG(LogPlatformFile, Verbose, TEXT("Flush return %d [%fms]"), int32(bResult), ThisTime);
115 return bResult;
116 }
117 virtual bool Truncate(int64 NewSize) override
118 {
119 FILE_LOG(LogPlatformFile, Verbose, TEXT("Truncate %s %lld"), *Filename, NewSize);
120 double StartTime = FPlatformTime::Seconds();
121 bool bResult = FileHandle->Truncate(NewSize);
122 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
123 FILE_LOG(LogPlatformFile, Verbose, TEXT("Truncate return %d [%fms]"), int32(bResult), ThisTime);
124 return bResult;
125 }
126 virtual void ShrinkBuffers() override
127 {
128 FILE_LOG(LogPlatformFile, Verbose, TEXT("ShrinkBuffers %s"), *Filename);
129 double StartTime = FPlatformTime::Seconds();
130 FileHandle->ShrinkBuffers();
131 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
132 FILE_LOG(LogPlatformFile, Verbose, TEXT("ShrinkBuffers return [%fms]"), ThisTime);
133 }
134};
135
137{
139
143#endif
144
145public:
146 static const TCHAR* GetTypeName()
147 {
148 return TEXT("LogFile");
149 }
150
152 : LowerLevel(nullptr)
153 {
154 }
155
156 //~ For visibility of overloads we don't override
157 using IPlatformFile::IterateDirectory;
158 using IPlatformFile::IterateDirectoryRecursively;
159 using IPlatformFile::IterateDirectoryStat;
160 using IPlatformFile::IterateDirectoryStatRecursively;
161
162 virtual bool ShouldBeUsed(IPlatformFile* Inner, const TCHAR* CmdLine) const override;
163
164 virtual bool Initialize(IPlatformFile* Inner, const TCHAR* CommandLineParam) override;
165
167 {
168 return LowerLevel;
169 }
170 virtual void SetLowerLevel(IPlatformFile* NewLowerLevel) override
171 {
172 LowerLevel = NewLowerLevel;
173 }
174 virtual const TCHAR* GetName() const override
175 {
177 }
178
179 virtual bool FileExists(const TCHAR* Filename) override
180 {
181 FString DataStr = FString::Printf(TEXT("FileExists %s"), Filename);
182 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
183 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
184 double StartTime = FPlatformTime::Seconds();
185 bool Result = LowerLevel->FileExists(Filename);
186 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
187 FILE_LOG(LogPlatformFile, Log, TEXT("FileExists return %d [%fms]"), int32(Result), ThisTime);
188 return Result;
189 }
190 virtual int64 FileSize(const TCHAR* Filename) override
191 {
192 FString DataStr = FString::Printf(TEXT("FileSize %s"), Filename);
193 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
194 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
195 double StartTime = FPlatformTime::Seconds();
196 int64 Result = LowerLevel->FileSize(Filename);
197 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
198 FILE_LOG(LogPlatformFile, Log, TEXT("FileSize return %lld [%fms]"), Result, ThisTime);
199 return Result;
200 }
201 virtual bool DeleteFile(const TCHAR* Filename) override
202 {
203 FString DataStr = FString::Printf(TEXT("DeleteFile %s"), Filename);
204 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
205 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
206 double StartTime = FPlatformTime::Seconds();
207 bool Result = LowerLevel->DeleteFile(Filename);
208 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
209 FILE_LOG(LogPlatformFile, Log, TEXT("DeleteFile return %d [%fms]"), int32(Result), ThisTime);
210 return Result;
211 }
212 virtual bool IsReadOnly(const TCHAR* Filename) override
213 {
214 FString DataStr = FString::Printf(TEXT("IsReadOnly %s"), Filename);
215 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
216 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
217 double StartTime = FPlatformTime::Seconds();
218 bool Result = LowerLevel->IsReadOnly(Filename);
219 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
220 FILE_LOG(LogPlatformFile, Log, TEXT("IsReadOnly return %d [%fms]"), int32(Result), ThisTime);
221 return Result;
222 }
223 virtual bool MoveFile(const TCHAR* To, const TCHAR* From) override
224 {
225 FString DataStr = FString::Printf(TEXT("MoveFile %s %s"), To, From);
226 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
227 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
228 double StartTime = FPlatformTime::Seconds();
229 bool Result = LowerLevel->MoveFile(To, From);
230 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
231 FILE_LOG(LogPlatformFile, Log, TEXT("MoveFile return %d [%fms]"), int32(Result), ThisTime);
232 return Result;
233 }
234 virtual bool SetReadOnly(const TCHAR* Filename, bool bNewReadOnlyValue) override
235 {
236 FString DataStr = FString::Printf(TEXT("SetReadOnly %s %d"), Filename, int32(bNewReadOnlyValue));
237 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
238 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
239 double StartTime = FPlatformTime::Seconds();
240 bool Result = LowerLevel->SetReadOnly(Filename, bNewReadOnlyValue);
241 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
242 FILE_LOG(LogPlatformFile, Log, TEXT("SetReadOnly return %d [%fms]"), int32(Result), ThisTime);
243 return Result;
244 }
245 virtual FDateTime GetTimeStamp(const TCHAR* Filename) override
246 {
247 FString DataStr = FString::Printf(TEXT("GetTimeStamp %s"), Filename);
248 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
249 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
250 double StartTime = FPlatformTime::Seconds();
251 FDateTime Result = LowerLevel->GetTimeStamp(Filename);
252 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
253 FILE_LOG(LogPlatformFile, Log, TEXT("GetTimeStamp return %llx [%fms]"), Result.GetTicks(), ThisTime);
254 return Result;
255 }
256 virtual void SetTimeStamp(const TCHAR* Filename, FDateTime DateTime) override
257 {
258 FString DataStr = FString::Printf(TEXT("SetTimeStamp %s"), Filename);
259 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
260 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
261 double StartTime = FPlatformTime::Seconds();
262 LowerLevel->SetTimeStamp(Filename, DateTime);
263 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
264 FILE_LOG(LogPlatformFile, Log, TEXT("SetTimeStamp [%fms]"), ThisTime);
265 }
266 virtual FDateTime GetAccessTimeStamp(const TCHAR* Filename) override
267 {
268 FString DataStr = FString::Printf(TEXT("GetAccessTimeStamp %s"), Filename);
269 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
270 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
271 double StartTime = FPlatformTime::Seconds();
273 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
274 FILE_LOG(LogPlatformFile, Log, TEXT("GetAccessTimeStamp return %llx [%fms]"), Result.GetTicks(), ThisTime);
275 return Result;
276 }
277 virtual FString GetFilenameOnDisk(const TCHAR* Filename) override
278 {
279 FString DataStr = FString::Printf(TEXT("GetFilenameOnDisk %s"), Filename);
280 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
281 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
282 double StartTime = FPlatformTime::Seconds();
284 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
285 FILE_LOG(LogPlatformFile, Log, TEXT("GetFilenameOnDisk return %s [%fms]"), *Result, ThisTime);
286 return Result;
287 }
288 virtual IFileHandle* OpenRead(const TCHAR* Filename, bool bAllowWrite) override
289 {
290 FString DataStr = FString::Printf(TEXT("OpenRead %s"), Filename);
291 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
292 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
293 double StartTime = FPlatformTime::Seconds();
294 IFileHandle* Result = LowerLevel->OpenRead(Filename, bAllowWrite);
295 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
296 FILE_LOG(LogPlatformFile, Log, TEXT("OpenRead return %llx [%fms]"), uint64(Result), ThisTime);
297 return Result ? (new FLoggedFileHandle(Result, Filename, *this)) : Result;
298 }
299 virtual IFileHandle* OpenWrite(const TCHAR* Filename, bool bAppend = false, bool bAllowRead = false) override
300 {
301 FString DataStr = FString::Printf(TEXT("OpenWrite %s %d %d"), Filename, int32(bAppend), int32(bAllowRead));
302 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
303 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
304 double StartTime = FPlatformTime::Seconds();
305 IFileHandle* Result = LowerLevel->OpenWrite(Filename, bAppend, bAllowRead);
306 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
307 FILE_LOG(LogPlatformFile, Log, TEXT("OpenWrite return %llx [%fms]"), uint64(Result), ThisTime);
308 return Result ? (new FLoggedFileHandle(Result, Filename, *this)) : Result;
309 }
310
311 virtual bool DirectoryExists(const TCHAR* Directory) override
312 {
313 FString DataStr = FString::Printf(TEXT("DirectoryExists %s"), Directory);
314 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
315 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
316 double StartTime = FPlatformTime::Seconds();
317 bool Result = LowerLevel->DirectoryExists(Directory);
318 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
319 FILE_LOG(LogPlatformFile, Log, TEXT("DirectoryExists return %d [%fms]"), int32(Result), ThisTime);
320 return Result;
321 }
322 virtual bool CreateDirectory(const TCHAR* Directory) override
323 {
324 FString DataStr = FString::Printf(TEXT("CreateDirectory %s"), Directory);
325 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
326 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
327 double StartTime = FPlatformTime::Seconds();
328 bool Result = LowerLevel->CreateDirectory(Directory);
329 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
330 FILE_LOG(LogPlatformFile, Log, TEXT("CreateDirectory return %d [%fms]"), int32(Result), ThisTime);
331 return Result;
332 }
333 virtual bool DeleteDirectory(const TCHAR* Directory) override
334 {
335 FString DataStr = FString::Printf(TEXT("DeleteDirectory %s"), Directory);
336 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
337 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
338 double StartTime = FPlatformTime::Seconds();
339 bool Result = LowerLevel->DeleteDirectory(Directory);
340 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
341 FILE_LOG(LogPlatformFile, Log, TEXT("DeleteDirectory return %d [%fms]"), int32(Result), ThisTime);
342 return Result;
343 }
344 virtual FFileStatData GetStatData(const TCHAR* FilenameOrDirectory) override
345 {
346 FString DataStr = FString::Printf(TEXT("GetStatData %s"), FilenameOrDirectory);
347 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
348 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
349 double StartTime = FPlatformTime::Seconds();
350 FFileStatData Result = LowerLevel->GetStatData(FilenameOrDirectory);
351 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
352 FILE_LOG(LogPlatformFile, Log, TEXT("GetStatData return %d [%fms]"), int32(Result.bIsValid), ThisTime);
353 return Result;
354 }
355
357 {
358 public:
361 : Visitor(InVisitor)
362 {
363 }
364 virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) override
365 {
366 FILE_LOG(LogPlatformFile, Verbose, TEXT("Visit %s %d"), FilenameOrDirectory, int32(bIsDirectory));
367 double StartTime = FPlatformTime::Seconds();
368 bool Result = Visitor.Visit(FilenameOrDirectory, bIsDirectory);
369 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
370 FILE_LOG(LogPlatformFile, Verbose, TEXT("Visit return %d [%fms]"), int32(Result), ThisTime);
371 return Result;
372 }
373 };
374
375 virtual bool IterateDirectory(const TCHAR* Directory, IPlatformFile::FDirectoryVisitor& Visitor) override
376 {
377 FString DataStr = FString::Printf(TEXT("IterateDirectory %s"), Directory);
378 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
379 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
380 double StartTime = FPlatformTime::Seconds();
381 FLogVisitor LogVisitor(Visitor);
382 bool Result = LowerLevel->IterateDirectory(Directory, LogVisitor);
383 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
384 FILE_LOG(LogPlatformFile, Log, TEXT("IterateDirectory return %d [%fms]"), int32(Result), ThisTime);
385 return Result;
386 }
387 virtual bool IterateDirectoryRecursively(const TCHAR* Directory, IPlatformFile::FDirectoryVisitor& Visitor) override
388 {
389 FString DataStr = FString::Printf(TEXT("IterateDirectoryRecursively %s"), Directory);
390 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
391 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
392 double StartTime = FPlatformTime::Seconds();
393 FLogVisitor LogVisitor(Visitor);
394 bool Result = LowerLevel->IterateDirectoryRecursively(Directory, LogVisitor);
395 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
396 FILE_LOG(LogPlatformFile, Log, TEXT("IterateDirectoryRecursively return %d [%fms]"), int32(Result), ThisTime);
397 return Result;
398 }
399
401 {
402 public:
405 : Visitor(InVisitor)
406 {
407 }
408 virtual bool Visit(const TCHAR* FilenameOrDirectory, const FFileStatData& StatData) override
409 {
410 FILE_LOG(LogPlatformFile, Verbose, TEXT("Visit %s %d"), FilenameOrDirectory, int32(StatData.bIsDirectory));
411 double StartTime = FPlatformTime::Seconds();
412 bool Result = Visitor.Visit(FilenameOrDirectory, StatData);
413 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
414 FILE_LOG(LogPlatformFile, Verbose, TEXT("Visit return %d [%fms]"), int32(Result), ThisTime);
415 return Result;
416 }
417 };
418
419 virtual bool IterateDirectoryStat(const TCHAR* Directory, IPlatformFile::FDirectoryStatVisitor& Visitor) override
420 {
421 FString DataStr = FString::Printf(TEXT("IterateDirectoryStat %s"), Directory);
422 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
423 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
424 double StartTime = FPlatformTime::Seconds();
425 FLogStatVisitor LogVisitor(Visitor);
426 bool Result = LowerLevel->IterateDirectoryStat(Directory, LogVisitor);
427 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
428 FILE_LOG(LogPlatformFile, Log, TEXT("IterateDirectoryStat return %d [%fms]"), int32(Result), ThisTime);
429 return Result;
430 }
431 virtual bool IterateDirectoryStatRecursively(const TCHAR* Directory, IPlatformFile::FDirectoryStatVisitor& Visitor) override
432 {
433 FString DataStr = FString::Printf(TEXT("IterateDirectoryStatRecursively %s"), Directory);
434 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
435 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
436 double StartTime = FPlatformTime::Seconds();
437 FLogStatVisitor LogVisitor(Visitor);
438 bool Result = LowerLevel->IterateDirectoryStatRecursively(Directory, LogVisitor);
439 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
440 FILE_LOG(LogPlatformFile, Log, TEXT("IterateDirectoryStatRecursively return %d [%fms]"), int32(Result), ThisTime);
441 return Result;
442 }
443
444 virtual bool DeleteDirectoryRecursively(const TCHAR* Directory) override
445 {
446 FString DataStr = FString::Printf(TEXT("DeleteDirectoryRecursively %s"), Directory);
447 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
448 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
449 double StartTime = FPlatformTime::Seconds();
450 bool Result = LowerLevel->DeleteDirectoryRecursively(Directory);
451 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
452 FILE_LOG(LogPlatformFile, Log, TEXT("DeleteDirectoryRecursively return %d [%fms]"), int32(Result), ThisTime);
453 return Result;
454 }
455 virtual bool CopyFile(const TCHAR* To, const TCHAR* From, EPlatformFileRead ReadFlags = EPlatformFileRead::None, EPlatformFileWrite WriteFlags = EPlatformFileWrite::None) override
456 {
457 FString DataStr = FString::Printf(TEXT("CopyFile %s %s"), To, From);
458 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
459 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
460 double StartTime = FPlatformTime::Seconds();
461 bool Result = LowerLevel->CopyFile(To, From, ReadFlags, WriteFlags);
462 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
463 FILE_LOG(LogPlatformFile, Log, TEXT("CopyFile return %d [%fms]"), int32(Result), ThisTime);
464 return Result;
465 }
466
469 {
473 }
475 {
478 if (--NumOpenHandles == 0)
479 {
481 }
482 }
484#endif
485 virtual IAsyncReadFileHandle* OpenAsyncRead(const TCHAR* Filename) override
486 {
487 FString DataStr = FString::Printf(TEXT("OpenAsyncRead %s"), Filename);
488 SCOPED_NAMED_EVENT_FSTRING(DataStr, FColor::Emerald);
489 FILE_LOG(LogPlatformFile, Log, TEXT("%s"), *DataStr);
490 double StartTime = FPlatformTime::Seconds();
491 IAsyncReadFileHandle* Result = LowerLevel->OpenAsyncRead(Filename);
492 double ThisTime = (FPlatformTime::Seconds() - StartTime) / 1000.0;
493 FILE_LOG(LogPlatformFile, Log, TEXT("OpenAsyncRead return %llx [%fms]"), uint64(Result), ThisTime);
494 //@todo no wrapped logging for async file handles (yet)
495 return Result;
496 }
497 virtual IMappedFileHandle* OpenMapped(const TCHAR* Filename) override
498 {
499 return LowerLevel->OpenMapped(Filename);
500 }
501 virtual void SetAsyncMinimumPriority(EAsyncIOPriorityAndFlags Priority) override
502 {
504 }
505
506};
#define UE_BUILD_SHIPPING
Definition Build.h:4
EAsyncIOPriorityAndFlags
Definition Enums.h:5594
DECLARE_LOG_CATEGORY_EXTERN(LogChunkInstaller, Log, All)
EPlatformFileRead
EPlatformFileWrite
bool bSuppressFileLog
#define FILE_LOG(CategoryName, Verbosity, Format,...)
#define TEXT(x)
Definition Platform.h:1108
#define SCOPED_NAMED_EVENT_FSTRING(Text, Color)
FWindowsPlatformTime FPlatformTime
virtual bool Read(uint8 *Destination, int64 BytesToRead) override
virtual int64 Tell() override
virtual ~FLoggedFileHandle()
virtual bool SeekFromEnd(int64 NewPositionRelativeToEnd) override
virtual bool Flush(const bool bFullFlush=false) override
FLoggedFileHandle(IFileHandle *InFileHandle, const TCHAR *InFilename, FLoggedPlatformFile &InOwner)
virtual bool Write(const uint8 *Source, int64 BytesToWrite) override
virtual void ShrinkBuffers() override
virtual bool Truncate(int64 NewSize) override
virtual int64 Size() override
TUniquePtr< IFileHandle > FileHandle
virtual bool Seek(int64 NewPosition) override
FLogStatVisitor(FDirectoryStatVisitor &InVisitor)
virtual bool Visit(const TCHAR *FilenameOrDirectory, const FFileStatData &StatData) override
virtual bool Visit(const TCHAR *FilenameOrDirectory, bool bIsDirectory) override
FLogVisitor(FDirectoryVisitor &InVisitor)
static const TCHAR * GetTypeName()
IPlatformFile * GetLowerLevel() override
virtual FDateTime GetTimeStamp(const TCHAR *Filename) override
virtual FString GetFilenameOnDisk(const TCHAR *Filename) override
virtual void SetAsyncMinimumPriority(EAsyncIOPriorityAndFlags Priority) override
virtual const TCHAR * GetName() const override
virtual FFileStatData GetStatData(const TCHAR *FilenameOrDirectory) override
virtual bool DeleteDirectory(const TCHAR *Directory) override
virtual bool IsReadOnly(const TCHAR *Filename) override
virtual bool IterateDirectory(const TCHAR *Directory, IPlatformFile::FDirectoryVisitor &Visitor) override
virtual bool DeleteDirectoryRecursively(const TCHAR *Directory) override
virtual bool IterateDirectoryRecursively(const TCHAR *Directory, IPlatformFile::FDirectoryVisitor &Visitor) override
virtual bool SetReadOnly(const TCHAR *Filename, bool bNewReadOnlyValue) override
virtual bool IterateDirectoryStatRecursively(const TCHAR *Directory, IPlatformFile::FDirectoryStatVisitor &Visitor) override
virtual bool IterateDirectoryStat(const TCHAR *Directory, IPlatformFile::FDirectoryStatVisitor &Visitor) override
virtual bool FileExists(const TCHAR *Filename) override
virtual IFileHandle * OpenWrite(const TCHAR *Filename, bool bAppend=false, bool bAllowRead=false) override
virtual IAsyncReadFileHandle * OpenAsyncRead(const TCHAR *Filename) override
virtual FDateTime GetAccessTimeStamp(const TCHAR *Filename) override
virtual void SetTimeStamp(const TCHAR *Filename, FDateTime DateTime) override
virtual IMappedFileHandle * OpenMapped(const TCHAR *Filename) override
virtual void SetLowerLevel(IPlatformFile *NewLowerLevel) override
virtual int64 FileSize(const TCHAR *Filename) override
virtual bool ShouldBeUsed(IPlatformFile *Inner, const TCHAR *CmdLine) const override
virtual bool Initialize(IPlatformFile *Inner, const TCHAR *CommandLineParam) override
virtual IFileHandle * OpenRead(const TCHAR *Filename, bool bAllowWrite) override
virtual bool DirectoryExists(const TCHAR *Directory) override
virtual bool Visit(const TCHAR *FilenameOrDirectory, const FFileStatData &StatData)=0
virtual bool Visit(const TCHAR *FilenameOrDirectory, bool bIsDirectory)=0
virtual IFileHandle * OpenWrite(const TCHAR *Filename, bool bAppend=false, bool bAllowRead=false)=0
virtual FFileStatData GetStatData(const TCHAR *FilenameOrDirectory)=0
virtual bool DeleteDirectoryRecursively(const TCHAR *Directory)
virtual IMappedFileHandle * OpenMapped(const TCHAR *Filename)
virtual bool IterateDirectoryStat(const TCHAR *Directory, FDirectoryStatVisitor &Visitor)=0
virtual IFileHandle * OpenRead(const TCHAR *Filename, bool bAllowWrite=false)=0
virtual void SetAsyncMinimumPriority(EAsyncIOPriorityAndFlags MinPriority)
virtual bool IterateDirectory(const TCHAR *Directory, FDirectoryVisitor &Visitor)=0
virtual bool IterateDirectoryStatRecursively(const TCHAR *Directory, FDirectoryStatVisitor &Visitor)
virtual bool IsReadOnly(const TCHAR *Filename)=0
virtual bool DeleteDirectory(const TCHAR *Directory)=0
virtual void SetTimeStamp(const TCHAR *Filename, FDateTime DateTime)=0
virtual bool DirectoryExists(const TCHAR *Directory)=0
virtual bool IterateDirectoryRecursively(const TCHAR *Directory, FDirectoryVisitor &Visitor)
virtual bool SetReadOnly(const TCHAR *Filename, bool bNewReadOnlyValue)=0
virtual IAsyncReadFileHandle * OpenAsyncRead(const TCHAR *Filename)
virtual bool FileExists(const TCHAR *Filename)=0
virtual int64 FileSize(const TCHAR *Filename)=0
virtual FString GetFilenameOnDisk(const TCHAR *Filename)=0
virtual FDateTime GetTimeStamp(const TCHAR *Filename)=0
virtual FDateTime GetAccessTimeStamp(const TCHAR *Filename)=0
static FORCEINLINE double Seconds()