Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Resources/Font/DroidSansMono.ttf
Binary file not shown.
Binary file added Resources/UI/DeleteFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/Excute_x40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/FolderClosed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/FolderOpen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/GenericFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/PythonEditor_16x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/SaveAll_40x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/Save_40x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/TextBlockHighlightShape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/UI/TextEditorBorder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions Source/PythonEditor/Private/DirectoryScanner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "PythonEditorPrivatePCH.h"
#include "DirectoryScanner.h"
#include "PythonProjectItem.h"

TArray<FDirectoryScannerCommand*> FDirectoryScanner::CommandQueue;

struct FDirectoryResult
{
FDirectoryResult(const FString& InPathName, EPythonProjectItemType::Type InType)
: PathName(InPathName)
, Type(InType)
{
}

FString PathName;

EPythonProjectItemType::Type Type;
};

struct FDirectoryScannerCommand : public IQueuedWork
{
FDirectoryScannerCommand(const FString& InPathName, const FOnDirectoryScanned& InOnDirectoryScanned)
: PathName(InPathName)
, OnDirectoryScanned(InOnDirectoryScanned)
, bExecuted(0)
{
}

/** Begin FQueuedWork interface */
virtual void Abandon() override
{
FPlatformAtomics::InterlockedExchange(&bExecuted, 1);
}

virtual void DoThreadedWork() override
{
class FDirectoryEnumerator : public IPlatformFile::FDirectoryVisitor
{
public:
FDirectoryEnumerator(TLockFreePointerListUnordered<FDirectoryResult, PLATFORM_CACHE_LINE_SIZE>& InFoundFiles)
: FoundFiles(InFoundFiles)
{
}

virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) override
{
if(bIsDirectory)
{
FoundFiles.Push(new FDirectoryResult(FilenameOrDirectory, EPythonProjectItemType::Folder));
}
else
{
FoundFiles.Push(new FDirectoryResult(FilenameOrDirectory, EPythonProjectItemType::File));
}

return true;
}

TLockFreePointerListUnordered<FDirectoryResult, PLATFORM_CACHE_LINE_SIZE>& FoundFiles;
};

FDirectoryEnumerator DirectoryEnumerator(FoundFiles);
IPlatformFile& PlatformFile = IPlatformFile::GetPlatformPhysical();
PlatformFile.IterateDirectory(*PathName, DirectoryEnumerator);

FPlatformAtomics::InterlockedExchange(&bExecuted, 1);
}
/** End FQueuedWork interface */

FString PathName;

FOnDirectoryScanned OnDirectoryScanned;

TLockFreePointerListUnordered<FDirectoryResult, PLATFORM_CACHE_LINE_SIZE> FoundFiles;

volatile int32 bExecuted;
};


bool FDirectoryScanner::Tick()
{
bool bAddedData = false;
for (int32 CommandIndex = 0; CommandIndex < CommandQueue.Num(); ++CommandIndex)
{
FDirectoryScannerCommand& Command = *CommandQueue[CommandIndex];
Command.DoThreadedWork();
if (Command.bExecuted)
{
while(!Command.FoundFiles.IsEmpty())
{
FDirectoryResult* DirectoryResult = Command.FoundFiles.Pop();
Command.OnDirectoryScanned.ExecuteIfBound(DirectoryResult->PathName, DirectoryResult->Type);
delete DirectoryResult;
bAddedData = true;
}

// Remove command from the queue & delete it, we are done for this tick
CommandQueue.RemoveAt(CommandIndex);
delete &Command;
break;
}
}

return bAddedData;
}

void FDirectoryScanner::AddDirectory(const FString& PathName, const FOnDirectoryScanned& OnDirectoryScanned)
{
FDirectoryScannerCommand* NewCommand = new FDirectoryScannerCommand(PathName, OnDirectoryScanned);
CommandQueue.Add(NewCommand);
//GThreadPool->AddQueuedWork(NewCommand);
}

bool FDirectoryScanner::IsScanning()
{
return CommandQueue.Num() > 0;
}
22 changes: 22 additions & 0 deletions Source/PythonEditor/Private/DirectoryScanner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "PythonProjectItem.h"

DECLARE_DELEGATE_TwoParams(FOnDirectoryScanned, const FString& /*InPathName*/, EPythonProjectItemType::Type /*InType*/);

class FDirectoryScanner
{
public:
static bool Tick();

static void AddDirectory(const FString& PathName, const FOnDirectoryScanned& OnDirectoryScanned);

static bool IsScanning() ;

public:
static TArray<struct FDirectoryScannerCommand*> CommandQueue;

static bool bDataDirty;
};
Loading