EHS/src/io/Directory_LNX.cpp

29 lines
470 B
C++
Raw Normal View History

#include "ehs/io/Directory_LNX.h"
#include "ehs/Log.h"
#include <dirent.h>
namespace ehs
{
Array<Str_8> Directory::GetAllFiles(const Str_8& dir)
{
Array<Str_8> result;
DIR* hdl = opendir(dir);
if (!dir)
{
EHS_LOG_INT("Error", 0, "Failed to open directory, \"" + dir + "\".");
return result;
}
dirent* entry;
while ((entry = readdir(hdl)))
if (entry->d_type == DT_REG)
result.Push(entry->d_name);
closedir(hdl);
return result;
}
}