MCPcopy Create free account
hub / github.com/Tencent/UnLua / GetFullPathFromRelativePath

Function GetFullPathFromRelativePath

Plugins/UnLua/Source/UnLua/Private/LuaCore.cpp:49–72  ·  view source on GitHub ↗

* Get lua file full path from relative path */

Source from the content-addressed store, hash-verified

47 * Get lua file full path from relative path
48 */
49FString GetFullPathFromRelativePath(const FString& RelativePath)
50{
51 FString FullFilePath = GLuaSrcFullPath + RelativePath;
52 FString ProjectDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
53 FString ProjectPersistentDownloadDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectPersistentDownloadDir());
54 if (!ProjectPersistentDownloadDir.EndsWith("/"))
55 {
56 ProjectPersistentDownloadDir.Append("/");
57 }
58
59 FString RealFullFilePath = FullFilePath.Replace(*ProjectDir, *ProjectPersistentDownloadDir); // try to load the file from 'ProjectPersistentDownloadDir' first
60 if (IFileManager::Get().FileExists(*RealFullFilePath))
61 {
62 FullFilePath = RealFullFilePath;
63 }
64 else
65 {
66 if (!IFileManager::Get().FileExists(*FullFilePath))
67 {
68 FullFilePath = "";
69 }
70 }
71 return FullFilePath;
72}
73
74/**
75 * Set the name for a Lua table which on the top of the stack

Callers 1

LoadFileFunction · 0.85

Calls 2

GetFunction · 0.50
AppendMethod · 0.45

Tested by

no test coverage detected