You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
AssetDefinition - Changing how getting the SourceFiles works a bit, wanted it to be easier to just get the real data and not have to wrap it myself, and also to not need to needlessly put it into a container if it's not needed. #jira UE-165574 [CL 23686064 by nick darnell in ue5-main branch]
58 lines
2.0 KiB
C++
58 lines
2.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "FindSourceFileInExplorer.h"
|
|
#include "Misc/Paths.h"
|
|
#include "HAL/PlatformProcess.h"
|
|
|
|
namespace UE::AssetTools
|
|
{
|
|
void ExecuteFindSourceFileInExplorer(TArray<FString> Filenames, TArray<FString> OverrideExtensions)
|
|
{
|
|
for (TArray<FString>::TConstIterator FilenameIter(Filenames); FilenameIter; ++FilenameIter)
|
|
{
|
|
const FString CSVFilename = FPaths::ConvertRelativePathToFull(*FilenameIter);
|
|
const FString RootPath = FPaths::GetPath(CSVFilename);
|
|
const FString BaseFilename = FPaths::GetBaseFilename(CSVFilename, true);
|
|
|
|
for (TArray<FString>::TConstIterator ExtensionItr(OverrideExtensions); ExtensionItr; ++ExtensionItr)
|
|
{
|
|
const FString FilenameWithExtension(FString::Printf(TEXT("%s/%s%s"), *RootPath, *BaseFilename, **ExtensionItr));
|
|
|
|
if (!FilenameWithExtension.IsEmpty() && FPaths::FileExists(*FilenameWithExtension))
|
|
{
|
|
FPlatformProcess::LaunchFileInDefaultExternalApplication(*FilenameWithExtension, nullptr, ELaunchVerb::Edit);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool CanExecuteFindSourceFileInExplorer(TArray<FString> Filenames, TArray<FString> OverrideExtensions)
|
|
{
|
|
// Verify that extensions were provided
|
|
if (OverrideExtensions.Num() == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Verify that the file exists with any of the given extensions
|
|
for (TArray<FString>::TConstIterator FilenameIter(Filenames); FilenameIter; ++FilenameIter)
|
|
{
|
|
const FString CSVFilename = FPaths::ConvertRelativePathToFull(*FilenameIter);
|
|
const FString RootPath = FPaths::GetPath(CSVFilename);
|
|
const FString BaseFilename = FPaths::GetBaseFilename(CSVFilename, true);
|
|
|
|
for (TArray<FString>::TConstIterator ExtensionItr(OverrideExtensions); ExtensionItr; ++ExtensionItr)
|
|
{
|
|
const FString FilenameWithExtension(FString::Printf(TEXT("%s/%s%s"), *RootPath, *BaseFilename, **ExtensionItr));
|
|
|
|
if (!FilenameWithExtension.IsEmpty() && FPaths::FileExists(*FilenameWithExtension))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |