22 lines
422 B
C++
22 lines
422 B
C++
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <Spectre/System/File.h>
|
|
|
|
namespace sp { namespace file
|
|
{
|
|
std::vector<unsigned char> read(const std::string& path) {
|
|
|
|
std::vector<unsigned char> buf;
|
|
FILE *fd = fopen(path.c_str(), "rb");
|
|
|
|
if (fd) {
|
|
fseek(fd, 0, SEEK_END);
|
|
buf.resize(ftell(fd));
|
|
rewind(fd);
|
|
fread(&buf[0], 1, buf.size(), fd);
|
|
fclose(fd);
|
|
}
|
|
return buf;
|
|
}
|
|
} } // namespace sp::file
|