#include "pipeline/loose_file_reader.hpp" #include "core/logger.hpp" #include #include namespace wowee { namespace pipeline { std::vector LooseFileReader::readFile(const std::string& filesystemPath) { std::ifstream file(filesystemPath, std::ios::binary | std::ios::ate); if (!file.is_open()) { return {}; } auto size = file.tellg(); if (size <= 0) { return {}; } std::vector data(static_cast(size)); file.seekg(0, std::ios::beg); file.read(reinterpret_cast(data.data()), size); if (!file.good()) { LOG_WARNING("Incomplete read of: ", filesystemPath); data.resize(static_cast(file.gcount())); } return data; } bool LooseFileReader::fileExists(const std::string& filesystemPath) { std::error_code ec; return std::filesystem::exists(filesystemPath, ec); } uint64_t LooseFileReader::getFileSize(const std::string& filesystemPath) { std::error_code ec; auto size = std::filesystem::file_size(filesystemPath, ec); if (ec) { return 0; } return static_cast(size); } } // namespace pipeline } // namespace wowee