Files
UnrealEngineUWP/Engine/Source/Editor/AddContentDialog/Private/ContentSourceProviders/FeaturePack/FeaturePackContentSourceProvider.cpp
2014-11-07 13:16:53 -05:00

53 lines
1.4 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "AddContentDialogPCH.h"
#include "FeaturePackContentSourceProvider.h"
#include "FeaturePackContentSource.h"
class FFillArrayDirectoryVisitor : public IPlatformFile::FDirectoryVisitor
{
public:
virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) override
{
if (bIsDirectory)
{
Directories.Add(FilenameOrDirectory);
}
else
{
Files.Add(FilenameOrDirectory);
}
return true;
}
TArray<FString> Directories;
TArray<FString> Files;
};
FFeaturePackContentSourceProvider::FFeaturePackContentSourceProvider()
{
//TODO: Add a directory watcher?
FString FeaturePackPath = FPaths::Combine(*FPaths::RootDir(), TEXT("FeaturePacks"), TEXT("Packed"));
IPlatformFile &PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FFillArrayDirectoryVisitor DirectoryVisitor;
PlatformFile.IterateDirectory(*FeaturePackPath, DirectoryVisitor);
for (auto FeaturePackFile : DirectoryVisitor.Files)
{
ContentSources.Add(MakeShareable(new FFeaturePackContentSource(FeaturePackFile)));
}
}
const TArray<TSharedRef<IContentSource>> FFeaturePackContentSourceProvider::GetContentSources()
{
return ContentSources;
}
void FFeaturePackContentSourceProvider::SetContentSourcesChanged(FOnContentSourcesChanged OnContentSourcesChangedIn)
{
OnContentSourcesChanged = OnContentSourcesChangedIn;
}
FFeaturePackContentSourceProvider::~FFeaturePackContentSourceProvider()
{
}