File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1616#include < vector>
1717#include < memory>
1818
19+ class TMemFile ;
20+
21+ namespace ROOT ::Internal {
22+
23+ void DumpBin (const TMemFile &file, FILE *out);
24+
25+ }
26+
1927class TMemFile : public TFile {
28+ friend void ROOT::Internal::DumpBin (const TMemFile &file, FILE *out);
29+
2030public:
2131 using ExternalDataPtr_t = std::shared_ptr<const std::vector<char >>;
2232 // / A read-only memory range which we do not control.
Original file line number Diff line number Diff line change @@ -312,6 +312,26 @@ void TMemFile::Print(Option_t *option /* = "" */) const
312312 }
313313}
314314
315+ // //////////////////////////////////////////////////////////////////////////////
316+ // / Writes the contents of the TMemFile to the given file. This is meant to be
317+ // / used mostly for debugging, as it dumps the current file's content as-is with
318+ // / no massaging (meaning the content might not be a valid ROOT file): for regular use cases, use Cp().
319+ // / Example usage:
320+ // / ~~~ {.cpp}
321+ // / FILE *out = fopen("memfile_dump.root", "wb");
322+ // / ROOT::Internal::DumpBin(memFile, out);
323+ // / fclose(out);
324+ // / ~~~
325+ void ROOT::Internal::DumpBin (const TMemFile &file, FILE *out)
326+ {
327+ const auto *cur = &file.fBlockList ;
328+ while (cur && cur->fSize ) {
329+ fwrite (cur->fBuffer , cur->fSize , 1 , out);
330+ cur = cur->fNext ;
331+ }
332+ fflush (out);
333+ }
334+
315335// //////////////////////////////////////////////////////////////////////////////
316336// / Wipe all the data from the permanent buffer but keep, the in-memory object
317337// / alive.
You can’t perform that action at this time.
0 commit comments