-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Labels
Description
I try to run this simple code and I get exception
'std::runtime_error': what(): open file mode not supported
from file "cista/targets/file.h" line 31
verify(read || write, "open file mode not supported");
I use Windows with msys2(mingw64).
namespace data = cista::offset;
constexpr auto const MODE = cista::mode::WITH_VERSION | cista::mode::WITH_INTEGRITY;
struct pos {
int x, y;
};
using vec = data::vector<pos>;
{
vec positions{{1, 2}, {3, 4}, {5, 6}, {7, 8}};
cista::buf mmap{cista::mmap{"data"}};
cista::serialize<MODE>(mmap, positions);
}
auto b = cista::mmap("data", cista::mmap::protection::MODIFY);
auto positions = cista::deserialize<vec, MODE>(b);
positions->push_back({5, 5});
for(auto pos : *positions) {
std::cout << pos.x << " " << pos.y << std::endl;
}
And question. I need load data from disk and modify it, but I don't need to sync data always with disk.
Should I serialize data from disk, copy it to memory and, after changing it, serialize it back?
Or should I just use mmap::modify? I do not fully understand how much mmap costs and what is more efficient"