Skip to content

Commit

Permalink
feat: fetch es files from Data/
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Nov 17, 2021
1 parent e4ec55a commit 39bfed8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
14 changes: 6 additions & 8 deletions Code/es_loader/ESLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include "ESLoader.h"

#include <filesystem>
namespace fs = std::filesystem;

ESLoader::ESLoader(String aDirectory)
: m_directory(std::move(aDirectory))
{
}

bool ESLoader::BuildFileList()
{
DEBUG_BREAK;

if (!FindFiles())
return false;

Expand All @@ -20,19 +21,16 @@ bool ESLoader::BuildFileList()

bool ESLoader::FindFiles()
{
DEBUG_BREAK;

if (m_directory.empty())
{
spdlog::error("Directory string is empty.");
return false;
}

// TODO: traverse files in directory
Vector<String> files;

for (String filename : files)
for (const auto& entry : fs::directory_iterator(m_directory))
{
String filename = entry.path().filename().string().c_str();

const char* fileExtension = strrchr(filename.c_str(), '.');
if (!fileExtension)
{
Expand Down
4 changes: 2 additions & 2 deletions Code/es_loader/ESLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class ESLoader

bool BuildFileList();

private:
//private:
bool FindFiles();
bool SortPlugins();

private:
//private:
String m_directory;
Vector<String> m_esmFilenames;
Vector<String> m_espFilenames;
Expand Down
20 changes: 19 additions & 1 deletion Code/es_loader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

int main(int argc, char** argv)
{
ESLoader loader("game_files");
ESLoader loader("Data\\");
if (!loader.BuildFileList())
{
spdlog::error("Failed to build file list.");
Expand All @@ -11,6 +11,24 @@ int main(int argc, char** argv)

spdlog::info("Build file list succeeded.");

spdlog::info("ESM filenames:");
for (auto esmFilename : loader.m_esmFilenames)
{
spdlog::info("\t{}", esmFilename);
}

spdlog::info("ESP filenames:");
for (auto espFilename : loader.m_espFilenames)
{
spdlog::info("\t{}", espFilename);
}

spdlog::info("ESL filenames:");
for (auto eslFilename : loader.m_eslFilenames)
{
spdlog::info("\t{}", eslFilename);
}

return 0;
}

0 comments on commit 39bfed8

Please sign in to comment.