Skip to content

Commit db2d9d5

Browse files
author
liu
committed
move PythonLib directory parent directory
1 parent 535c167 commit db2d9d5

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

‎Source/UnrealEnginePython/Private/UnrealEnginePython.cpp‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ void FUnrealEnginePythonModule::StartupModule()
474474
init_unreal_engine_builtin();
475475
#if PLATFORM_ANDROID
476476
FString InDirectory = FString(TEXT("Scripts"));
477+
FString InDirectory1 = FString(TEXT("PythonLib"));
478+
FString InDirectory2 = FString(TEXT("PythonLib/python3.11"));
479+
FString InDirectory3 = FString(TEXT("PythonLib/python3.11/site-packages"));
477480

478481
extern FString GExternalFilePath;
479482

@@ -503,14 +506,37 @@ void FUnrealEnginePythonModule::StartupModule()
503506
if (FFileHelper::LoadFileToArray(MemFile, *SourceFilename, 0))
504507
{
505508
FString DestFilename = GExternalFilePath / InDirectory / Path;
509+
UE_LOG(LogPython, Warning, TEXT("Script DestFilename %s"), *DestFilename);
510+
511+
FFileHelper::SaveArrayToFile(MemFile, *DestFilename);
512+
}
513+
}
514+
515+
FString DirectoryPath1 = FPaths::ProjectContentDir() / InDirectory1;
516+
FileManager->IterateDirectoryRecursively(*DirectoryPath1, Visitor);
517+
FString Prefix2 = FApp::GetProjectName() / FString(TEXT("Content/PythonLib/"));
518+
519+
for (TMap<FString, FDateTime>::TIterator TimestampIt(Visitor.FileTimes); TimestampIt; ++TimestampIt)
520+
{
521+
FString Path = TimestampIt.Key();
522+
523+
Path.RemoveFromStart(Prefix2);
524+
525+
// read the file contents and write it if successful to external path
526+
TArray<uint8> MemFile;
527+
528+
const FString SourceFilename = TimestampIt.Key();
529+
530+
if (FFileHelper::LoadFileToArray(MemFile, *SourceFilename, 0))
531+
{
532+
FString DestFilename = GExternalFilePath / InDirectory1 / Path;
533+
UE_LOG(LogPython, Warning, TEXT("Python DestFilename %s"), *DestFilename);
506534

507535
FFileHelper::SaveArrayToFile(MemFile, *DestFilename);
508536
}
509537
}
510538

511539
FString PyScriptsSearchPath = GExternalFilePath / InDirectory;
512-
FString InDirectory2 = FString(TEXT("Scripts/lib/python3.11"));
513-
FString InDirectory3 = FString(TEXT("Scripts/lib/python3.11/site-packages"));
514540
FString PyScriptsSearchPath2 = GExternalFilePath / InDirectory2;
515541
FString PyScriptsSearchPath3 = GExternalFilePath / InDirectory3;
516542

0 commit comments

Comments
 (0)