110#define _XOPEN_SOURCE 600
119#include <sys/xattr.h>
124# include <sys/types.h>
129#include "RConfigure.h"
165#include "compiledata.h"
178#include <sys/extattr.h>
199#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
202#define getxattr(path, name, value, size) extattr_get_file(path, EXTATTR_NAMESPACE_USER, name, value, size)
205const Int_t kBEGIN = 100;
211static struct AddPseudoGlobals {
224 fCacheReadMap =
new TMap();
225 SetBit(kBinaryFile,
kTRUE);
228 Info(
"TFile",
"default ctor");
370 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
372 auto zombify = [
this] {
374 if (fGlobalRegistration) {
376 gROOT->GetListOfClosedObjects()->Add(
this);
385 if (strlen(fUrl.GetProtocol()) != 0 && strcmp(fUrl.GetProtocol(),
"file") != 0 && !fOption.BeginsWith(
"NET") &&
386 !fOption.BeginsWith(
"WEB")) {
388 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
396 if (sfname1.Index(
"?") !=
kNPOS) {
397 TString s = sfname1(0, sfname1.Index(
"?"));
399 fNoAnchorInName = kTRUE;
406 fname1 = fUrl.GetFile();
409 if (strstr(fUrl.GetOptions(),
"filetype=raw"))
413 if (strstr(fUrl.GetOptions(),
"filetype=pcm"))
416 if (fUrl.HasOption(
"reproducible"))
417 SetBit(kReproducible);
420 fAsyncOpenStatus = kAOSNotAsync;
422 BuildDirectoryFile(
this,
nullptr);
424 fVersion =
gROOT->GetVersionInt();
426 fCacheReadMap =
new TMap();
427 SetBit(kBinaryFile,
kTRUE);
429 if (fIsRootFile && !fIsPcmFile && fOption !=
"NEW" && fOption !=
"CREATE"
430 && fOption !=
"RECREATE") {
435 fname1 = fArchive->GetArchiveName();
438 if (!strlen(fArchive->GetMemberName()))
443 if (fOption.Contains(
"_WITHOUT_GLOBALREGISTRATION")) {
444 fOption = fOption.ReplaceAll(
"_WITHOUT_GLOBALREGISTRATION",
"");
445 fGlobalRegistration =
false;
447 fList->UseRWLock(
false);
451 if (fOption ==
"NET")
454 if (fOption ==
"WEB") {
460 if (fOption ==
"NEW")
467 if (!create && !recreate && !
update && !read) {
474 if (!fname1 || !fname1[0]) {
475 Error(
"TFile",
"file name is not specified");
481 if (!strcmp(fname1,
"/dev/null") &&
493 if (!
gSystem->ExpandPathName(fname)) {
495 fRealName = GetName();
496 if (!
gSystem->IsAbsoluteFileName(fRealName)) {
499 fname = fRealName.Data();
501 Error(
"TFile",
"error expanding path %s", fname1);
508 if (TestBit(kReproducible)) {
509 if(
auto name=fUrl.GetValueFromOptions(
"reproducible")) {
516 if (
gSystem->Unlink(fname.Data()) != 0) {
517 SysError(
"TFile",
"could not delete %s (errno: %d)",
518 fname.Data(),
gSystem->GetErrno());
528 Error(
"TFile",
"file %s already exists", fname.Data());
538 Error(
"TFile",
"no write permission, could not open file %s", fname.Data());
545 Error(
"TFile",
"file %s does not exist", fname.Data());
550 Error(
"TFile",
"no read permission, could not open file %s", fname.Data());
564 SysError(
"TFile",
"file %s can not be opened", fname.Data());
576 SysError(
"TFile",
"file %s can not be opened for reading", fname.Data());
603 fList->Delete(
"slow");
617 gROOT->GetListOfClosedObjects()->Remove(
this);
628 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
654 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
670 if (
fArchive->SetCurrentMember() != -1)
673 Error(
"Init",
"member %s not found in archive %s",
696 if (
gEnv->GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
716 char *header =
new char[kBEGIN+200];
721 Error(
"Init",
"%s failed to read the file type data.",
728 if (strncmp(header,
"root", 4)) {
734 char *buffer = header + 4;
737 frombuf(buffer, &headerLength);
740 Int_t send,sfree,sinfo;
763 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
775 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
780 char *buffer_keyloc =
nullptr;
785 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
790 if (nbytes+
fBEGIN > kBEGIN+200) {
792 header =
new char[nbytes];
797 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
803 buffer_keyloc = header;
806 buffer_keyloc = header+
fBEGIN;
809 frombuf(buffer,&version); versiondir = version%1000;
814 if (version > 1000) {
819 Int_t sdir,sparent,skeys;
824 if (versiondir > 1)
fUUID.ReadBuffer(buffer);
827 buffer_keyloc +=
sizeof(
Int_t);
829 frombuf(buffer_keyloc, &keyversion);
831 if (keyversion > 1000) {
838 cname.ReadBuffer(buffer_keyloc);
839 cname.ReadBuffer(buffer_keyloc);
840 fTitle.ReadBuffer(buffer_keyloc);
843 Error(
"Init",
"cannot read directory info of file %s",
GetName());
860 if (
gEnv->GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
884 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
887 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
893 Warning(
"Init",
"file %s probably not closed, "
894 "trying to recover",
GetName());
902 Warning(
"Init",
"successfully recovered %d keys", nrecov);
904 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
912 gROOT->GetListOfFiles()->Add(
this);
918 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
919 if (lenIndex < 5000) lenIndex = 5000;
926 gROOT->GetListOfFiles()->Remove(
this);
931 if (
fKeys->GetSize()) {
933 const auto separator =
fVersion < 63200 ?
"/" :
".";
934 const auto thisVersion =
gROOT->GetVersionInt();
935 const auto msg =
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file. "
936 "The file was produced with ROOT version %d.%02d%s%02d, "
937 "while the current version is %d.%02d.%02d";
941 thisVersion / 10000, (thisVersion / 100) % (100), thisVersion % 100);
951 while ((key = (TKey*)next())) {
962 gROOT->GetListOfClosedObjects()->Add(
this);
1010 while ((key = iter()) !=
nullptr) {
1011 TFileCacheRead *cache =
dynamic_cast<TFileCacheRead *
>(
fCacheReadMap->GetValue(key));
1023 TFree *
f1 = (TFree*)
fFree->First();
1057 while ((pid = (TProcessID*)next())) {
1068 gROOT->GetListOfFiles()->Remove(
this);
1069 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1070 gROOT->GetListOfClosedObjects()->Add(
this);
1081 return new TKey(obj,
name, bufsize, mother);
1089 return new TKey(obj, cl,
name, bufsize, mother);
1101 static TFile *currentFile =
nullptr;
1114 Info(
"Delete",
"deleting name = %s", namecycle);
1144 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1145 if (
h->LoadPlugin() == -1)
1147 h->ExecPlugin(3,
this, keys,
option);
1186 tobuf(buffer, version);
1202 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1203 return std::numeric_limits<Int_t>::max() -1;
1219 Int_t nbytes, objlen, nwh = 64;
1220 char *header =
new char[
fBEGIN];
1226 while (idcur <
fEND-100) {
1241 if (nbytes == 0)
break;
1247 if (!objlen) objlen = nbytes-keylen;
1249 uncomp += keylen + objlen;
1284 TFileCacheRead *cache = (TFileCacheRead *)
fCacheReadMap->GetValue(tree);
1319 if (first <
fBEGIN)
return 0;
1320 if (first >
fEND)
return 0;
1322 Int_t nread = maxbytes;
1323 if (first+maxbytes >
fEND) nread =
fEND-maxbytes;
1325 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1331 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1342 if (nb < 0)
return nread;
1344 const Int_t headerSize = 16;
1345 if (nread < headerSize)
return nread;
1350 if (!olen) olen = nbytes-klen;
1369 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1391 ROOT::Internal::RConcurrentHashColl::HashValue hash;
1395 TList *list =
nullptr;
1398 auto key = std::make_unique<TKey>(
this);
1400 auto buf = buffer.data();
1404 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1406 return {
nullptr, 1, hash};
1409 if (lookupSICache) {
1416 Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1417 for(
auto uid : *si_uids)
1419 return {
nullptr, 0, hash};
1422 key->ReadKeyBuffer(buf);
1423 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1426 list = (TList*)
Get(
"StreamerInfo");
1430 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1432 return {
nullptr, 1, hash};
1435 return {list, 0, hash};
1499 TFree *
f1 = (TFree*)
fFree->First();
1501 TFree *newfree =
f1->AddFree(
fFree,first,last);
1502 if(!newfree)
return;
1506 if (nbytesl > 2000000000) nbytesl = 2000000000;
1508 char buffer[
sizeof(
Int_t)];
1509 char *pbuffer = buffer;
1510 tobuf(pbuffer, nbytes);
1580 TString options(opt);
1582 const bool forComp = options.Contains(
"forcomp");
1583 const bool extended = options.Contains(
"extended");
1585 const unsigned char nDigits = std::log10(
fEND) + 1;
1587 std::optional<ROOT::Detail::TKeyMapNode> lastNode;
1589 for (
const auto &key : tkeyInfos) {
1591 switch (key.fType) {
1593 Printf(
"Address = %" PRIu64
"\tNbytes = %u\t=====E R R O R=======", key.fAddr, key.fLen);
1597 Printf(
"Address = %" PRIu64
"\tNbytes = %d\t=====G A P===========", key.fAddr, -key.fLen);
1603 extrainfo.
Form(
" name: %-16s title: %s", key.fKeyName.c_str(), key.fKeyTitle.c_str());
1607 if (key.fObjLen !=
static_cast<Int_t>(key.fLen) - key.fKeyLen) {
1608 Float_t cx =
static_cast<float>(key.fObjLen + key.fKeyLen) / key.fLen;
1609 Printf(
"At:%-*" PRIu64
" N=%-8u K=%-3d O=%-8d %-14s CX = %5.2f %s", nDigits + 1, key.fAddr, key.fLen,
1610 key.fKeyLen, key.fObjLen, key.fClassName.c_str(), cx, extrainfo.
Data());
1612 Printf(
"At:%-*" PRIu64
" N=%-8u K=%-3d O=%-8d %-14s CX = 1 %s", nDigits + 1, key.fAddr, key.fLen,
1613 key.fKeyLen, key.fObjLen, key.fClassName.c_str(), extrainfo.
Data());
1618 if (key.fObjLen !=
static_cast<Int_t>(key.fLen) - key.fKeyLen) {
1619 Float_t cx =
static_cast<float>(key.fObjLen + key.fKeyLen) / key.fLen;
1620 Printf(
"%d/%06d At:%-*" PRIu64
" N=%-8u %-14s CX = %5.2f %s", date, time, nDigits + 1, key.fAddr,
1621 key.fLen, key.fClassName.c_str(), cx, extrainfo.
Data());
1623 Printf(
"%d/%06d At:%-*" PRIu64
" N=%-8u %-14s %s", date, time, nDigits + 1, key.fAddr,
1624 key.fLen, key.fClassName.c_str(), extrainfo.
Data());
1631 Int_t datime = lastNode ? lastNode->fDatime : 0;
1634 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s", date, time, nDigits + 1,
fEND, 1,
"END");
1636 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits + 1,
fEND, 1,
"END");
1642 return ROOT::Detail::TKeyMapIterable(
this);
1648 fCurAddr = fFile->fBEGIN;
1654 static constexpr int headerSize = 512;
1656 const std::uint64_t idcur =
fCurAddr;
1657 const std::uint64_t
end =
fFile->fEND;
1659 return std::nullopt;
1662 auto nread = headerSize;
1663 if (idcur + nread >=
end)
1664 nread =
end - idcur - 1;
1666 char header[headerSize];
1667 if (
fFile->ReadBuffer(header, nread)) {
1674 char *buffer = header;
1692 frombuf(buffer, &node.fKeyVersion);
1693 frombuf(buffer, &node.fObjLen);
1694 frombuf(buffer, &node.fDatime);
1695 frombuf(buffer, &node.fKeyLen);
1696 frombuf(buffer, &node.fCycle);
1697 if (node.fKeyVersion > 1000) {
1698 frombuf(buffer, &node.fSeekKey);
1699 frombuf(buffer, &node.fSeekPdir);
1704 node.fSeekKey =
static_cast<Long64_t>(skey);
1705 node.fSeekPdir =
static_cast<Long64_t>(sdir);
1708 const auto readString = [&buffer, &header](
bool skipCheck =
false) {
1709 std::uint8_t stringLenShort;
1710 std::uint32_t stringLen;
1711 if (!skipCheck && ((buffer - header) >= headerSize)) {
1714 frombuf(buffer, &stringLenShort);
1715 if (stringLenShort == 0xFF)
1718 stringLen = stringLenShort;
1720 if ((buffer - header) + stringLen > headerSize)
1721 stringLen = headerSize - (buffer - header);
1726 str = std::string(buffer, stringLen);
1727 buffer += stringLen;
1732 node.fClassName = readString(
true);
1734 if (idcur ==
static_cast<std::uint64_t
>(
fFile->fSeekFree))
1735 node.fClassName =
"FreeSegments";
1736 else if (idcur ==
static_cast<std::uint64_t
>(
fFile->fSeekInfo))
1737 node.fClassName =
"StreamerInfo";
1738 else if (idcur ==
static_cast<std::uint64_t
>(
fFile->fSeekKeys))
1739 node.fClassName =
"KeysList";
1741 node.fKeyName = readString();
1742 node.fKeyTitle = readString();
1754 GetList()->R__FOR_EACH(TObject,Paint)(
option);
1762 Printf(
"TFile: name=%s, title=%s, option=%s", GetName(), GetTitle(), GetOption());
1763 GetList()->R__FOR_EACH(TObject,Print)(
option);
1784 if ((st = ReadBufferViaCache(buf,
len))) {
1793 while ((siz = SysRead(fD, buf,
len)) < 0 && GetErrno() == EINTR)
1797 SysError(
"ReadBuffer",
"error reading from file %s", GetName());
1801 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1829 if ((st = ReadBufferViaCache(buf,
len))) {
1840 while ((siz = SysRead(fD, buf,
len)) < 0 && GetErrno() == EINTR)
1844 SysError(
"ReadBuffer",
"error reading from file %s", GetName());
1848 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1878 for (
Int_t j = 0; j < nbuf; j++) {
1879 if (ReadBufferAsync(
pos[j],
len[j])) {
1888 TFileCacheRead *old = fCacheRead;
1889 fCacheRead =
nullptr;
1892 char *buf2 =
nullptr;
1897 if (cur -curbegin < fgReadaheadSize) {
n++; i++; bigRead =
kFALSE;}
1898 if (bigRead || (i>=nbuf)) {
1910 if (!buf2) buf2 =
new char[fgReadaheadSize];
1917 for (
Int_t j=0;j<
n;j++) {
1918 memcpy(&buf[k],&buf2[
pos[i-
n+j]-curbegin],
len[i-
n+j]);
1923 fBytesReadExtra += extra;
1924 fBytesRead -= extra;
1925 fgBytesRead -= extra;
1928 curbegin = i < nbuf ?
pos[i] : 0;
1931 if (buf2)
delete [] buf2;
1946 Int_t st = fCacheRead->ReadBuffer(buf, off,
len);
1951 SetOffset(off +
len);
1958 if (fWritable && fCacheWrite) {
1959 if (fCacheWrite->ReadBuffer(buf, off,
len) == 0) {
1960 SetOffset(off +
len);
1981 if (fNbytesFree < 0 || fNbytesFree > fEND) {
1985 TKey *headerfree =
new TKey(fSeekFree, fNbytesFree,
this);
1991 TFree *afree =
new TFree();
1994 if (afree->
GetLast() > fEND)
break;
2006 TProcessID *pid =
nullptr;
2007 TObjArray *pids = GetListOfProcessIDs();
2008 if (pidf < pids->GetSize()) pid = (TProcessID *)pids->
UncheckedAt(pidf);
2017 snprintf(pidname,32,
"ProcessID%d",pidf);
2018 pid = (TProcessID *)Get(pidname);
2020 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",pidname,GetName(),(
size_t)pid);
2029 TIter next(pidslist);
2035 while ((p = (TProcessID*)next())) {
2105 Int_t nbytes,date,time,objlen,nwheader;
2108 char *buffer, *bufread;
2113 if ((
size = GetSize()) == -1) {
2114 Error(
"Recover",
"cannot stat the file %s", GetName());
2120 if (fWritable && !fFree) fFree =
new TList;
2124 Int_t nread = nwheader;
2126 while (idcur < fEND) {
2128 if (idcur+nread >= fEND) nread = fEND-idcur-1;
2131 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2139 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
2144 if (fWritable)
new TFree(fFree,idcur,idcur-nbytes-1);
2154 if (versionkey > 1000) {
2163 char *classname =
nullptr;
2164 if (nwhc <= 0 || nwhc > 100)
break;
2165 classname =
new char[nwhc+1];
2166 int i, nwhci = nwhc;
2167 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
2168 classname[nwhci] =
'\0';
2172 && strcmp(classname,
"TBasket")) {
2173 TKey *key =
new TKey(
this);
2175 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
2176 fSeekInfo = seekkey;
2178 fNbytesInfo = nbytes;
2184 Info(
"Recover",
"%s, recovered key %s:%s at address %lld",GetName(),key->
GetClassName(),key->
GetName(),idcur);
2187 delete [] classname;
2192 if (max_file_size < fEND) max_file_size = fEND+1000000000;
2193 TFree *last = (TFree*)fFree->Last();
2195 last->
AddFree(fFree,fEND,max_file_size);
2197 new TFree(fFree,fEND,max_file_size);
2199 if (nrecov) Write();
2222 if (opt !=
"READ" && opt !=
"UPDATE") {
2223 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2227 if (opt == fOption || (opt ==
"UPDATE" && fOption ==
"CREATE"))
2230 if (opt ==
"READ") {
2234 if (IsOpen() && IsWritable()) {
2235 WriteStreamerInfo();
2240 TFree *
f1 = (TFree*)fFree->First();
2261 fD = SysOpen(fRealName, O_RDONLY, 0666);
2263 fD = SysOpen(fRealName, O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
2266 SysError(
"ReOpen",
"file %s can not be opened in read mode", GetName());
2283 fD = SysOpen(fRealName, O_RDWR | O_CREAT, 0666);
2285 fD = SysOpen(fRealName, O_RDWR | O_CREAT |
O_BINARY, S_IREAD | S_IWRITE);
2288 SysError(
"ReOpen",
"file %s can not be opened in update mode", GetName());
2294 if (fSeekFree > fBEGIN)
2297 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments", GetName());
2310 fOffset =
offset + fArchiveOffset;
2318 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2333 offset += fArchiveOffset;
2342 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2346 if ((retpos = SysSeek(fD,
offset, whence)) < 0)
2347 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2348 offset, GetName(), retpos);
2361 if (fCompress < 0) {
2364 int level = fCompress % 100;
2365 fCompress = 100 * algorithm + level;
2374 if (level < 0) level = 0;
2375 if (level > 99) level = 99;
2376 if (fCompress < 0) {
2380 int algorithm = fCompress / 100;
2382 fCompress = 100 * algorithm + level;
2393 fCompress = settings;
2421 if (cache) fCacheReadMap->Add(tree, cache);
2425 TFileCacheRead* tpf = (TFileCacheRead *)fCacheReadMap->GetValue(tree);
2426 fCacheReadMap->Remove(tree);
2427 if (tpf && (tpf->
GetFile() ==
this) && (action != kDoNotDisconnect)) tpf->
SetFile(0, action);
2430 if (cache) cache->
SetFile(
this, action);
2431 else if (!tree && fCacheRead && (action != kDoNotDisconnect)) fCacheRead->SetFile(0, action);
2443 if (!cache && fCacheWrite)
delete fCacheWrite;
2444 fCacheWrite = cache;
2460 if (
b.IsReading()) {
2473 fSumBuffer += double(bufsize);
2474 fSum2Buffer += double(bufsize) * double(bufsize);
2491 if (!IsWritable()) {
2492 if (!TestBit(kWriteError)) {
2494 Warning(
"Write",
"file %s not opened in write mode", GetName());
2500 if (!GetTitle() || strlen(GetTitle()) == 0)
2501 Info(
"Write",
"writing name = %s", GetName());
2503 Info(
"Write",
"writing name = %s title = %s", GetName(), GetTitle());
2508 WriteStreamerInfo();
2521 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2522 return const_cast<TFile*
>(
this)->Write(
n, opt, bufsize);
2531 if (IsOpen() && fWritable) {
2534 if ((st = WriteBufferViaCache(buf,
len))) {
2542 while ((siz = SysWrite(fD, buf,
len)) < 0 && GetErrno() == EINTR)
2547 SetBit(kWriteError); SetWritable(
kFALSE);
2548 SysError(
"WriteBuffer",
"error writing to file %s (%ld)", GetName(), (
Long_t)siz);
2552 SetBit(kWriteError);
2553 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2558 fgBytesWrite += siz;
2574 if (!fCacheWrite)
return 0;
2578 if ((st = fCacheWrite->WriteBuffer(buf, off,
len)) < 0) {
2579 SetBit(kWriteError);
2580 Error(
"WriteBuffer",
"error writing to cache");
2599 if (fSeekFree != 0) {
2600 MakeFree(fSeekFree, fSeekFree + fNbytesFree -1);
2605 auto createKey = [
this]() {
2609 while ((afree = (TFree*) next())) {
2610 nbytes += afree->
Sizeof();
2612 if (!nbytes)
return (TKey*)
nullptr;
2614 TKey *key =
new TKey(fName,fTitle,
IsA(),nbytes,
this);
2618 return (TKey*)
nullptr;
2623 TKey *key = createKey();
2640 char *
start = buffer;
2644 while ((afree = (TFree*) next())) {
2649 auto actualBytes = buffer-
start;
2650 if ( actualBytes != nbytes ) {
2651 if (actualBytes < nbytes) {
2654 memset(buffer,0,nbytes-actualBytes);
2656 Error(
"WriteFree",
"The free block list TKey wrote more data than expected (%d vs %ld). Most likely there has been an out-of-bound write.",nbytes,(
long int)actualBytes);
2671 TFree *lastfree = (TFree*)fFree->Last();
2672 if (lastfree) fEND = lastfree->
GetFirst();
2673 const char *root =
"root";
2674 char *psave =
new char[fBEGIN];
2675 char *buffer = psave;
2676 Int_t nfree = fFree->GetSize();
2677 memcpy(buffer, root, 4); buffer += 4;
2678 Int_t version = fVersion;
2679 if (version <1000000 && fEND > kStartBigFile) {version += 1000000; fUnits = 8;}
2680 tobuf(buffer, version);
2682 if (version < 1000000) {
2685 tobuf(buffer, fNbytesFree);
2686 tobuf(buffer, nfree);
2687 tobuf(buffer, fNbytesName);
2688 tobuf(buffer, fUnits);
2689 tobuf(buffer, fCompress);
2691 tobuf(buffer, fNbytesInfo);
2693 tobuf(buffer, fEND);
2694 tobuf(buffer, fSeekFree);
2695 tobuf(buffer, fNbytesFree);
2696 tobuf(buffer, nfree);
2697 tobuf(buffer, fNbytesName);
2698 tobuf(buffer, fUnits);
2699 tobuf(buffer, fCompress);
2700 tobuf(buffer, fSeekInfo);
2701 tobuf(buffer, fNbytesInfo);
2703 if (TestBit(kReproducible))
2704 TUUID(
"00000000-0000-0000-0000-000000000000").FillBuffer(buffer);
2706 fUUID.FillBuffer(buffer);
2707 Int_t nbytes = buffer - psave;
2709 WriteBuffer(psave, nbytes);
2785 void *dir =
gSystem->OpenDirectory(dirname);
2794 }
else if (opt.
Contains(
"recreate")) {
2797 if (
gSystem->mkdir(dirname) < 0) {
2798 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2804 const char *afile =
gSystem->GetDirEntry(dir);
2806 if (strcmp(afile,
".") == 0)
continue;
2807 if (strcmp(afile,
"..") == 0)
continue;
2808 dirpath.
Form(
"%s/%s",dirname,afile);
2816 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2820 if (
gSystem->mkdir(dirname) < 0) {
2821 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2833 TList *filelist = (TList*)GetStreamerInfoCache();
2834 if (filelist) filelist = (TList*)filelist->
Clone();
2836 Error(
"MakeProject",
"file %s has no StreamerInfo", GetName());
2840 TString clean_dirname(dirname);
2841 if (clean_dirname[clean_dirname.Length()-1]==
'/') {
2842 clean_dirname.Remove(clean_dirname.Length()-1);
2843 }
else if (clean_dirname[clean_dirname.Length()-1]==
'\\') {
2844 clean_dirname.Remove(clean_dirname.Length()-1);
2845 if (clean_dirname[clean_dirname.Length()-1]==
'\\') {
2846 clean_dirname.Remove(clean_dirname.Length()-1);
2849 TString subdirname(
gSystem->BaseName(clean_dirname) );
2850 if (subdirname ==
"") {
2851 Error(
"MakeProject",
"Directory name must not be empty.");
2856 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.Data(),subdirname.Data());
2857 FILE *sfp = fopen(spath.
Data(),
"w");
2859 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2862 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2863 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.Data() );
2864 if (!genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.Data() );
2865 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.Data() );
2866 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2867 fprintf(sfp,
" template <typename T>\n");
2868 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2869 fprintf(sfp,
" delete ptr;\n");
2870 fprintf(sfp,
" }\n");
2871 fprintf(sfp,
" template <typename T, typename Q>\n");
2872 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2873 fprintf(sfp,
" // Do nothing\n");
2874 fprintf(sfp,
" }\n");
2875 fprintf(sfp,
" template <typename T, typename Q>\n");
2876 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2877 fprintf(sfp,
" delete ptr.second;\n");
2878 fprintf(sfp,
" }\n");
2879 fprintf(sfp,
" template <typename T, typename Q>\n");
2880 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2881 fprintf(sfp,
" delete ptr.first;\n");
2882 fprintf(sfp,
" }\n");
2883 fprintf(sfp,
" template <typename T, typename Q>\n");
2884 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2885 fprintf(sfp,
" delete ptr.first;\n");
2886 fprintf(sfp,
" delete ptr.second;\n");
2887 fprintf(sfp,
" }\n");
2888 fprintf(sfp,
"};\n\n");
2894 TStreamerInfo *info;
2895 TIter flnext(filelist);
2897 TList *list =
new TList();
2898 while ((info = (TStreamerInfo*)flnext())) {
2902 if (strstr(info->
GetName(),
"@@")) {
2913 TStreamerElement *el;
2914 ROOT::Detail::TSchemaRuleSet::TMatches rules;
2918 while( (el=(TStreamerElement*)enext()) ) {
2919 for(
auto rule : rules) {
2920 if( rule->IsRenameRule() || rule->IsAliasRule() )
2923 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2924 TString
attr( rule->GetAttributes() );
2926 if (
attr.Contains(
"owner")) {
2927 if (
attr.Contains(
"notowner")) {
2937 TVirtualStreamerInfo *alternate = (TVirtualStreamerInfo*)list->
FindObject(info->
GetName());
2950 TIter nextextra(&extrainfos);
2951 while ((info = (TStreamerInfo*)nextextra())) {
2953 filelist->
Add(info);
2959 while ((info = (TStreamerInfo*)next())) {
2964 TIter subnext(list);
2965 TStreamerInfo *subinfo;
2968 while ((subinfo = (TStreamerInfo*)subnext())) {
2979 subClasses.
Add(subinfo);
2984 subClasses.
Clear(
"nodelete");
2986 extrainfos.
Clear(
"nodelete");
2989 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.Data(),subdirname.Data());
2990 FILE *allfp = fopen(path,
"a");
2992 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2994 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.Data());
2998 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.Data());
3009 FILE *fpMAKE =
nullptr;
3013 path.
Form(
"%s/makep.cmd",clean_dirname.Data());
3015 path.
Form(
"%s/MAKEP",clean_dirname.Data());
3018 fpMAKE = fopen(path,
"wb");
3020 fpMAKE = fopen(path,
"w");
3023 Error(
"MakeProject",
"cannot open file %s", path.
Data());
3031 FILE *ifp =
nullptr;
3032 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.Data(),subdirname.Data());
3034 ifp = fopen(path,
"wb");
3036 ifp = fopen(path,
"w");
3039 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3048 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.Data(),subdirname.Data(),
gSystem->GetIncludePath());
3049 path.
Form(
"%s/%sSelection.xml",clean_dirname.Data(),subdirname.Data());
3051 fprintf(fpMAKE,
"rootcling -v1 -f %sProjectDict.cxx %s ", subdirname.Data(),
gSystem->GetIncludePath());
3052 path.
Form(
"%s/%sLinkDef.h",clean_dirname.Data(),subdirname.Data());
3058 FILE *fp = fopen(path,
"wb");
3060 FILE *fp = fopen(path,
"w");
3063 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3072 fprintf(fp,
"<lcgdict>\n");
3075 fprintf(fp,
"#ifdef __CLING__\n");
3083 while ((info = (TStreamerInfo*)next())) {
3087 if (strncmp(info->
GetName(),
"auto_ptr<", std::char_traits<char>::length(
"auto_ptr<")) == 0) {
3096 for(
auto rule : rules) {
3099 rule->AsString(strrule,
"x");
3102 selections.
Append(strrule);
3105 rule->AsString(strrule);
3106 if (strncmp(strrule.
Data(),
"type=",5)==0) {
3109 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
3116 std::vector<std::string> inside;
3123 switch ( stlkind ) {
3127 what =
"std::pair<";
3137 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3141 tmp.
Form(
"template class %s;\n",
what.Data());
3146 what.ReplaceAll(
"std::",
"");
3149 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3157 tmp.
Form(
"<class name=\"%s\" />\n",key->
GetName());
3166 what.ReplaceAll(
"std::",
"");
3167 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3178 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3182 if (
what[
what.Length()-1] ==
'>') {
3183 tmp.
Form(
"template class %s;\n",
what.Data());
3189 what.ReplaceAll(
"std::",
"");
3190 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3196 TStreamerElement *element;
3197 while( (element = (TStreamerElement*)eliter() ) ) {
3200 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3204 tmp.
Form(
"template class %s;\n",
what.Data());
3213 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3214 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3215 fprintf(ifp,
"%s",instances.
Data());
3216 fprintf(ifp,
"#endif\n");
3217 fprintf(fp,
"%s",selections.
Data());
3218 fprintf(fp,
"</lcgdict>\n");
3220 fprintf(fp,
"#endif\n");
3226 TString sdirname(subdirname);
3228 TString cmd =
gSystem->GetMakeSharedLib();
3229 TString sources =
TString::Format(
"%sProjectSource.cxx ", sdirname.Data());
3231 TString
object =
TString::Format(
"%sProjectSource.", sdirname.Data());
3232 object.Append(
gSystem->GetObjExt() );
3233 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3234 cmd.
ReplaceAll(
"$IncludePath",TString(
gSystem->GetIncludePath()) +
" -I" + clean_dirname.Data());
3241 TString rootbuild = ROOTBUILD;
3243 sOpt =
gSystem->GetFlagsOpt();
3245 sOpt =
gSystem->GetFlagsDebug();
3247#if defined(_MSC_VER) && defined(_DEBUG)
3250 sOpt =
gSystem->GetFlagsDebug();
3255 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.Data());
3257 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.Data());
3258 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.Data());
3261 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3263 printf(
"%s/MAKEP file has been generated\n", clean_dirname.Data());
3268 if (!opt.
Contains(
"nocompilation")) {
3270 path =
gSystem->WorkingDirectory();
3271 gSystem->ChangeDirectory(clean_dirname.Data());
3273 gSystem->Exec(
"chmod +x MAKEP");
3274 int res = !
gSystem->Exec(
"./MAKEP");
3277 chmod(
"makep.cmd",00700);
3278 int res = !
gSystem->Exec(
"MAKEP");
3280 gSystem->ChangeDirectory(path);
3281 path.
Form(
"%s/%s.%s",clean_dirname.Data(),subdirname.Data(),
gSystem->GetSoExt());
3282 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3287 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3306 auto listRetcode = GetStreamerInfoListImpl(
true);
3307 TList *list = listRetcode.fList;
3308 auto retcode = listRetcode.fReturnCode;
3310 if (retcode) MakeZombie();
3316 if (
gDebug > 0)
Info(
"ReadStreamerInfo",
"called for file %s",GetName());
3318 TStreamerInfo *info;
3320 Int_t version = fVersion;
3321 if (version > 1000000) version -= 1000000;
3322 if (version < 53419 || (59900 < version && version < 59907)) {
3328 info = (TStreamerInfo*)lnk->
GetObject();
3334 TStreamerElement *element;
3335 while ((element = (TStreamerElement*) next())) {
3336 TStreamerBase *base =
dynamic_cast<TStreamerBase*
>(element);
3337 if (!base)
continue;
3348 std::vector<Int_t> si_uids;
3355 info = (TStreamerInfo*)lnk->
GetObject();
3362 TObject *obj = (TObject*)info;
3363 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3366 TList *listOfRules = (TList*)obj;
3367 TObjLink *rulelnk = listOfRules->
FirstLink();
3369 TObjString *rule = (TObjString*)rulelnk->
GetObject();
3371 rulelnk = rulelnk->
Next();
3375 Warning(
"ReadStreamerInfo",
"%s has a %s in the list of TStreamerInfo.", GetName(), info->
IsA()->
GetName());
3385 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3390 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3392 if ( (!isstl &&
mode ==0) || (isstl &&
mode ==1) ) {
3397 Int_t asize = fClassIndex->GetSize();
3398 if (uid >= asize && uid <100000) fClassIndex->Set(2*asize);
3399 if (uid >= 0 && uid < fClassIndex->GetSize()) {
3400 si_uids.push_back(uid);
3401 fClassIndex->fArray[uid] = 1;
3404 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3411 fClassIndex->fArray[0] = 0;
3417 fgTsSIHashes.Insert(listRetcode.fHash, std::move(si_uids));
3433 fgReadInfo = readinfo;
3451 TList *list = GetStreamerInfoList();
3464 TProcessID *pid = pidd;
3466 TObjArray *pids = GetListOfProcessIDs();
3467 Int_t npids = GetNProcessIDs();
3468 for (
Int_t i=0;i<npids;i++) {
3478 this->IncrementProcessIDs();
3480 Info(
"WriteProcessID",
"name=%s, file=%s",
name, GetName());
3494 if (!fWritable)
return;
3495 if (!fClassIndex)
return;
3496 if (fIsPcmFile)
return;
3497 if (fClassIndex->fArray[0] == 0
3498 && fSeekInfo != 0) {
3504 if (
gDebug > 0)
Info(
"WriteStreamerInfo",
"called for file %s",GetName());
3509 TIter next(
gROOT->GetListOfStreamerInfo());
3510 TStreamerInfo *info;
3514 listOfRules.
SetName(
"listOfRules");
3515 std::set<TClass*> classSet;
3517 while ((info = (TStreamerInfo*)next())) {
3519 if (fClassIndex->fArray[uid]) {
3521 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3527 if ( classSet.find( clinfo ) == classSet.end() ) {
3528 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3531 ROOT::TSchemaRule *rule;
3532 while( (rule = (ROOT::TSchemaRule*)it.Next()) ) {
3533 TObjString *obj =
new TObjString();
3535 listOfRules.
Add(obj);
3537 classSet.insert(clinfo);
3544 fClassIndex->fArray[0] = 2;
3548 list.
Add(&listOfRules);
3552 if (fSeekInfo) MakeFree(fSeekInfo,fSeekInfo+fNbytesInfo-1);
3554 TKey key(&list,
"StreamerInfo",GetBestBuffer(),
this);
3555 fKeys->Remove(&key);
3556 fSeekInfo = key.GetSeekKey();
3557 fNbytesInfo = key.GetNbytes();
3558 SumBuffer(key.GetObjlen());
3561 fClassIndex->fArray[0] = 0;
3578 if (fgCacheFileDir ==
"") {
3580 "you want to read through a cache, but you have no valid cache "
3581 "directory set - reading remotely");
3582 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3586 if ((!strcmp(fileurl.GetProtocol(),
"file"))) {
3588 if (!fgCacheFileForce)
3590 "you want to read through a cache, but you are reading "
3591 "local files - CACHEREAD disabled");
3595 TString cachefilepath;
3596 TString cachefilepathbasedir;
3597 cachefilepath = fgCacheFileDir;
3598 cachefilepath += fileurl.GetFile();
3599 cachefilepathbasedir =
gSystem->GetDirName(cachefilepath);
3600 if ((
gSystem->mkdir(cachefilepathbasedir,
kTRUE) < 0) &&
3602 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3603 "cannot create the directory %s - CACHEREAD disabled",
3604 cachefilepathbasedir.
Data());
3607 if (strlen(fileurl.GetAnchor())) {
3609 cachefilepath +=
"__";
3610 cachefilepath += fileurl.GetAnchor();
3611 fileurl.SetAnchor(
"");
3613 if (strstr(
name,
"zip=")) {
3615 TString urloptions = fileurl.GetOptions();
3617 TObjArray *objOptions = urloptions.
Tokenize(
"&");
3618 Int_t optioncount = 0;
3621 TString loption = ((TObjString*)objOptions->
At(
n))->GetName();
3622 TObjArray *objTags = loption.
Tokenize(
"=");
3624 TString key = ((TObjString*)objTags->
At(0))->
GetName();
3625 TString
value = ((TObjString*)objTags->
At(1))->GetName();
3627 if (optioncount!=0) {
3632 newoptions +=
value;
3641 fileurl.SetOptions(newoptions.
Data());
3642 cachefilepath +=
"__";
3643 cachefilepath += zipname;
3644 fileurl.SetAnchor(
"");
3654 if (!
gSystem->GetPathInfo(cachefilepath, &
id, &
size, &flags, &modtime)) {
3656 if (!fgCacheFileDisconnected) {
3657 char cacheblock[256];
3658 char remotblock[256];
3661 cfurl = cachefilepath;
3662 cfurl +=
"?filetype=raw";
3664 TString ropt = rurl.GetOptions();
3665 ropt +=
"&filetype=raw";
3666 rurl.SetOptions(ropt);
3668 Bool_t forcedcache = fgCacheFileForce;
3669 fgCacheFileForce =
kFALSE;
3672 TFile *remotfile =
TFile::Open(rurl.GetUrl(),
"READ");
3674 fgCacheFileForce = forcedcache;
3678 ::Error(
"TFile::OpenFromCache",
3679 "cannot open the cache file to check cache consistency");
3684 ::Error(
"TFile::OpenFromCache",
3685 "cannot open the remote file to check cache consistency");
3692 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3694 if (memcmp(cacheblock, remotblock, 256)) {
3695 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3696 "differs from the remote file - forcing an update");
3700 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
3701 "remote file are not readable - forcing an update");
3713 Bool_t forcedcache = fgCacheFileForce;
3714 fgCacheFileForce =
kFALSE;
3716 const auto cachefilepathtmp = cachefilepath + std::to_string(
gSystem->GetPid()) +
".tmp";
3719 "you want to read through a cache, but I "
3720 "cannot make a cache copy of %s - CACHEREAD disabled",
3721 cachefilepathbasedir.
Data());
3722 fgCacheFileForce = forcedcache;
3725 if (
gSystem->AccessPathName(cachefilepath))
3726 gSystem->Rename(cachefilepathtmp, cachefilepath);
3728 gSystem->Unlink(cachefilepathtmp);
3730 fgCacheFileForce = forcedcache;
3731 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
name, cachefilepath.
Data());
3733 fileurl.SetProtocol(
"file");
3734 fileurl.SetFile(cachefilepath);
3737 tagfile = cachefilepath;
3738 tagfile +=
".ROOT.cachefile";
3741 return TFile::Open(fileurl.GetUrl(),
"READ", ftitle, compress, netopt);
3793 EFileType
type = kFile;
3796 if (!url || strlen(url) <= 0) {
3797 ::Error(
"TFile::Open",
"no url specified");
3801 TString expandedUrl(url);
3802 gSystem->ExpandPathName(expandedUrl);
3806 if (
gEnv->GetValue(
"TFile.CrossProtocolRedirects", 1) == 1) {
3807 TUrl fileurl(expandedUrl,
kTRUE);
3808 if (strcmp(fileurl.GetProtocol(),
"file") == 0) {
3809 ssize_t
len = getxattr(fileurl.GetFile(),
"eos.url.xroot",
nullptr, 0);
3811 std::string xurl(
len, 0);
3812 std::string fileNameFromUrl{fileurl.GetFile()};
3813 if (getxattr(fileNameFromUrl.c_str(),
"eos.url.xroot", &xurl[0],
len) ==
len) {
3816 if (
auto baseName = fileNameFromUrl.substr(fileNameFromUrl.find_last_of(
"/") + 1);
3817 std::equal(baseName.crbegin(), baseName.crend(), xurl.crbegin())) {
3818 if ((
f =
TFile::Open(xurl.c_str(), options, ftitle, compress, netopt))) {
3819 if (!
f->IsZombie()) {
3836 TString opts(options);
3838 Int_t ito = opts.Index(
"TIMEOUT=");
3840 TString sto = opts(ito + std::char_traits<char>::length(
"TIMEOUT="), opts.Length());
3845 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
3847 sto.
Insert(0,
"TIMEOUT=");
3850 TFileOpenHandle *fh =
TFile::AsyncOpen(expandedUrl, opts, ftitle, compress, netopt);
3865 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
3867 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
3872 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.Data());
3879 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
3880 opts.ReplaceAll(
"TIMEOUT=",
"");
3885 const char *
option = opts;
3888 TString namelist(expandedUrl);
3889 Ssiz_t ip = namelist.Index(
"|");
3892 RedirectHandle_t rh;
3894 TString outf =
".TFileOpen_";
3895 FILE *fout =
gSystem->TempFileName(outf);
3898 gSystem->RedirectOutput(outf,
"w", &rh);
3905 while (namelist.Tokenize(
n, from,
"|") && !
f) {
3908 if (!strcasecmp(option,
"CACHEREAD") ||
3909 ((!strcasecmp(option,
"READ") || !strcasecmp(option,
"READ_WITHOUT_GLOBALREGISTRATION") || !option[0]) &&
3910 fgCacheFileForce)) {
3916 IncrementFileCounter();
3921 name = urlname.GetUrl();
3923 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
3924 TIter nxr(fgAsyncOpenRequests);
3925 TFileOpenHandle *fh =
nullptr;
3926 while ((fh = (TFileOpenHandle *)nxr()))
3931 TString urlOptions(urlname.GetOptions());
3932 if (urlOptions.BeginsWith(
"pmerge") || urlOptions.Contains(
"&pmerge") || urlOptions.Contains(
" pmerge")) {
3936 f = (TFile*)
gROOT->ProcessLineFast(
TString::Format(
"new TParallelMergingFile(\"%s\",\"%s\",\"%s\",%d)",
n.Data(),option,ftitle,compress));
3940 TString lfname =
gEnv->GetValue(
"Path.Localroot",
"");
3943 if (
type == kLocal) {
3947 urlname.SetHost(
"");
3948 urlname.SetProtocol(
"file");
3949 lfname = urlname.GetUrl();
3951 f =
new TFile(lfname.
Data(), option, ftitle, compress);
3953 }
else if (
type == kNet) {
3956 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
3957 if (
h->LoadPlugin() == -1)
3959 f = (TFile*)
h->ExecPlugin(5,
name.Data(), option, ftitle, compress, netopt);
3962 }
else if (
type == kWeb) {
3965 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
3966 if (
h->LoadPlugin() == -1)
3968 f = (TFile*)
h->ExecPlugin(2,
name.Data(), option);
3971 }
else if (
type == kFile) {
3974 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
3975 h->LoadPlugin() == 0) {
3976 name.ReplaceAll(
"file:",
"");
3977 f = (TFile*)
h->ExecPlugin(4,
name.Data(), option, ftitle, compress);
3979 f =
new TFile(
name.Data(), option, ftitle, compress);
3984 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
3985 if (
h->LoadPlugin() == -1)
3987 f = (TFile *)
h->ExecPlugin(4,
name.Data(), option, ftitle, compress);
3991 if (strcmp(
name, urlname.GetFileAndOptions()) != 0)
3992 f =
TFile::Open(urlname.GetFileAndOptions(), option, ftitle, compress);
3997 if (
f &&
f->IsZombie()) {
3998 TString newUrl =
f->GetNewUrl();
4000 if( newUrl.
Length() && (newUrl !=
name) &&
gEnv->GetValue(
"TFile.CrossProtocolRedirects", 1) )
4009 gSystem->RedirectOutput(0,
"", &rh);
4019 if (
type != kLocal &&
type != kFile &&
4020 f &&
f->IsWritable() && !
f->IsRaw()) {
4021 new TFileCacheWrite(
f, 1);
4055 const char *ftitle,
Int_t compress,
4058 TFileOpenHandle *fh =
nullptr;
4063 if (!url || strlen(url) <= 0) {
4064 ::Error(
"TFile::AsyncOpen",
"no url specified");
4069 TString namelist(url);
4070 gSystem->ExpandPathName(namelist);
4071 Ssiz_t ip = namelist.Index(
"|");
4074 RedirectHandle_t rh;
4076 TString outf =
".TFileAsyncOpen_";
4077 FILE *fout =
gSystem->TempFileName(outf);
4080 gSystem->RedirectOutput(outf,
"w", &rh);
4087 while (namelist.Tokenize(
n, from,
"|") && !
f) {
4092 name = urlname.GetUrl();
4097 TPluginHandler *
h =
nullptr;
4102 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4103 !strcmp(
h->GetClass(),
"TNetXNGFile")
4104 &&
h->LoadPlugin() == 0) {
4105 f = (TFile*)
h->ExecPlugin(6,
name.Data(), option, ftitle, compress, netopt,
kTRUE);
4113 gSystem->RedirectOutput(0,
"", &rh);
4115 if (!notfound && !
f)
4126 fh =
new TFileOpenHandle(
name, option, ftitle, compress, netopt);
4129 fh =
new TFileOpenHandle(
f);
4135 if (!fgAsyncOpenRequests)
4136 fgAsyncOpenRequests =
new TList;
4137 fgAsyncOpenRequests->Add(fh);
4155 if (fh && fgAsyncOpenRequests) {
4158 fgAsyncOpenRequests->Remove(fh);
4160 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4162 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4163 !strcmp(
f->GetOption(),
"RECREATE") ||
4174 if (
f)
f->fAsyncHandle = fh;
4186#if defined(R__WINGCC)
4190#elif defined(R__SEEK64)
4191 return ::open64(pathname, flags,
mode);
4193 return ::open(pathname, flags,
mode);
4202 if (fd < 0)
return 0;
4211 return ::read(fd, buf,
len);
4219 return ::write(fd, buf,
len);
4230#if defined (R__SEEK64)
4231 return ::lseek64(fd,
offset, whence);
4233 return ::_lseeki64(fd,
offset, whence);
4235 return ::lseek(fd,
offset, whence);
4249 return gSystem->GetPathInfo(fRealName,
id,
size, flags, modtime);
4257 if (TestBit(kDevNull))
return 0;
4262 return ::_commit(fd);
4271 return fCacheWrite ? fCacheWrite->GetBytesInCache() + fBytesWrite : fBytesWrite;
4288 return fgBytesWrite;
4304 return fgReadaheadSize;
4332 TString cached{cachedir};
4340 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it", TString(cachedir).Data());
4341 fgCacheFileDir =
"";
4348 fgCacheFileDir = cached;
4349 fgCacheFileDisconnected = operatedisconnected;
4350 fgCacheFileForce = forcecacheread;
4359 return fgCacheFileDir;
4371 if (fgCacheFileDir ==
"") {
4381 TString cachetagfile = fgCacheFileDir;
4382 cachetagfile +=
".tag.ROOT.cache";
4383 if (!
gSystem->GetPathInfo(cachetagfile, &
id, &
size, &flags, &modtime)) {
4386 if (lastcleanuptime < cleanupinterval) {
4387 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4393 cachetagfile +=
"?filetype=raw";
4394 TFile *tagfile =
nullptr;
4396 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4397 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4405#if defined(R__WIN32)
4406 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4407#elif defined(R__MACOSX)
4408 cmd.
Form(
"perl -e 'my $cachepath = \"%s\"; my $cachesize = %lld;my $findcommand=\"find $cachepath -type f -exec stat -f \\\"\\%%a::\\%%N::\\%%z\\\" \\{\\} \\\\\\;\";my $totalsize=0;open FIND, \"$findcommand | sort -k 1 |\";while (<FIND>) { my ($accesstime, $filename, $filesize) = split \"::\",$_; $totalsize += $filesize;if ($totalsize > $cachesize) {if ( ( -e \"${filename}.ROOT.cachefile\" ) || ( -e \"${filename}\" ) ) {unlink \"$filename.ROOT.cachefile\";unlink \"$filename\";}}}close FIND;' ", fgCacheFileDir.Data(),shrinksize);
4410 cmd.
Form(
"perl -e 'my $cachepath = \"%s\"; my $cachesize = %lld;my $findcommand=\"find $cachepath -type f -exec stat -c \\\"\\%%x::\\%%n::\\%%s\\\" \\{\\} \\\\\\;\";my $totalsize=0;open FIND, \"$findcommand | sort -k 1 |\";while (<FIND>) { my ($accesstime, $filename, $filesize) = split \"::\",$_; $totalsize += $filesize;if ($totalsize > $cachesize) {if ( ( -e \"${filename}.ROOT.cachefile\" ) || ( -e \"${filename}\" ) ) {unlink \"$filename.ROOT.cachefile\";unlink \"$filename\";}}}close FIND;' ", fgCacheFileDir.Data(),shrinksize);
4416 if ((
gSystem->Exec(cmd)) != 0) {
4417 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4429 UInt_t to = fgOpenTimeout;
4430 fgOpenTimeout = timeout;
4439 return fgOpenTimeout;
4450 fgOnlyStaged = onlystaged;
4459 return fgOnlyStaged;
4475 if (!strcmp(u.GetFile(), fUrl.GetFile())) {
4477 if (u.GetPort() == fUrl.GetPort()) {
4478 if (!strcmp(u.GetHostFQDN(), fUrl.GetHostFQDN())) {
4496 return fFile->Matches(url);
4497 }
else if (fName.Length() > 0){
4501 if (!strcmp(u.GetFile(), uref.GetFile())) {
4503 if (u.GetPort() == uref.GetPort()) {
4505 if (!strcmp(u.GetHostFQDN(), uref.GetHostFQDN())) {
4528 TPMERegexp re(
"^(root|xroot).*",
"i");
4529 if (re.Match(
name)) {
4543 Bool_t forceRemote =
gEnv->GetValue(
"Path.ForceRemote", 0);
4544 forceRemote = (forceRemote) ?
kTRUE :
gEnv->GetValue(
"TFile.ForceRemote", 0);
4545 TString opts = url.GetOptions();
4547 forceRemote =
kTRUE;
4555 const char *fname = url.GetFileAndOptions();
4557 if (fname[0] ==
'/') {
4559 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4562 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4565 lfname.
Form(
"%s/%s",
gSystem->HomeDirectory(), fname);
4573 TString fn = TUrl(lfname).GetFile();
4574 if (!
gSystem->ExpandPathName(fn)) {
4580 if (localFile && prefix)
4586 type = (localFile) ? kLocal :
type;
4587 }
else if (TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").Match(
name)) {
4591 }
else if (!strncmp(
name,
"file:", 5)) {
4606 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
4607 TIter nxr(fgAsyncOpenRequests);
4608 TFileOpenHandle *fh =
nullptr;
4609 while ((fh = (TFileOpenHandle *)nxr()))
4616 TSeqCollection *of =
gROOT->GetListOfFiles();
4617 if (of && (of->
GetSize() > 0)) {
4620 while ((
f = (TFile *)nxf()))
4621 if (
f->Matches(
name))
4622 return f->GetAsyncOpenStatus();
4626 return kAOSNotAsync;
4634 if (handle && handle->
fFile) {
4652 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
4653 TIter nxr(fgAsyncOpenRequests);
4654 TFileOpenHandle *fh =
nullptr;
4655 while ((fh = (TFileOpenHandle *)nxr()))
4663 TSeqCollection *of =
gROOT->GetListOfFiles();
4664 if (of && (of->
GetSize() > 0)) {
4667 while ((
f = (TFile *)nxf()))
4668 if (
f->Matches(
name))
4669 return f->GetEndpointUrl();
4673 return (
const TUrl *)
nullptr;
4681 fprintf(stderr,
"[TFile::Cp] Total %.02f MB\t|", (
Double_t)
size/1048576);
4683 for (
int l = 0;
l < 20;
l++) {
4685 if (
l < 20*bytesread/
size)
4686 fprintf(stderr,
"=");
4687 else if (
l == 20*bytesread/
size)
4688 fprintf(stderr,
">");
4689 else if (
l > 20*bytesread/
size)
4690 fprintf(stderr,
".");
4692 fprintf(stderr,
"=");
4698 fprintf(stderr,
"| %.02f %% [%.01f MB/s]\r",
4699 100.0*(
size?(bytesread/((
float)
size)):1), (lCopy_time>0.)?bytesread/lCopy_time/1048576.:0.);
4713 TUrl dURL(dst,
kTRUE);
4715 TString oopt =
"RECREATE";
4716 TString ourl = dURL.GetUrl();
4719 TString opt = dURL.GetOptions();
4723 opt +=
"filetype=raw";
4725 dURL.SetOptions(opt);
4727 char *copybuffer =
nullptr;
4729 TFile *sfile =
this;
4730 TFile *dfile =
nullptr;
4736 if (
gSystem->AccessPathName(ourl)) {
4740 dURL.SetOptions(opt);
4745 if (!(dfile =
TFile::Open(dURL.GetUrl(), oopt))) {
4746 ::Error(
"TFile::Cp",
"cannot open destination file %s", dst);
4752 rmdestiferror =
kTRUE;
4757 copybuffer =
new char[bufsize];
4759 ::Error(
"TFile::Cp",
"cannot allocate the copy buffer");
4764 Long64_t read, written, totalread, filesize, b00;
4774 if (progressbar) CpProgress(totalread, filesize,watch);
4779 if (filesize - b1 > (
Long64_t)bufsize) {
4782 readsize = filesize - b1;
4785 if (readsize == 0)
break;
4791 if ((read <= 0) || readop) {
4792 ::Error(
"TFile::Cp",
"cannot read from source file %s. readsize=%lld read=%lld readop=%d",
4793 sfile->
GetName(), readsize, read, readop);
4800 if ((written != read) || writeop) {
4801 ::Error(
"TFile::Cp",
"cannot write %lld bytes to destination file %s", read, dst);
4805 }
while (read == (
Long64_t)bufsize);
4808 CpProgress(totalread, filesize,watch);
4809 fprintf(stderr,
"\n");
4815 if (dfile) dfile->
Close();
4817 if (dfile)
delete dfile;
4818 if (copybuffer)
delete[] copybuffer;
4820 if (rmdestiferror && (success !=
kTRUE))
4838 TFile *sfile =
nullptr;
4843 if (!(sfile =
TFile::Open(sURL.GetUrl(),
"READ"))) {
4844 ::Error(
"TFile::Cp",
"cannot open source file %s",
src);
4846 success = sfile->
Cp(dst, progressbar, bufsize);
4861#if defined(R__neverLINUX) && !defined(R__WINGCC)
4873 int advice = POSIX_FADV_WILLNEED;
4878 advice = POSIX_FADV_NORMAL;
4882#if defined(R__SEEK64)
4909 TFileCacheRead *cr =
nullptr;
4910 if ((cr = GetCacheRead())) {
void frombuf(char *&buf, Bool_t *x)
void tobuf(char *&buf, Bool_t x)
T ReadBuffer(TBufferFile *buf)
One of the template functions used to read objects from messages.
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TClass * IsA() const override
bool Bool_t
Boolean (0=false, 1=true) (bool).
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short).
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
int Ssiz_t
String size (currently int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
float Float_t
Float 4 bytes (float).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
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)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void SysError(const char *location, const char *msgfmt,...)
Use this function in case a system (OS or GUI) related error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
if(err< fMinRelativeError)
externTPluginManager * gPluginMgr
externTVirtualMutex * gROOTMutex
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
externTVirtualMonitoringWriter * gMonitoringWriter
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
std::optional< TKeyMapNode > Next()
TIterator(TFile *file, std::uint64_t addr)
const TMatches FindRules(const TString &source) const
Return all the rules that are about the given 'source' class.
const TObjArray * GetRules() const
This class is a thread-safe associative collection connecting a 256 bits digest/hash to a collection ...
void AsString(TString &out, const char *options="") const
Add to the string 'out' the string representation of the rule.
static TArchiveFile * Open(const char *url, TFile *file)
Return proper archive file handler depending on passed url.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t IsSyntheticPair() const
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
Bool_t HasInterpreterInfo() const
const ROOT::Detail::TSchemaRuleSet * GetSchemaRules() const
Return the set of the schema rules if any.
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
static Bool_t AddRule(const char *rule)
Add a schema evolution customization rule.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Version_t GetClassVersion() const
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
void ls(Option_t *option="") const override
List (ls) all objects in this collection.
void SetName(const char *name)
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TObject * Clone(const char *newname="") const override
Make a clone of an collection using the Streamer facility.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
static void GetDateTime(UInt_t datetime, Int_t &date, Int_t &time)
Static function that returns the date and time.
void Close(Option_t *option="") override
Delete all objects from memory and directory structure itself.
Bool_t cd() override
Change current directory to "this" directory.
Bool_t IsWritable() const override
void Delete(const char *namecycle="") override
Delete Objects or/and keys in a directory.
Int_t ReadKeys(Bool_t forceRead=kTRUE) override
TDatime fDatimeM
Date and time of last modification.
Int_t fNbytesKeys
Number of bytes for the keys.
Int_t GetNkeys() const override
Long64_t fSeekKeys
Location of Keys record on file.
Int_t Sizeof() const override
Return size of the TNamed part of the TObject.
Long64_t fSeekParent
Location of parent directory on file.
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write this object to the current directory.
Long64_t fSeekDir
Location of directory on file.
Int_t fNbytesName
Number of bytes in TNamed at creation time.
TDatime fDatimeC
Date and time when directory is created.
Bool_t fWritable
True if directory is writable.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
void FillBuffer(char *&buffer) override
Encode TNamed into output buffer.
void SetWritable(Bool_t writable=kTRUE) override
TList * fKeys
Pointer to keys list in memory.
void ls(Option_t *option="") const override
List Directory contents.
Describe directory structure in memory.
virtual TList * GetList() const
void SetName(const char *newname) override
Set the name for directory If the directory name is changed after the directory was written once,...
TUUID fUUID
Unique identifier.
TList * fList
List of objects in memory.
A cache when reading files over the network.
virtual void Close(Option_t *option="")
Close out any threads or asynchronous fetches used by the underlying implementation.
virtual Int_t GetBufferSize() const
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
A cache when writing files over the network.
TFile * fFile
TFile instance of the file being opened.
const char * GetOpt() const
Bool_t Matches(const char *name)
Int_t GetCompress() const
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
void ls(Option_t *option="") const override
List Directory contents.
ROOT::Detail::TKeyMapIterable WalkTKeys()
Traverses all TKeys in the TFile and returns information about them.
virtual TList * GetStreamerInfoList() final
static TFile *& CurrentFile()
virtual Int_t GetErrno() const
Long64_t fSeekFree
Location on disk of free segments structure.
static Int_t fgReadaheadSize
Readahead buffer size.
virtual Bool_t ReadBuffer(char *buf, Int_t len)
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
void FillBuffer(char *&buffer) override
Encode TNamed into output buffer.
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
const TList * GetStreamerInfoCache()
virtual void WriteStreamerInfo()
virtual Bool_t Matches(const char *name)
TArchiveFile * fArchive
!Archive file from which we read this file
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
static Int_t GetFileReadCalls()
static void SetFileBytesWritten(Long64_t bytes=0)
Bool_t fNoAnchorInName
!True if we don't want to force the anchor to be appended to the file name
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
void Paint(Option_t *option="") override
Paint all objects in the directory.
Int_t GetBestBuffer() const
TList * fOpenPhases
!Time info about open phases
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
virtual void SetCacheWrite(TFileCacheWrite *cache)
TFileCacheWrite * GetCacheWrite() const
virtual Long64_t GetBytesWritten() const
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=nullptr, ECacheAction action=kDisconnect)
static TString fgCacheFileDir
Directory where to locally stage files.
static void IncrementFileCounter()
Int_t fVersion
File format version.
void Print(Option_t *option="") const override
Print all objects in the directory.
virtual EAsyncOpenStatus GetAsyncOpenStatus()
void Streamer(TBuffer &) override
TDirectory Streamer.
virtual void ReadStreamerInfo()
static Bool_t fgOnlyStaged
Before the file is opened, it is checked, that the file is staged, if not, the open fails.
Bool_t fMustFlush
!True if the file buffers must be flushed
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Int_t ReadBufferViaCache(char *buf, Int_t len)
static Bool_t GetOnlyStaged()
virtual UShort_t WriteProcessID(TProcessID *pid)
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
TMap * fCacheReadMap
!Pointer to the read cache (if any)
Long64_t fBEGIN
First used byte in file.
virtual Int_t ReOpen(Option_t *mode)
Long64_t fArchiveOffset
!Offset at which file starts in archive
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
static Long64_t GetFileBytesRead()
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write this object to the current directory.
virtual Int_t SysClose(Int_t fd)
virtual Long64_t GetBytesRead() const
virtual InfoListRet GetStreamerInfoListImpl(bool lookupSICache)
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
virtual void WriteHeader()
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
TFile(const TFile &)=delete
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
TString fOption
File options.
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
virtual Int_t GetBytesToPrefetch() const
virtual Int_t SysSync(Int_t fd)
void SumBuffer(Int_t bufsize)
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=nullptr)
EAsyncOpenStatus
Asynchronous open request status.
virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
static Long64_t GetFileCounter()
Int_t fCompress
Compression level and algorithm.
static UInt_t GetOpenTimeout()
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
virtual const TUrl * GetEndpointUrl() const
Int_t fNbytesFree
Number of bytes for free segments structure.
static constexpr Version_t Class_Version()
Int_t Sizeof() const override
Return size of the TNamed part of the TObject.
Bool_t fIsPcmFile
!True if the file is a ROOT pcm file.
virtual void MakeFree(Long64_t first, Long64_t last)
virtual void Init(Bool_t create)
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Char_t fUnits
Number of bytes for file pointers.
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
static UInt_t SetOpenTimeout(UInt_t timeout)
static TFileOpenHandle * AsyncOpen(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
static ROOT::Internal::RConcurrentHashColl fgTsSIHashes
!TS Set of hashes built from read streamer infos
static void SetFileReadCalls(Int_t readcalls=0)
virtual void ShowStreamerInfo()
Bool_t fIsRootFile
!True is this is a ROOT file, raw file otherwise
TList * fFree
Free segments linked list table.
void Delete(const char *namecycle="") override
Delete Objects or/and keys in a directory.
static TList * fgAsyncOpenRequests
virtual TProcessID * ReadProcessID(UShort_t pidf)
Bool_t fInitDone
!True if the file has been initialized
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
virtual Long64_t GetSize() const
static TFile * OpenFromCache(const char *name, Option_t *="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
static void SetFileBytesRead(Long64_t bytes=0)
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
TList * fInfoCache
!Cached list of the streamer infos in this file
static Int_t GetReadaheadSize()
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
virtual Int_t SysRead(Int_t fd, void *buf, Int_t len)
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t bufsize=1000000)
Long64_t fEND
Last used byte in file.
virtual void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
virtual void ResetErrno() const
virtual Bool_t IsOpen() const
bool fGlobalRegistration
! if true, bypass use of global lists
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Bool_t fIsArchive
!True if this is a pure archive file
void Draw(Option_t *option="") override
Fill Graphics Structure and Paint.
void Close(Option_t *option="") override
Delete all objects from memory and directory structure itself.
TClass * IsA() const override
static Bool_t GetReadStreamerInfo()
virtual void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
virtual void MakeProject(const char *dirname, const char *classes="*", Option_t *option="new")
@ k630forwardCompatibility
static const char * GetCacheFileDir()
virtual void DrawMap(const char *keys="*", Option_t *option="")
Int_t fNProcessIDs
Number of TProcessID written to this file.
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Int_t fWritten
Number of objects written so far.
Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen)
static Long64_t GetFileBytesWritten()
Float_t GetCompressionFactor()
static void SetReadaheadSize(Int_t bufsize=256000)
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Int_t Sizeof() const
return number of bytes occupied by this TFree on permanent storage
virtual void ReadBuffer(char *&buffer)
Decode one free structure from input buffer.
Long64_t GetFirst() const
virtual void FillBuffer(char *&buffer)
Encode fre structure into output buffer.
TFree * AddFree(TList *lfree, Long64_t first, Long64_t last)
Add a new free segment to the list of free segments.
static void MakeFunctor(const char *name, const char *type, GlobFunc &func)
Book space in a file, create I/O buffers, to fill them, (un)compress them.
void Delete(Option_t *option="") override
Delete an object from the file.
virtual Long64_t GetSeekKey() const
virtual const char * GetClassName() const
virtual Bool_t ReadFile()
Read the key structure from the file.
void ReadKeyBuffer(char *&buffer)
Decode input buffer.
virtual Int_t WriteFile(Int_t cycle=1, TFile *f=nullptr)
Write the encoded object supported by this key.
virtual char * GetBuffer() const
void AddAfter(const TObject *after, TObject *obj) override
Insert object after object after in the list.
void Clear(Option_t *option="") override
Remove all objects from the list.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
virtual TObjLink * FirstLink() const
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
void RemoveLast() override
Remove the last object of the list.
static void GenerateMissingStreamerInfos(TList *extrainfos, TStreamerElement *element)
Generate an empty StreamerInfo for types that are used in templates parameters but are not known in t...
static TString UpdateAssociativeToVector(const char *name)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
virtual void FillBuffer(char *&buffer)
Encode TNamed into output buffer.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual Int_t Sizeof() const
Return size of the TNamed part of the TObject.
Int_t IndexOf(const TObject *obj) const override
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
TObject * UncheckedAt(Int_t i) const
void Add(TObject *obj) override
TObject * GetObject() const
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual UInt_t GetUniqueID() const
Return the unique object id.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
TObject()
TObject constructor.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Int_t IncrementCount()
Increase the reference count to this object.
void Clear(Option_t *option="") override
delete the TObjArray pointing to referenced objects this function is called by TFile::Close("R")
void CheckInit()
Initialize fObjects.
static TObjArray * GetPIDs()
static: returns array of TProcessIDs
static TProcessID * GetSessionProcessID()
static function returning the pointer to the session TProcessID
Int_t DecrementCount()
The reference fCount is used to delete the TProcessID in the TFile destructor when fCount = 0.
static TProcessID * GetPID()
static: returns pointer to current TProcessID
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Continue()
Resume a stopped stopwatch.
void Stop()
Stop the stopwatch.
void SetBaseCheckSum(UInt_t cs)
TClass * GetClass() const
Int_t GetClassVersion() const override
Int_t GenerateHeaderFile(const char *dirname, const TList *subClasses=nullptr, const TList *extrainfos=nullptr) override
Generate header file for the class described by this TStreamerInfo the function is called by TFile::M...
Int_t GetNumber() const override
TClass * IsA() const override
TClass * GetClass() const override
TObjArray * GetElements() const override
UInt_t GetCheckSum() const override
void BuildCheck(TFile *file=nullptr, Bool_t load=kTRUE) override
Check if built and consistent with the class dictionary.
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TString & Insert(Ssiz_t pos, const char *s)
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
void Clear()
Clear string without changing its capacity.
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & ReplaceAll(const TString &s1, const TString &s2)
void ToUpper()
Change string to upper case.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
static void ResetErrno()
Static function resetting system error number.
static Int_t GetErrno()
Static function returning system error number.
virtual Int_t GetClassVersion() const =0
RooCmdArg Save(bool flag=true)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
externTVirtualRWMutex * gCoreMutex
Type GetType(const std::string &Name)
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
bool IsStdPair(std::string_view name)
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Int_t WriteTObject(TBuffer &buf, void *addr, const TConfiguration *config)
@ kUndefined
Undefined compression algorithm (must be kept the last of the list in case a new algorithm is added).
@ kUseMin
Compression level reserved when we are not sure what to use (1 is for the fastest compression).
Simple struct of the return value of GetStreamerInfoListImpl.