mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-14 05:25:09 -05:00
93d0d7443a
* LUS Cleanup: Removes GameSettings class. Moves code to Imgui. * Fixes more strdup problems and finalized removal of GameSetting. * Reverts changes to Directory.h * Update Directory.h * Fixes PR. * Update Directory.h * Update rando_main.cpp
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include "StringHelper.h"
|
|
#include <iostream>
|
|
|
|
#if __has_include(<filesystem>)
|
|
#include <filesystem>
|
|
namespace fs = std::filesystem;
|
|
#else
|
|
#include <experimental/filesystem>
|
|
namespace fs = std::experimental::filesystem;
|
|
#endif
|
|
|
|
#undef GetCurrentDirectory
|
|
#undef CreateDirectory
|
|
|
|
class Directory
|
|
{
|
|
public:
|
|
#ifndef PATH_HACK
|
|
static std::string GetCurrentDirectory() { return fs::current_path().string(); }
|
|
#endif
|
|
|
|
static bool Exists(const fs::path& path) { return fs::exists(path); }
|
|
|
|
// Stupid hack because of Windows.h
|
|
static void MakeDirectory(const std::string& path)
|
|
{
|
|
CreateDirectory(path);
|
|
}
|
|
|
|
static void CreateDirectory(const std::string& path)
|
|
{
|
|
try
|
|
{
|
|
fs::create_directories(path);
|
|
}
|
|
catch (...)
|
|
{
|
|
}
|
|
}
|
|
|
|
static std::vector<std::string> ListFiles(const std::string& dir)
|
|
{
|
|
std::vector<std::string> lst;
|
|
|
|
if (Exists(dir))
|
|
{
|
|
for (auto& p : fs::recursive_directory_iterator(dir))
|
|
{
|
|
if (!p.is_directory())
|
|
lst.push_back(p.path().generic_string());
|
|
}
|
|
}
|
|
|
|
return lst;
|
|
}
|
|
};
|