38 Debug("TMemFile", "%s", x);
111 :
TFile(path,
"WEB",
"read-only TMemFile", 0 ),
162 :
TMemFile(path, nullptr, -1, option, ftitle, compress, defBlockSize)
179 Int_t mode = O_RDWR | O_CREAT;
184 SysError(
"TMemFile",
"file %s can not be opened", path);
192 SysError(
"TMemFile",
"file %s can not be opened for reading", path);
282 current = current->
fNext;
300 if (strcmp(option,
"blocks")==0) {
304 Printf(
"TMemBlock: %d size=%lld addr=%p curr=%p prev=%p next=%p",
307 current = current->
fNext;
328 while (cur && cur->fSize) {
329 fwrite(cur->fBuffer, cur->fSize, 1, out);
377 gROOT->GetListOfFiles()->Remove(
this);
388 while ((idcur = next())) {
405 while( (key = (
TKey*)next()) ) {
407 Warning(
"ResetObjects",
"Key/Object %s is not attached to the directory %s and can not be ResetAfterMerge correctly",
415 listHargs.
Form(
"(TFileMergeInfo*)0x%zx",(
size_t)info);
419 while ((idcur = next())) {
427 idcur->
Execute(
"ResetAfterMerge", listHargs.
Data(), &error);
429 Error(
"ResetObjects",
"calling ResetAfterMerge() on '%s' failed.",
449 gSystem->SetErrorStr(
"The memory file is not open.");
473 buf = (
char*)buf + sublen;
474 Int_t len_left = len - sublen;
515 if (whence == SEEK_SET) {
525 }
else if (whence == SEEK_CUR) {
529 }
else if (offset > 0) {
549 SysError(
"TMemFile",
"Unable to seek past the beginning of file");
568 }
else if (whence == SEEK_END) {
570 SysError(
"TMemFile",
"Unable to seek past end of file");
574 SysError(
"TMemFile",
"Unable to seek to end of file");
579 SysError(
"TMemFile",
"Unknown whence!");
618 gSystem->SetErrorStr(
"A memory file with shared data is read-only.");
624 gSystem->SetErrorStr(
"The memory file is not open.");
641 buf = (
char*)buf + sublen;
642 Int_t len_left = len - sublen;
void tobuf(char *&buf, Bool_t x)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void SysError(const char *location, const char *msgfmt,...)
Use this function in case a system (OS or GUI) related error occurred.
void MayNotUse(const char *method)
This function can be used in classes that should override a certain function, but in the inherited cl...
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
#define TRACE(Flag, Args)
externTVirtualMutex * gROOTMutex
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
#define R__LOCKGUARD(mutex)
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
Return the wrapper around Merge.
Int_t fNbytesKeys
Number of bytes for the keys.
TList * GetListOfKeys() const override
Long64_t fSeekKeys
Location of Keys record on file.
Bool_t fWritable
True if directory is writable.
TDirectory::TContext keeps track and restore the current directory.
virtual TList * GetList() const
A class to pass information from the TFileMerger to the objects being merged.
Int_t fReadCalls
Number of read calls ( not counting the cache calls ).
Long64_t fBytesRead
Number of bytes read from this file.
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Int_t GetCompressionSettings() const
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Bool_t fMustFlush
!True if the file buffers must be flushed
friend class TDirectoryFile
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
virtual void Init(Bool_t create)
Initialize a TFile object.
TFile(const TFile &)=delete
TString fOption
File options.
virtual Long64_t GetEND() const
virtual const TUrl * GetEndpointUrl() const
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Long64_t fBytesWrite
Number of bytes written to this file.
TList * fFree
Free segments linked list table.
Bool_t fInitDone
!True if the file has been initialized
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Long64_t fOffset
!Seek offset cache
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
void Close(Option_t *option="") override
Close a file.
Int_t fNProcessIDs
Number of TProcessID written to this file.
Int_t fWritten
Number of objects written so far.
Option_t * GetOption() const override
Book space in a file, create I/O buffers, to fill them, (un)compress them.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Open a file in 'MemFile'.
ExternalDataPtr_t fExternalData
shared file data / content
bool NeedsExistingFile(EMode mode) const
Long64_t fDefaultBlockSize
Bool_t fIsOwnedByROOT
if this is a C-style memory region
TMemFile(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Long64_t defBlockSize=0LL)
Usual Constructor.
Long64_t GetSize() const override
Return the current size of the memory file.
Long64_t fBlockOffset
Seek offset within the block.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len) override
Write a buffer into the file.
EMode ParseOption(Option_t *option)
Parse option strings and set fOption.
TMemBlock * fBlockSeek
Pointer to the block we seeked to.
static constexpr Long64_t fgDefaultBlockSize
Long64_t fSize
Total file size (sum of the size of the chunks).
TMemBlock fBlockList
Collection of memory blocks of size fgDefaultBlockSize.
void Print(Option_t *option="") const override
Print all objects in the file.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Perform a stat on the file; see TFile::SysStat().
Long64_t fSysOffset
Seek offset in file.
Bool_t IsExternalData() const
~TMemFile() override
Close and clean-up file.
bool NeedsToWrite(EMode mode) const
Int_t SysRead(Int_t fd, void *buf, Int_t len) override
Read specified number of bytes from current offset into the buffer.
Int_t SysClose(Int_t fd) override
Close the mem file.
std::shared_ptr< const std::vector< char > > ExternalDataPtr_t
Int_t SysWriteImpl(Int_t fd, const void *buf, Long64_t len)
Write a buffer into the file.
void ResetObjects(TDirectoryFile *, TFileMergeInfo *) const
Wipe all the data from the permanent buffer but keep, the in-memory object alive.
void ResetErrno() const override
Simply calls TSystem::ResetErrno().
Int_t SysReadImpl(Int_t fd, void *buf, Long64_t len)
Read specified number of bytes from current offset into the buffer.
virtual Long64_t CopyTo(void *to, Long64_t maxsize) const
Copy the binary representation of the TMemFile into the memory area starting at 'to' and of length at...
Int_t SysSync(Int_t fd) override
Sync remaining data to disk.
void ResetAfterMerge(TFileMergeInfo *) override
Wipe all the data from the permanent buffer but keep, the in-memory object alive.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence) override
Seek to a specified position in the file.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
virtual TClass * IsA() const
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
static void ResetErrno()
Static function resetting system error number.
void DumpBin(const TMemFile &file, FILE *out)
Writes the contents of the TMemFile to the given file.
~TMemBlock()
Usual destructors. Delete the block memory.
void CreateNext(Long64_t size)
TMemBlock(const TMemBlock &)=delete
A read-only memory range which we do not control.