File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -102,11 +102,12 @@ void JSONIOHandlerImpl::createFile(
102
102
}
103
103
104
104
auto res_pair = getPossiblyExisting (name);
105
+ auto fullPathToFile = fullPath (std::get<0 >(res_pair));
105
106
File shared_name = File (name);
106
107
VERIFY_ALWAYS (
107
108
!(m_handler->m_backendAccess == Access::READ_WRITE &&
108
109
(!std::get<2 >(res_pair) ||
109
- auxiliary::file_exists (fullPath (std::get< 0 >(res_pair)) ))),
110
+ auxiliary::file_exists (fullPathToFile ))),
110
111
" [JSON] Can only overwrite existing file in CREATE mode." );
111
112
112
113
if (!std::get<2 >(res_pair))
@@ -127,9 +128,12 @@ void JSONIOHandlerImpl::createFile(
127
128
associateWithFile (writable, shared_name);
128
129
this ->m_dirty .emplace (shared_name);
129
130
130
- if (m_handler->m_backendAccess != Access::APPEND)
131
+ if (m_handler->m_backendAccess != Access::APPEND ||
132
+ !auxiliary::file_exists (fullPathToFile))
131
133
{
132
- // make sure to overwrite!
134
+ // if in create mode: make sure to overwrite
135
+ // if in append mode and the file does not exist: create an empty
136
+ // dataset
133
137
this ->m_jsonVals [shared_name] = std::make_shared<nlohmann::json>();
134
138
}
135
139
// else: the JSON value is not available in m_jsonVals and will be
Original file line number Diff line number Diff line change @@ -6046,9 +6046,14 @@ void append_mode(
6046
6046
std::string jsonConfig = " {}" )
6047
6047
{
6048
6048
6049
- std::string filename = (variableBased ? " ../samples/append_variablebased."
6050
- : " ../samples/append_groupbased." ) +
6049
+ std::string filename =
6050
+ (variableBased ? " ../samples/append/append_variablebased."
6051
+ : " ../samples/append/append_groupbased." ) +
6051
6052
extension;
6053
+ if (auxiliary::directory_exists (" ../samples/append" ))
6054
+ {
6055
+ auxiliary::remove_directory (" ../samples/append" );
6056
+ }
6052
6057
std::vector<int > data (10 , 0 );
6053
6058
auto writeSomeIterations = [&data](
6054
6059
WriteIterations &&writeIterations,
@@ -6064,7 +6069,7 @@ void append_mode(
6064
6069
}
6065
6070
};
6066
6071
{
6067
- Series write (filename, Access::CREATE , jsonConfig);
6072
+ Series write (filename, Access::APPEND , jsonConfig);
6068
6073
if (variableBased)
6069
6074
{
6070
6075
if (write.backend () != " ADIOS2" )
You can’t perform that action at this time.
0 commit comments