handle non existant serialized state better

master
Martin Felis 2016-11-25 22:32:42 +01:00
parent 6f44e81987
commit 48e51bb3cb
2 changed files with 8 additions and 3 deletions

View File

@ -69,7 +69,6 @@ SET ( protot_SRCS
src/shaderc_hlsl.cpp
src/RuntimeModuleManager.cc
# src/Serializer.cc
3rdparty/glfw/deps/glad.c
)

View File

@ -5,7 +5,7 @@
#include <fstream>
#include <unordered_map>
#include <cstring>
#include <sys/stat.h>
struct WriteSerializer {
enum { IsReading = 0 };
@ -71,13 +71,19 @@ struct ReadSerializer {
}
void Open(const char* filename) {
// early out if file does not (yet) exist
struct stat fstat;
if (stat(filename, &fstat) == -1) {
return;
}
std::ifstream stream(filename, std::ios::binary);
size_t key_size;
size_t block_size;
while (!stream.eof()) {
// read key size
stream.read(reinterpret_cast<char*>(&key_size), sizeof(size_t));
std::cout << "read key size " << key_size << std::endl;