2016-03-04 23:02:44 +00:00
|
|
|
#include "hecl/hecl.hpp"
|
2019-08-24 19:27:05 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2016-08-12 02:33:03 +00:00
|
|
|
#include <mutex>
|
2019-08-24 19:27:05 +00:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <thread>
|
2016-08-12 02:33:03 +00:00
|
|
|
#include <unordered_map>
|
2015-07-06 01:35:08 +00:00
|
|
|
|
2016-01-02 02:27:17 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#ifndef _WIN32_IE
|
|
|
|
#define _WIN32_IE 0x0400
|
|
|
|
#endif
|
|
|
|
#include <shlobj.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
#include <mntent.h>
|
2017-02-26 02:42:57 +00:00
|
|
|
#include <sys/wait.h>
|
2016-01-02 02:27:17 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-24 19:27:05 +00:00
|
|
|
#include <logvisor/logvisor.hpp>
|
|
|
|
|
2019-10-01 07:23:35 +00:00
|
|
|
using namespace std::literals;
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
namespace hecl {
|
2015-08-06 19:10:12 +00:00
|
|
|
unsigned VerbosityLevel = 0;
|
2017-12-16 02:13:20 +00:00
|
|
|
bool GuiMode = false;
|
2016-03-04 23:02:44 +00:00
|
|
|
logvisor::Module LogModule("hecl");
|
2021-06-30 20:27:53 +00:00
|
|
|
constexpr std::string_view Illegals = R"(<>?")";
|
2015-08-05 01:54:35 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
void SanitizePath(std::string& path) {
|
|
|
|
if (path.empty())
|
|
|
|
return;
|
|
|
|
path.erase(std::remove(path.begin(), path.end(), '\n'), path.end());
|
|
|
|
path.erase(std::remove(path.begin(), path.end(), '\r'), path.end());
|
|
|
|
std::string::iterator p1 = path.begin();
|
|
|
|
bool ic = false;
|
|
|
|
std::transform(path.begin(), path.end(), path.begin(), [&](const char a) -> char {
|
|
|
|
++p1;
|
|
|
|
if (Illegals.find_first_of(a) != std::string::npos) {
|
|
|
|
ic = false;
|
|
|
|
return '_';
|
|
|
|
}
|
2015-11-11 08:41:25 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
if (ic) {
|
|
|
|
ic = false;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
if (a == '\\' && (p1 == path.end() || *p1 != '\\')) {
|
|
|
|
ic = true;
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
return a;
|
|
|
|
});
|
|
|
|
while (path.back() == '/')
|
|
|
|
path.pop_back();
|
2015-08-05 01:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string GetcwdStr() {
|
2018-12-08 05:18:42 +00:00
|
|
|
/* http://stackoverflow.com/a/2869667 */
|
|
|
|
// const size_t ChunkSize=255;
|
|
|
|
// const int MaxChunks=10240; // 2550 KiBs of current path are more than enough
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
char stackBuffer[255]; // Stack buffer for the "normal" case
|
2019-08-24 19:54:37 +00:00
|
|
|
if (Getcwd(stackBuffer, int(std::size(stackBuffer))) != nullptr) {
|
2021-06-30 18:20:45 +00:00
|
|
|
return std::string(stackBuffer);
|
2019-08-24 19:54:37 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
if (errno != ERANGE) {
|
|
|
|
// It's not ERANGE, so we don't know how to handle it
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Fatal, FMT_STRING("Cannot determine the current path."));
|
2018-12-08 05:18:42 +00:00
|
|
|
// Of course you may choose a different error reporting method
|
|
|
|
}
|
|
|
|
// Ok, the stack buffer isn't long enough; fallback to heap allocation
|
|
|
|
for (int chunks = 2; chunks < 10240; chunks++) {
|
|
|
|
// With boost use scoped_ptr; in C++0x, use unique_ptr
|
|
|
|
// If you want to be less C++ but more efficient you may want to use realloc
|
2019-08-24 19:54:37 +00:00
|
|
|
const int bufSize = 255 * chunks;
|
2021-06-30 18:20:45 +00:00
|
|
|
std::unique_ptr<char[]> cwd(new char[bufSize]);
|
2019-08-24 19:54:37 +00:00
|
|
|
if (Getcwd(cwd.get(), bufSize) != nullptr) {
|
2021-06-30 18:20:45 +00:00
|
|
|
return std::string(cwd.get());
|
2019-08-24 19:54:37 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
if (errno != ERANGE) {
|
|
|
|
// It's not ERANGE, so we don't know how to handle it
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Fatal, FMT_STRING("Cannot determine the current path."));
|
2018-12-08 05:18:42 +00:00
|
|
|
// Of course you may choose a different error reporting method
|
2018-05-25 06:34:58 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
2021-06-30 18:20:45 +00:00
|
|
|
LogModule.report(logvisor::Fatal,
|
|
|
|
FMT_STRING("Cannot determine the current path; the path is apparently unreasonably long"));
|
|
|
|
return std::string();
|
2018-05-25 06:34:58 +00:00
|
|
|
}
|
|
|
|
|
2016-08-12 02:33:03 +00:00
|
|
|
static std::mutex PathsMutex;
|
|
|
|
static std::unordered_map<std::thread::id, ProjectPath> PathsInProgress;
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
bool ResourceLock::InProgress(const ProjectPath& path) {
|
2019-08-21 21:01:00 +00:00
|
|
|
std::unique_lock lk{PathsMutex};
|
2019-08-24 19:32:15 +00:00
|
|
|
return std::any_of(PathsInProgress.cbegin(), PathsInProgress.cend(),
|
|
|
|
[&path](const auto& entry) { return entry.second == path; });
|
2016-08-12 02:33:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
bool ResourceLock::SetThreadRes(const ProjectPath& path) {
|
2019-08-21 21:01:00 +00:00
|
|
|
std::unique_lock lk{PathsMutex};
|
2019-08-24 19:36:35 +00:00
|
|
|
if (PathsInProgress.find(std::this_thread::get_id()) != PathsInProgress.cend()) {
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Fatal, FMT_STRING("multiple resource locks on thread"));
|
2019-08-24 19:36:35 +00:00
|
|
|
}
|
2016-08-12 02:33:03 +00:00
|
|
|
|
2019-08-24 19:36:35 +00:00
|
|
|
const bool isInProgress = std::any_of(PathsInProgress.cbegin(), PathsInProgress.cend(),
|
|
|
|
[&path](const auto& entry) { return entry.second == path; });
|
|
|
|
if (isInProgress) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-12 02:33:03 +00:00
|
|
|
|
2019-08-24 19:36:35 +00:00
|
|
|
PathsInProgress.insert_or_assign(std::this_thread::get_id(), path);
|
2018-12-08 05:18:42 +00:00
|
|
|
return true;
|
2016-08-12 02:33:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
void ResourceLock::ClearThreadRes() {
|
2019-08-21 21:01:00 +00:00
|
|
|
std::unique_lock lk{PathsMutex};
|
2018-12-08 05:18:42 +00:00
|
|
|
PathsInProgress.erase(std::this_thread::get_id());
|
2016-08-12 02:33:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
bool IsPathPNG(const hecl::ProjectPath& path) {
|
2021-06-30 18:20:45 +00:00
|
|
|
const auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), "rb");
|
2019-08-21 23:33:25 +00:00
|
|
|
if (fp == nullptr) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return false;
|
2019-08-21 23:33:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
uint32_t buf = 0;
|
2019-08-21 23:33:25 +00:00
|
|
|
if (std::fread(&buf, 1, sizeof(buf), fp.get()) != sizeof(buf)) {
|
2015-10-01 00:40:06 +00:00
|
|
|
return false;
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
2019-08-21 23:33:25 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
buf = hecl::SBig(buf);
|
2019-08-21 23:33:25 +00:00
|
|
|
return buf == 0x89504e47;
|
2015-10-01 00:40:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
bool IsPathBlend(const hecl::ProjectPath& path) {
|
2019-08-21 23:33:25 +00:00
|
|
|
const auto lastCompExt = path.getLastComponentExt();
|
2021-06-30 18:20:45 +00:00
|
|
|
if (lastCompExt.empty() || lastCompExt != "blend")
|
2018-12-08 05:18:42 +00:00
|
|
|
return false;
|
2019-08-21 23:33:25 +00:00
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
const auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), "rb");
|
2019-08-21 23:33:25 +00:00
|
|
|
if (fp == nullptr) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return false;
|
2019-08-21 23:33:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
uint32_t buf = 0;
|
2019-08-21 23:33:25 +00:00
|
|
|
if (std::fread(&buf, 1, sizeof(buf), fp.get()) != sizeof(buf)) {
|
2015-10-01 00:40:06 +00:00
|
|
|
return false;
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
2019-08-21 23:33:25 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
buf = hecl::SLittle(buf);
|
2019-08-21 23:33:25 +00:00
|
|
|
return buf == 0x4e454c42 || buf == 0x88b1f;
|
2015-10-01 00:40:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
bool IsPathYAML(const hecl::ProjectPath& path) {
|
2019-10-01 07:23:35 +00:00
|
|
|
auto lastComp = path.getLastComponent();
|
2021-06-30 18:20:45 +00:00
|
|
|
if (lastComp == "!catalog.yaml" || lastComp == "!memoryid.yaml" || lastComp == "!memoryrelays.yaml")
|
2019-10-01 07:23:35 +00:00
|
|
|
return false; /* !catalog.yaml, !memoryid.yaml, !memoryrelays.yaml are exempt from general use */
|
2018-12-08 05:18:42 +00:00
|
|
|
auto lastCompExt = path.getLastComponentExt();
|
|
|
|
if (lastCompExt.empty())
|
2015-10-01 00:40:06 +00:00
|
|
|
return false;
|
2021-06-30 18:20:45 +00:00
|
|
|
return lastCompExt == "yaml" || lastCompExt == "yml";
|
2015-10-01 00:40:06 +00:00
|
|
|
}
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
hecl::DirectoryEnumerator::DirectoryEnumerator(std::string_view path, Mode mode, bool sizeSort, bool reverse,
|
2018-12-08 05:18:42 +00:00
|
|
|
bool noHidden) {
|
2021-06-30 18:20:45 +00:00
|
|
|
Sstat theStat;
|
|
|
|
if (Stat(path.data(), &theStat) || !S_ISDIR(theStat.st_mode)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
2016-01-01 00:16:20 +00:00
|
|
|
|
|
|
|
#if _WIN32
|
2021-06-30 18:20:45 +00:00
|
|
|
std::wstring wc = nowide::widen(path);
|
|
|
|
wc += L"/*";
|
2018-12-08 05:18:42 +00:00
|
|
|
WIN32_FIND_DATAW d;
|
|
|
|
HANDLE dir = FindFirstFileW(wc.c_str(), &d);
|
2021-06-30 18:20:45 +00:00
|
|
|
if (dir == INVALID_HANDLE_VALUE) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
switch (mode) {
|
|
|
|
case Mode::Native:
|
|
|
|
do {
|
2021-06-30 18:20:45 +00:00
|
|
|
if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
std::string fileName = nowide::narrow(d.cFileName);
|
|
|
|
std::string fp(path);
|
|
|
|
fp += '/';
|
|
|
|
fp += fileName;
|
|
|
|
Sstat st;
|
|
|
|
if (Stat(fp.c_str(), &st))
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
size_t sz = 0;
|
|
|
|
bool isDir = false;
|
2021-06-30 18:20:45 +00:00
|
|
|
if (S_ISDIR(st.st_mode)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
isDir = true;
|
2021-06-30 18:20:45 +00:00
|
|
|
} else if (S_ISREG(st.st_mode)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
sz = st.st_size;
|
2021-06-30 18:20:45 +00:00
|
|
|
} else {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
m_entries.emplace_back(fp, fileName, sz, isDir);
|
2018-12-08 05:18:42 +00:00
|
|
|
} while (FindNextFileW(dir, &d));
|
|
|
|
break;
|
|
|
|
case Mode::DirsThenFilesSorted:
|
|
|
|
case Mode::DirsSorted: {
|
2021-06-30 18:20:45 +00:00
|
|
|
std::map<std::string, Entry, CaseInsensitiveCompare> sort;
|
2018-12-08 05:18:42 +00:00
|
|
|
do {
|
2021-06-30 18:20:45 +00:00
|
|
|
if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
std::string fileName = nowide::narrow(d.cFileName);
|
|
|
|
std::string fp(path);
|
|
|
|
fp += '/';
|
|
|
|
fp += fileName;
|
|
|
|
Sstat st;
|
|
|
|
if (Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
sort.emplace(fileName, Entry{fp, fileName, 0, true});
|
2018-12-08 05:18:42 +00:00
|
|
|
} while (FindNextFileW(dir, &d));
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
m_entries.reserve(sort.size());
|
|
|
|
if (reverse) {
|
2021-10-26 02:34:20 +00:00
|
|
|
for (auto it = sort.crbegin(); it != sort.crend(); ++it) {
|
|
|
|
m_entries.emplace_back(std::move(it->second));
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (auto& e : sort) {
|
|
|
|
m_entries.emplace_back(std::move(e.second));
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 00:16:20 +00:00
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
if (mode == Mode::DirsSorted) {
|
2018-12-08 05:18:42 +00:00
|
|
|
break;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
FindClose(dir);
|
|
|
|
dir = FindFirstFileW(wc.c_str(), &d);
|
|
|
|
}
|
|
|
|
case Mode::FilesSorted: {
|
2021-06-30 18:20:45 +00:00
|
|
|
if (mode == Mode::FilesSorted) {
|
2018-12-08 05:18:42 +00:00
|
|
|
m_entries.clear();
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
|
|
|
|
if (sizeSort) {
|
|
|
|
std::multimap<size_t, Entry> sort;
|
|
|
|
do {
|
2021-06-30 18:20:45 +00:00
|
|
|
if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
std::string fileName = nowide::narrow(d.cFileName);
|
|
|
|
std::string fp(path);
|
|
|
|
fp += '/';
|
|
|
|
fp += fileName;
|
|
|
|
Sstat st;
|
|
|
|
if (Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
sort.emplace(st.st_size, Entry{fp, fileName, static_cast<size_t>(st.st_size), false});
|
2018-12-08 05:18:42 +00:00
|
|
|
} while (FindNextFileW(dir, &d));
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
m_entries.reserve(m_entries.size() + sort.size());
|
|
|
|
if (reverse) {
|
2021-10-26 02:34:20 +00:00
|
|
|
for (auto it = sort.crbegin(); it != sort.crend(); ++it) {
|
|
|
|
m_entries.emplace_back(std::move(it->second));
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (auto& e : sort) {
|
|
|
|
m_entries.emplace_back(std::move(e.second));
|
|
|
|
}
|
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
} else {
|
2021-06-30 18:20:45 +00:00
|
|
|
std::map<std::string, Entry, CaseInsensitiveCompare> sort;
|
2018-12-08 05:18:42 +00:00
|
|
|
do {
|
2021-06-30 18:20:45 +00:00
|
|
|
if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
std::string fileName = nowide::narrow(d.cFileName);
|
|
|
|
std::string fp(path);
|
|
|
|
fp += '/';
|
|
|
|
fp += fileName;
|
|
|
|
Sstat st;
|
|
|
|
if (Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
sort.emplace(fileName, Entry{fp, fileName, static_cast<size_t>(st.st_size), false});
|
2018-12-08 05:18:42 +00:00
|
|
|
} while (FindNextFileW(dir, &d));
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
m_entries.reserve(m_entries.size() + sort.size());
|
|
|
|
if (reverse) {
|
2021-10-26 02:34:20 +00:00
|
|
|
for (auto it = sort.crbegin(); it != sort.crend(); ++it) {
|
|
|
|
m_entries.emplace_back(std::move(it->second));
|
2021-06-30 18:20:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (auto& e : sort) {
|
|
|
|
m_entries.emplace_back(std::move(e.second));
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 00:16:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FindClose(dir);
|
2016-01-01 00:16:20 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
DIR* dir = opendir(path.data());
|
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
const dirent* d;
|
|
|
|
switch (mode) {
|
|
|
|
case Mode::Native:
|
|
|
|
while ((d = readdir(dir))) {
|
|
|
|
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
|
|
|
|
continue;
|
|
|
|
if (noHidden && d->d_name[0] == '.')
|
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string fp(path);
|
2018-12-08 05:18:42 +00:00
|
|
|
fp += '/';
|
|
|
|
fp += d->d_name;
|
|
|
|
hecl::Sstat st;
|
|
|
|
if (hecl::Stat(fp.c_str(), &st))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
size_t sz = 0;
|
|
|
|
bool isDir = false;
|
|
|
|
if (S_ISDIR(st.st_mode))
|
|
|
|
isDir = true;
|
|
|
|
else if (S_ISREG(st.st_mode))
|
|
|
|
sz = st.st_size;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
m_entries.push_back(Entry(std::move(fp), d->d_name, sz, isDir));
|
2016-01-01 00:16:20 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
break;
|
|
|
|
case Mode::DirsThenFilesSorted:
|
|
|
|
case Mode::DirsSorted: {
|
2021-06-30 18:20:45 +00:00
|
|
|
std::map<std::string, Entry, CaseInsensitiveCompare> sort;
|
2018-12-08 05:18:42 +00:00
|
|
|
while ((d = readdir(dir))) {
|
|
|
|
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
|
|
|
|
continue;
|
|
|
|
if (noHidden && d->d_name[0] == '.')
|
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string fp(path);
|
2018-12-08 05:18:42 +00:00
|
|
|
fp += '/';
|
|
|
|
fp += d->d_name;
|
|
|
|
hecl::Sstat st;
|
|
|
|
if (hecl::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode))
|
|
|
|
continue;
|
|
|
|
sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, 0, true)));
|
2016-01-01 00:16:20 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
for (auto it = sort.crbegin(); it != sort.crend(); ++it)
|
|
|
|
m_entries.push_back(std::move(it->second));
|
|
|
|
else
|
|
|
|
for (auto& e : sort)
|
|
|
|
m_entries.push_back(std::move(e.second));
|
|
|
|
|
|
|
|
if (mode == Mode::DirsSorted)
|
|
|
|
break;
|
|
|
|
rewinddir(dir);
|
2019-02-18 05:44:46 +00:00
|
|
|
[[fallthrough]];
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
case Mode::FilesSorted: {
|
|
|
|
if (mode == Mode::FilesSorted)
|
|
|
|
m_entries.clear();
|
|
|
|
|
|
|
|
if (sizeSort) {
|
|
|
|
std::multimap<size_t, Entry> sort;
|
|
|
|
while ((d = readdir(dir))) {
|
|
|
|
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
|
|
|
|
continue;
|
|
|
|
if (noHidden && d->d_name[0] == '.')
|
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string fp(path);
|
2018-12-08 05:18:42 +00:00
|
|
|
fp += '/';
|
|
|
|
fp += d->d_name;
|
|
|
|
hecl::Sstat st;
|
|
|
|
if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode))
|
|
|
|
continue;
|
|
|
|
sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d->d_name, st.st_size, false)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
for (auto it = sort.crbegin(); it != sort.crend(); ++it)
|
|
|
|
m_entries.push_back(std::move(it->second));
|
|
|
|
else
|
|
|
|
for (auto& e : sort)
|
|
|
|
m_entries.push_back(std::move(e.second));
|
|
|
|
} else {
|
2021-06-30 18:20:45 +00:00
|
|
|
std::map<std::string, Entry, CaseInsensitiveCompare> sort;
|
2018-12-08 05:18:42 +00:00
|
|
|
while ((d = readdir(dir))) {
|
|
|
|
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
|
|
|
|
continue;
|
|
|
|
if (noHidden && d->d_name[0] == '.')
|
|
|
|
continue;
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string fp(path);
|
2018-12-08 05:18:42 +00:00
|
|
|
fp += '/';
|
|
|
|
fp += d->d_name;
|
|
|
|
hecl::Sstat st;
|
|
|
|
if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode))
|
|
|
|
continue;
|
|
|
|
sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, st.st_size, false)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
for (auto it = sort.crbegin(); it != sort.crend(); ++it)
|
|
|
|
m_entries.push_back(std::move(it->second));
|
|
|
|
else
|
|
|
|
for (auto& e : sort)
|
|
|
|
m_entries.push_back(std::move(e.second));
|
2016-01-01 00:16:20 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
2016-01-01 00:16:20 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
static std::pair<std::string, std::string> NameFromPath(std::string_view path) {
|
|
|
|
if (path.size() == 1 && path[0] == '/')
|
|
|
|
return {std::string(path), "/"};
|
|
|
|
size_t lastSlash = path.rfind('/');
|
2018-12-08 05:18:42 +00:00
|
|
|
if (lastSlash != std::string::npos)
|
2021-06-30 18:20:45 +00:00
|
|
|
return {std::string(path), std::string(path.cbegin() + lastSlash + 1, path.cend())};
|
2018-12-08 05:18:42 +00:00
|
|
|
else
|
2021-06-30 18:20:45 +00:00
|
|
|
return {std::string(path), std::string(path)};
|
2016-01-02 02:27:17 +00:00
|
|
|
}
|
|
|
|
|
2017-02-04 03:45:39 +00:00
|
|
|
/* recursive mkdir */
|
|
|
|
#if _WIN32
|
2021-06-30 18:20:45 +00:00
|
|
|
int RecursiveMakeDir(const char* dir) {
|
|
|
|
char tmp[1024];
|
2018-12-08 05:18:42 +00:00
|
|
|
|
|
|
|
/* copy path */
|
2021-06-30 18:20:45 +00:00
|
|
|
std::strncpy(tmp, dir, std::size(tmp));
|
|
|
|
const size_t len = std::strlen(tmp);
|
2019-08-24 19:54:37 +00:00
|
|
|
if (len >= std::size(tmp)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove trailing slash */
|
|
|
|
if (tmp[len - 1] == '/' || tmp[len - 1] == '\\') {
|
|
|
|
tmp[len - 1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* recursive mkdir */
|
2021-06-30 18:20:45 +00:00
|
|
|
char* p = nullptr;
|
2019-08-24 19:47:46 +00:00
|
|
|
Sstat sb;
|
2018-12-08 05:18:42 +00:00
|
|
|
for (p = tmp + 1; *p; p++) {
|
|
|
|
if (*p == '/' || *p == '\\') {
|
|
|
|
*p = 0;
|
|
|
|
/* test path */
|
|
|
|
if (Stat(tmp, &sb) != 0) {
|
2017-02-04 03:45:39 +00:00
|
|
|
/* path does not exist - create directory */
|
2021-06-30 18:20:45 +00:00
|
|
|
const nowide::wstackstring wtmp(tmp);
|
|
|
|
if (!CreateDirectoryW(wtmp.get(), nullptr)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return -1;
|
2017-02-04 03:45:39 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
} else if (!S_ISDIR(sb.st_mode)) {
|
2017-02-04 03:45:39 +00:00
|
|
|
/* not a directory */
|
|
|
|
return -1;
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
*p = '/';
|
2017-02-04 03:45:39 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
/* test path */
|
|
|
|
if (Stat(tmp, &sb) != 0) {
|
|
|
|
/* path does not exist - create directory */
|
2021-06-30 18:20:45 +00:00
|
|
|
const nowide::wstackstring wtmp(tmp);
|
|
|
|
if (!CreateDirectoryW(wtmp.get(), nullptr)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else if (!S_ISDIR(sb.st_mode)) {
|
|
|
|
/* not a directory */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2017-02-04 03:45:39 +00:00
|
|
|
}
|
|
|
|
#else
|
2021-06-30 18:20:45 +00:00
|
|
|
int RecursiveMakeDir(const char* dir) {
|
|
|
|
char tmp[1024];
|
2018-12-08 05:18:42 +00:00
|
|
|
|
|
|
|
/* copy path */
|
2021-04-05 17:25:40 +00:00
|
|
|
std::memset(tmp, 0, std::size(tmp));
|
|
|
|
std::strncpy(tmp, dir, std::size(tmp) - 1);
|
2019-08-24 19:47:46 +00:00
|
|
|
const size_t len = std::strlen(tmp);
|
2019-08-24 19:54:37 +00:00
|
|
|
if (len >= std::size(tmp)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove trailing slash */
|
|
|
|
if (tmp[len - 1] == '/') {
|
|
|
|
tmp[len - 1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* recursive mkdir */
|
2021-06-30 18:20:45 +00:00
|
|
|
char* p = nullptr;
|
2019-08-24 19:47:46 +00:00
|
|
|
Sstat sb;
|
2018-12-08 05:18:42 +00:00
|
|
|
for (p = tmp + 1; *p; p++) {
|
|
|
|
if (*p == '/') {
|
|
|
|
*p = 0;
|
|
|
|
/* test path */
|
|
|
|
if (Stat(tmp, &sb) != 0) {
|
2017-02-04 03:45:39 +00:00
|
|
|
/* path does not exist - create directory */
|
|
|
|
if (mkdir(tmp, 0755) < 0) {
|
2018-12-08 05:18:42 +00:00
|
|
|
return -1;
|
2017-02-04 03:45:39 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
} else if (!S_ISDIR(sb.st_mode)) {
|
2017-02-04 03:45:39 +00:00
|
|
|
/* not a directory */
|
|
|
|
return -1;
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
*p = '/';
|
2017-02-04 03:45:39 +00:00
|
|
|
}
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
/* test path */
|
|
|
|
if (Stat(tmp, &sb) != 0) {
|
|
|
|
/* path does not exist - create directory */
|
|
|
|
if (mkdir(tmp, 0755) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else if (!S_ISDIR(sb.st_mode)) {
|
|
|
|
/* not a directory */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2017-02-04 03:45:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string GetTmpDir() {
|
2017-02-24 08:27:07 +00:00
|
|
|
#ifdef _WIN32
|
2017-12-06 03:22:31 +00:00
|
|
|
#if WINDOWS_STORE
|
2019-08-24 20:04:28 +00:00
|
|
|
const wchar_t* TMPDIR = nullptr;
|
2017-12-06 03:22:31 +00:00
|
|
|
#else
|
2021-06-30 18:20:45 +00:00
|
|
|
auto TMPDIR = GetEnv("TEMP");
|
|
|
|
if (!TMPDIR) {
|
|
|
|
return "\\Temp";
|
|
|
|
}
|
|
|
|
return std::move(TMPDIR.value());
|
2017-12-06 03:22:31 +00:00
|
|
|
#endif
|
2017-02-24 08:27:07 +00:00
|
|
|
#else
|
2019-08-24 20:04:28 +00:00
|
|
|
const char* TMPDIR = getenv("TMPDIR");
|
2018-12-08 05:18:42 +00:00
|
|
|
if (!TMPDIR)
|
2019-08-24 20:04:28 +00:00
|
|
|
TMPDIR = "/tmp";
|
2018-12-08 05:18:42 +00:00
|
|
|
return TMPDIR;
|
2021-06-30 18:20:45 +00:00
|
|
|
#endif
|
2017-02-24 08:27:07 +00:00
|
|
|
}
|
|
|
|
|
2017-12-06 03:22:31 +00:00
|
|
|
#if !WINDOWS_STORE
|
2021-06-30 18:20:45 +00:00
|
|
|
int RunProcess(const char* path, const char* const args[]) {
|
2017-02-24 08:27:07 +00:00
|
|
|
#ifdef _WIN32
|
2019-08-24 20:14:37 +00:00
|
|
|
SECURITY_ATTRIBUTES sattrs = {sizeof(SECURITY_ATTRIBUTES), nullptr, TRUE};
|
|
|
|
HANDLE consoleOutReadTmp = INVALID_HANDLE_VALUE;
|
|
|
|
HANDLE consoleOutWrite = INVALID_HANDLE_VALUE;
|
2018-12-08 05:18:42 +00:00
|
|
|
if (!CreatePipe(&consoleOutReadTmp, &consoleOutWrite, &sattrs, 0)) {
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Fatal, FMT_STRING("Error with CreatePipe"));
|
2018-12-08 05:18:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-25 07:58:36 +00:00
|
|
|
|
2019-08-24 20:14:37 +00:00
|
|
|
HANDLE consoleErrWrite = INVALID_HANDLE_VALUE;
|
2018-12-08 05:18:42 +00:00
|
|
|
if (!DuplicateHandle(GetCurrentProcess(), consoleOutWrite, GetCurrentProcess(), &consoleErrWrite, 0, TRUE,
|
|
|
|
DUPLICATE_SAME_ACCESS)) {
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Fatal, FMT_STRING("Error with DuplicateHandle"));
|
2017-02-25 07:58:36 +00:00
|
|
|
CloseHandle(consoleOutReadTmp);
|
2018-12-08 05:18:42 +00:00
|
|
|
CloseHandle(consoleOutWrite);
|
|
|
|
return -1;
|
|
|
|
}
|
2017-02-25 07:58:36 +00:00
|
|
|
|
2019-08-24 20:14:37 +00:00
|
|
|
HANDLE consoleOutRead = INVALID_HANDLE_VALUE;
|
2018-12-08 05:18:42 +00:00
|
|
|
if (!DuplicateHandle(GetCurrentProcess(), consoleOutReadTmp, GetCurrentProcess(),
|
|
|
|
&consoleOutRead, // Address of new handle.
|
|
|
|
0, FALSE, // Make it uninheritable.
|
|
|
|
DUPLICATE_SAME_ACCESS)) {
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Fatal, FMT_STRING("Error with DuplicateHandle"));
|
2018-12-08 05:18:42 +00:00
|
|
|
CloseHandle(consoleOutReadTmp);
|
|
|
|
CloseHandle(consoleOutWrite);
|
|
|
|
CloseHandle(consoleErrWrite);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(consoleOutReadTmp);
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
std::wstring cmdLine;
|
|
|
|
const char* const* arg = &args[1];
|
2018-12-08 05:18:42 +00:00
|
|
|
while (*arg) {
|
2021-06-30 18:20:45 +00:00
|
|
|
cmdLine += L" \"";
|
|
|
|
cmdLine += nowide::widen(*arg++);
|
|
|
|
cmdLine += L'"';
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STARTUPINFO sinfo = {sizeof(STARTUPINFO)};
|
|
|
|
HANDLE nulHandle = CreateFileW(L"nul", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sattrs, OPEN_EXISTING,
|
2019-08-24 20:14:37 +00:00
|
|
|
FILE_ATTRIBUTE_NORMAL, nullptr);
|
2018-12-08 05:18:42 +00:00
|
|
|
sinfo.dwFlags = STARTF_USESTDHANDLES;
|
|
|
|
sinfo.hStdInput = nulHandle;
|
|
|
|
sinfo.hStdError = consoleErrWrite;
|
|
|
|
sinfo.hStdOutput = consoleOutWrite;
|
|
|
|
|
|
|
|
PROCESS_INFORMATION pinfo = {};
|
2021-06-30 18:20:45 +00:00
|
|
|
const nowide::wstackstring wpath(path);
|
|
|
|
if (!CreateProcessW(wpath.get(), cmdLine.data(), nullptr, nullptr, TRUE, NORMAL_PRIORITY_CLASS, nullptr, nullptr,
|
|
|
|
&sinfo, &pinfo)) {
|
2018-12-08 05:18:42 +00:00
|
|
|
LPWSTR messageBuffer = nullptr;
|
2019-08-24 20:14:37 +00:00
|
|
|
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
|
|
|
|
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr);
|
2021-06-30 18:20:45 +00:00
|
|
|
LogModule.report(logvisor::Error, FMT_STRING("unable to launch process from {}: {}"), path,
|
|
|
|
nowide::narrow(messageBuffer));
|
2018-12-08 05:18:42 +00:00
|
|
|
LocalFree(messageBuffer);
|
2017-02-25 07:58:36 +00:00
|
|
|
|
|
|
|
CloseHandle(nulHandle);
|
|
|
|
CloseHandle(consoleErrWrite);
|
|
|
|
CloseHandle(consoleOutWrite);
|
2018-12-08 05:18:42 +00:00
|
|
|
CloseHandle(consoleOutRead);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(nulHandle);
|
|
|
|
CloseHandle(consoleErrWrite);
|
|
|
|
CloseHandle(consoleOutWrite);
|
|
|
|
|
|
|
|
bool consoleThreadRunning = true;
|
|
|
|
auto consoleThread = std::thread([=, &consoleThreadRunning]() {
|
|
|
|
CHAR lpBuffer[256];
|
|
|
|
DWORD nBytesRead;
|
|
|
|
DWORD nCharsWritten;
|
|
|
|
|
|
|
|
while (consoleThreadRunning) {
|
2019-08-24 20:14:37 +00:00
|
|
|
if (!ReadFile(consoleOutRead, lpBuffer, sizeof(lpBuffer), &nBytesRead, nullptr) || !nBytesRead) {
|
2018-12-08 05:18:42 +00:00
|
|
|
DWORD err = GetLastError();
|
|
|
|
if (err == ERROR_BROKEN_PIPE)
|
|
|
|
break; // pipe done - normal exit path.
|
|
|
|
else
|
2020-04-11 22:48:11 +00:00
|
|
|
LogModule.report(logvisor::Error, FMT_STRING("Error with ReadFile: {:08X}"), err); // Something bad happened.
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display the character read on the screen.
|
|
|
|
auto lk = logvisor::LockLog();
|
2019-08-24 20:14:37 +00:00
|
|
|
if (!WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), lpBuffer, nBytesRead, &nCharsWritten, nullptr)) {
|
2020-04-11 22:48:11 +00:00
|
|
|
// LogModule.report(logvisor::Error, FMT_STRING("Error with WriteConsole: {:08X}"), GetLastError());
|
2018-12-08 05:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-25 07:58:36 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
CloseHandle(consoleOutRead);
|
|
|
|
});
|
2017-02-25 07:58:36 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
WaitForSingleObject(pinfo.hProcess, INFINITE);
|
|
|
|
DWORD ret;
|
|
|
|
if (!GetExitCodeProcess(pinfo.hProcess, &ret))
|
|
|
|
ret = -1;
|
|
|
|
consoleThreadRunning = false;
|
|
|
|
if (consoleThread.joinable())
|
|
|
|
consoleThread.join();
|
2017-02-25 07:58:36 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
CloseHandle(pinfo.hProcess);
|
|
|
|
CloseHandle(pinfo.hThread);
|
2017-02-25 07:58:36 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
return ret;
|
2017-02-24 08:27:07 +00:00
|
|
|
#else
|
2018-12-08 05:18:42 +00:00
|
|
|
pid_t pid = fork();
|
|
|
|
if (!pid) {
|
2019-02-27 05:13:19 +00:00
|
|
|
closefrom(3);
|
2018-12-08 05:18:42 +00:00
|
|
|
execvp(path, (char* const*)args);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
int ret;
|
|
|
|
if (waitpid(pid, &ret, 0) < 0)
|
2017-02-24 08:27:07 +00:00
|
|
|
return -1;
|
2018-12-08 05:18:42 +00:00
|
|
|
if (WIFEXITED(ret))
|
|
|
|
return WEXITSTATUS(ret);
|
|
|
|
return -1;
|
2017-02-24 08:27:07 +00:00
|
|
|
#endif
|
|
|
|
}
|
2017-12-06 03:22:31 +00:00
|
|
|
#endif
|
2017-02-24 08:27:07 +00:00
|
|
|
|
2018-12-08 05:18:42 +00:00
|
|
|
} // namespace hecl
|