Commit db5d1fca authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Set the read only mode on all files written by the accesor. Reset if updating.

parent 1383ef1b
......@@ -781,6 +781,15 @@ public:
{
auto victim = dataset_;
dataset_.reset();
switch (disposition_) {
case OpenMode::Truncate:
case OpenMode::ReadWrite:
// TODO-Low: Maybe not if the file isn't finalized?
victim->setReadonlyMode(true);
break;
default:
break;
}
disposition_ = OpenMode::Closed;
victim->close();
victim.reset(); // Any throw from SDGenericDataset dtor happens here.
......@@ -1139,6 +1148,23 @@ SeismicStoreFile::SeismicStoreFile(const std::string& filename, OpenMode mode, c
dataset->open(seismicdrive::SDDatasetDisposition::READ_ONLY, extra);
break;
case OpenMode::ReadWrite:
{
// Assume the zgy file was marked as readonly.
// Change it back to writable. The application takes all
// responsibility for this not being a very bad idea.
// TODO-Low: Should the application explicitly request this?
auto sgds = std::make_shared<seismicdrive::SDGenericDataset>
(manager.get(), filename, sd_ds_log);
sgds->open(seismicdrive::SDDatasetDisposition::READ_ONLY);
if (sgds->getReadonlyMode()) {
sgds->setReadonlyMode(false);
_logger(0, "Cleared readonly flag on \"" + filename + "\"");
}
else {
_logger(0, "No readonly flag on \"" + filename + "\"");
}
sgds->close();
}
dataset->open(seismicdrive::SDDatasetDisposition::READ_WRITE, extra);
break;
case OpenMode::Truncate:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment