Files
UnrealEngineUWP/Engine/Source/Developer/CQTest/Private/TestDirectoryGenerator.cpp
sebastian lewicki 695acb1980 Upgrading the CQTest plugin to an Engine module
Introducing the CQTestEnhancedInput plugin as this requires use of the EnhancedInput Engine Plugin (Engine modules cannot make use of the Engine Plugin)
#jira UE-217806
#rb Devin.Doucette, Jerome.Delattre, rob.huyett, sean.sweeney

[CL 36039088 by sebastian lewicki in ue5-main branch]
2024-09-05 10:24:20 -04:00

63 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Misc/App.h"
#include "Misc/Paths.h"
namespace TestDirectoryGenerator
{
void SplitPath(const FString& Path, FString* Lhs, FString* Rhs, FString* SourceType)
{
static const FString Plugins = TEXT("/Plugins/");
static const FString Platforms = TEXT("/Platforms/");
static const FString Source = TEXT("/Source/");
static const FString Slash = TEXT("/");
FString SplitString = Source;
if (Path.Find(Plugins) != INDEX_NONE)
{
Path.Split(Plugins, Lhs, Rhs);
*SourceType = TEXT("Plugins");
}
else if (Path.Find(Platforms) != INDEX_NONE)
{
Path.Split(Platforms, Lhs, Rhs);
*SourceType = TEXT("Platforms");
}
else if (Path.Find(Source) != INDEX_NONE)
{
Path.Split(Source, Lhs, Rhs);
*SourceType = TEXT("Source");
SplitString = Slash;
}
else
{
checkf(false, TEXT("%s Should contain Plugins, Platforms, or Source"), *Path);
*Lhs = TEXT("Unknown");
*Rhs = TEXT("Unknown");
*SourceType = TEXT("Unknown");
return;
}
Lhs->Split(Slash, nullptr, Lhs, ESearchCase::CaseSensitive, ESearchDir::FromEnd);
if (Lhs->IsEmpty())
{
*Lhs = TEXT("Unknown");
}
Rhs->Split(SplitString, Rhs, nullptr);
if (Rhs->IsEmpty())
{
*Rhs = TEXT("Unknown");
}
}
CQTEST_API FString Generate(const FString& Filename)
{
static const FString Engine = TEXT("Engine/");
const FString Path(Filename.Replace(TEXT("\\"), TEXT("/"), ESearchCase::CaseSensitive).Replace(TEXT("../"), *Engine, ESearchCase::CaseSensitive));
FString Before, After, SourceType;
SplitPath(Path, &Before, &After, &SourceType);
After = After.Replace(TEXT("/"), TEXT("."));
return FString::Printf(TEXT("%s.%s.%s"), *Before, *SourceType, *After);
}
}