@@ -103,6 +103,8 @@ class AbstractIOHandlerImplCommon : public AbstractIOHandlerImpl
103103 FilePositionType *
104104 setAndGetFilePosition (Writable *writable, std::string extend);
105105
106+ void propagateFilestateToRoot (Writable *writable);
107+
106108 /*
107109 * The "virtual" methods here must be implemented by the child class,
108110 * but the references are resolved at compile time, hence not really
@@ -138,8 +140,9 @@ AbstractIOHandlerImplCommon<IOHandler_t, FilePositionType>::makeFile(
138140 Writable *writable, std::string file, bool consider_open_files)
139141{
140142 auto make_new = [&]() {
141- new (&writable->fileState )
142- internal::SharedFileState (std::in_place, file);
143+ using SharedFileState = internal::SharedFileState;
144+ writable->fileState .~SharedFileState ();
145+ new (&writable->fileState ) SharedFileState (std::in_place, file);
143146 m_files[std::move (file)].derive_from (writable->fileState );
144147 };
145148 if (consider_open_files)
@@ -311,4 +314,16 @@ auto AbstractIOHandlerImplCommon<IOHandlerImpl_t, FilePositionType>::
311314 writable->abstractFilePosition = std::move (new_pos);
312315 return dynamic_cast <FilePositionType *>(res);
313316}
317+
318+ template <typename IOHandlerImpl_t, typename FilePositionType>
319+ void AbstractIOHandlerImplCommon<IOHandlerImpl_t, FilePositionType>::
320+ propagateFilestateToRoot (Writable *const writable)
321+ {
322+ auto ancestor = writable;
323+ while (ancestor->parent )
324+ {
325+ ancestor = ancestor->parent ;
326+ ancestor->fileState .derive_from (writable->fileState );
327+ }
328+ }
314329} // namespace openPMD
0 commit comments