37 Debug("TMemFile", "%s", x);
60 fPrevious(previous), fNext(0), fBuffer(0),
fSize(0)
73 fPrevious(nullptr), fNext(nullptr), fBuffer(data),
fSize(size)
104 else if (
fOption ==
"RECREATE")
119 TFile(path,
"WEB",
"read-only TMemFile", 0 ),
120 fBlockList(reinterpret_cast<
UChar_t*>(const_cast<char*>(data->data())), data->size()),
141 TFile(
name,
"WEB",
"read-only TMemFile", 0 ),
142 fBlockList(reinterpret_cast<
UChar_t*>(buffer->Buffer()), buffer->BufferSize()),
143 fSize(buffer->BufferSize()), fSysOffset(0), fBlockSeek(&(fBlockList)), fBlockOffset(0)
172 :
TMemFile(path, nullptr, -1, option, ftitle, compress, defBlockSize)
181 :
TFile(path,
"WEB", ftitle, compress), fBlockList(size), fSize(size), fSysOffset(0), fBlockSeek(&(fBlockList)),
189 Int_t mode = O_RDWR | O_CREAT;
194 SysError(
"TMemFile",
"file %s can not be opened", path);
202 SysError(
"TMemFile",
"file %s can not be opened for reading", path);
225 TFile(orig.GetEndpointUrl()->GetUrl(),
"WEB", orig.GetTitle(),
226 orig.GetCompressionSettings() ), fBlockList(orig.GetEND()), fExternalData(orig.fExternalData),
227 fSize(orig.GetEND()), fSysOffset(0), fBlockSeek(&(fBlockList)), fBlockOffset(0)
293 current = current->
fNext;
311 if (strcmp(option,
"blocks")==0) {
315 Printf(
"TMemBlock: %d size=%lld addr=%p curr=%p prev=%p next=%p",
318 current = current->
fNext;
373 gROOT->GetListOfFiles()->Remove(
this);
384 while ((idcur = next())) {
402 while( (key = (
TKey*)next()) ) {
404 Warning(
"ResetObjects",
"Key/Object %s is not attached to the directory %s and can not be ResetAfterMerge correctly",
412 listHargs.
Form(
"(TFileMergeInfo*)0x%lx",(
ULong_t)info);
416 while ((idcur = next())) {
417 TClass *objcl = idcur->IsA();
422 }
else if (idcur->IsA()->GetMethodWithPrototype(
"ResetAfterMerge",
"TFileMergeInfo*") ) {
424 idcur->
Execute(
"ResetAfterMerge", listHargs.
Data(), &error);
426 Error(
"ResetObjects",
"calling ResetAfterMerge() on '%s' failed.",
468 buf = (
char*)buf + sublen;
469 Int_t len_left = len - sublen;
510 if (whence == SEEK_SET) {
520 }
else if (whence == SEEK_CUR) {
524 }
else if (offset > 0) {
544 SysError(
"TMemFile",
"Unable to seek past the beginning of file");
563 }
else if (whence == SEEK_END) {
565 SysError(
"TMemFile",
"Unable to seek past end of file");
569 SysError(
"TMemFile",
"Unable to seek to end of file");
574 SysError(
"TMemFile",
"Unknown whence!");
636 buf = (
char*)buf + sublen;
637 Int_t len_left = len - sublen;
void tobuf(char *&buf, Bool_t x)
R__EXTERN TVirtualMutex * gROOTMutex
void Printf(const char *fmt,...)
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD(mutex)
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
A ROOT file is structured in Directories (like a file system).
Int_t fNbytesKeys
Number of bytes for the keys.
Long64_t fSeekKeys
Location of Keys record on file.
Bool_t fWritable
True if directory is writable.
virtual TList * GetListOfKeys() const
virtual TList * GetList() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
virtual void Close(Option_t *option="")
Close a file.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Bool_t fMustFlush
!True if the file buffers must be flushed
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
virtual void Init(Bool_t create)
Initialize a TFile object.
TString fOption
File options.
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)
Option_t * GetOption() const
Long64_t fOffset
!Seek offset cache
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Int_t fNProcessIDs
Number of TProcessID written to this file.
Int_t fWritten
Number of objects written so far.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void Delete(Option_t *option="")
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.
const ExternalDataPtr_t fExternalData
shared file data / content
bool NeedsExistingFile(EMode mode) const
Long64_t fDefaultBlockSize
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Read specified number of bytes from current offset into the buffer.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Perform a stat on the file; see TFile::SysStat().
Int_t SysClose(Int_t fd)
Close the mem file.
Long64_t fBlockOffset
Seek offset within the block.
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.
std::shared_ptr< const std::vector< char > > ExternalDataPtr_t
Long64_t fSysOffset
Seek offset in file.
bool NeedsToWrite(EMode mode) const
Int_t SysSync(Int_t fd)
Sync remaining data to disk.
Int_t SysWriteImpl(Int_t fd, const void *buf, Long64_t len)
Write a buffer into the file.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file.
virtual void Print(Option_t *option="") const
Print all objects in the file.
void ResetErrno() const
Simply calls TSystem::ResetErrno().
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in 'MemFile'.
virtual Long64_t GetSize() const
Return the current size of the memory file.
void ResetObjects(TDirectoryFile *, TFileMergeInfo *) const
Wipe all the data from the permanent buffer but keep, the in-memory object alive.
void ResetAfterMerge(TFileMergeInfo *)
Wipe all the data from the permanent buffer but keep, the in-memory object alive.
virtual ~TMemFile()
Close and clean-up file.
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...
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Seek to a specified position in the file.
TMemFile(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Long64_t defBlockSize=0LL)
Usual Constructor.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name 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=0)
Execute method on this object with the given parameter string, e.g.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * Data() const
void ToUpper()
Change string to upper case.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
static void ResetErrno()
Static function resetting system error number.
void SetErrorStr(const char *errstr)
Set the system error string.
~TMemBlock()
Usual destructors. Delete the block memory.
void CreateNext(Long64_t size)
TMemBlock()
Default constructor.