33 lines
897 B
C++
33 lines
897 B
C++
#include "esx_reader.hpp"
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <filesystem>
|
|
|
|
static constexpr auto esm_name = "Skyrim.esm";
|
|
|
|
/* Propagated Exceptions:
|
|
* - std::bad_alloc
|
|
* - std::filesystem::filesystem_error
|
|
* - std::ios_base::failure
|
|
*/
|
|
[[nodiscard]] static std::ifstream open_esm(void)
|
|
{
|
|
std::filesystem::path cwd = std::filesystem::current_path();
|
|
auto esm_path = cwd / esm_name;
|
|
auto esm_fs = std::ifstream(esm_path, std::ios::binary);
|
|
if (esm_fs.fail())
|
|
throw std::ios_base::failure("Could not open the esm file for reading.");
|
|
return esm_fs;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
auto esm_fs = open_esm();
|
|
std::array<char, 4> fourcc{};
|
|
esm_fs.read(fourcc.data(), static_cast<std::streamsize>(fourcc.size()));
|
|
for (auto c : fourcc)
|
|
std::cout << c;
|
|
std::cout << '\n';
|
|
return 0;
|
|
} |