Added GetAllFiles to filesystem
This commit is contained in:
@@ -64,6 +64,34 @@ bool FileSystem::FileExists(const std::string& path, bool absolute)
|
||||
return std::filesystem::exists(fullPath) && std::filesystem::is_regular_file(fullPath);
|
||||
}
|
||||
|
||||
std::vector<Ref<File>> FileSystem::GetAllFiles(const FileType fileType)
|
||||
{
|
||||
std::vector<Ref<File>> foundFiles;
|
||||
|
||||
std::function<void(Ref<Directory>)> scanDir;
|
||||
scanDir = [scanDir, &foundFiles, fileType](Ref<Directory> dir)
|
||||
{
|
||||
// All the files matching the filetype
|
||||
for (auto& f : dir->Files)
|
||||
{
|
||||
if (f->GetFileType() == fileType)
|
||||
{
|
||||
foundFiles.push_back(f);
|
||||
}
|
||||
}
|
||||
|
||||
// Scan sub folder
|
||||
for (auto& d : dir->Directories)
|
||||
{
|
||||
scanDir(d);
|
||||
}
|
||||
};
|
||||
|
||||
scanDir(RootDirectory);
|
||||
|
||||
return foundFiles;
|
||||
}
|
||||
|
||||
void FileSystem::SetRootDirectory(const std::string path)
|
||||
{
|
||||
Root = path;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "src/Core/Core.h"
|
||||
#include "FileTypes.h"
|
||||
|
||||
namespace filewatch
|
||||
{
|
||||
@@ -35,6 +36,7 @@ namespace Nuake
|
||||
static bool MakeDirectory(const std::string& path, bool absolute = false);
|
||||
static bool DirectoryExists(const std::string& path, bool absolute = false);
|
||||
static bool FileExists(const std::string& path, bool absolute = false);
|
||||
static std::vector<Ref<File>> GetAllFiles(const FileType fileType);
|
||||
|
||||
static std::string ReadFile(const std::string& path, bool absolute = false);
|
||||
static void CopyFileAbsolute(const std::string& src, const std::string& dest);
|
||||
|
||||
Reference in New Issue
Block a user