22 lines
590 B
C++
22 lines
590 B
C++
// core/util/file_bytes implementation — see file_bytes.h.
|
|
|
|
#include "core/util/file_bytes.h"
|
|
|
|
#include <fstream>
|
|
|
|
namespace reasampler::util {
|
|
|
|
std::vector<std::uint8_t> readFileBytes(const std::string& path) {
|
|
std::ifstream f(path, std::ios::binary | std::ios::ate);
|
|
if (!f) return {};
|
|
const std::streamoff size = f.tellg();
|
|
if (size <= 0) return {};
|
|
std::vector<std::uint8_t> bytes(static_cast<std::size_t>(size));
|
|
f.seekg(0);
|
|
f.read(reinterpret_cast<char*>(bytes.data()), size);
|
|
if (!f) return {};
|
|
return bytes;
|
|
}
|
|
|
|
} // namespace reasampler::util
|