110#define _XOPEN_SOURCE 600
119#include <sys/xattr.h>
124# include <sys/types.h>
129#include "RConfigure.h"
163#include "compiledata.h"
169#include "ROOT/InternalIOUtils.hxx"
180#include <sys/extattr.h>
201#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
204#define getxattr(path, name, value, size) extattr_get_file(path, EXTATTR_NAMESPACE_USER, name, value, size)
213static struct AddPseudoGlobals {
230 Info(
"TFile",
"default ctor");
380 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
386 gROOT->GetListOfClosedObjects()->Add(
this);
398 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
485 Error(
"TFile",
"file name is not specified");
527 SysError(
"TFile",
"could not delete %s (errno: %d)",
538 Error(
"TFile",
"file %s already exists",
fname.Data());
548 Error(
"TFile",
"no write permission, could not open file %s",
fname.Data());
555 Error(
"TFile",
"file %s does not exist",
fname.Data());
560 Error(
"TFile",
"no read permission, could not open file %s",
fname.Data());
574 SysError(
"TFile",
"file %s can not be opened",
fname.Data());
586 SysError(
"TFile",
"file %s can not be opened for reading",
fname.Data());
627 gROOT->GetListOfClosedObjects()->Remove(
this);
638 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
664 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
683 Error(
"Init",
"member %s not found in archive %s",
706 if (
gEnv->
GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
726 char *header =
new char[
kBEGIN+200];
731 Error(
"Init",
"%s failed to read the file type data.",
738 if (
strncmp(header,
"root", 4)) {
744 char *buffer = header + 4;
773 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
785 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
795 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
802 header =
new char[
nbytes];
807 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
853 Error(
"Init",
"cannot read directory info of file %s",
GetName());
870 if (
gEnv->
GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
894 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
897 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
903 Warning(
"Init",
"file %s probably not closed, "
904 "trying to recover",
GetName());
914 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
922 gROOT->GetListOfFiles()->Add(
this);
936 gROOT->GetListOfFiles()->Remove(
this);
943 const auto separator =
fVersion < 63200 ?
"/" :
".";
945 const auto msg =
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file. "
946 "The file was produced with ROOT version %d.%02d%s%02d, "
947 "while the current version is %d.%02d.%02d";
961 while ((key = (
TKey*)next())) {
972 gROOT->GetListOfClosedObjects()->Add(
this);
1020 while ((key = iter()) !=
nullptr) {
1068 if (!
pid->DecrementCount()) {
1078 gROOT->GetListOfFiles()->Remove(
this);
1079 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1080 gROOT->GetListOfClosedObjects()->Add(
this);
1154 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1155 if (
h->LoadPlugin() == -1) {
1156 ::Error(
"TFile::Open",
"Failed to load plugin TFileDrawMap");
1159 h->ExecPlugin(3,
this, keys,
option);
1214 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1215 return std::numeric_limits<Int_t>::max() -1;
1232 char *header =
new char[
fBEGIN];
1331 if (first <
fBEGIN)
return 0;
1332 if (first >
fEND)
return 0;
1337 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1343 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1356 const Int_t headerSize = 16;
1381 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1407 TList *list =
nullptr;
1410 auto key = std::make_unique<TKey>(
this);
1411 auto buffer = std::make_unique<char[]>(
fNbytesInfo+1);
1412 auto buf = buffer.get();
1416 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1418 return {
nullptr, 1,
hash};
1428 Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1431 return {
nullptr, 0,
hash};
1435 return {
nullptr, 1,
hash};
1436 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.get()));
1439 list = (
TList*)
Get(
"StreamerInfo");
1443 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1445 return {
nullptr, 1,
hash};
1448 return {list, 0,
hash};
1521 char buffer[
sizeof(
Int_t)];
1598 const unsigned char nDigits = std::log10(
fEND) + 1;
1600 std::optional<ROOT::Detail::TKeyMapNode>
lastNode;
1604 switch (key.fType) {
1606 Printf(
"Address = %" PRIu64 "\tNbytes = %u\t=====E R R O R=======", key.fAddr, key.fLen);
1610 Printf(
"Address = %" PRIu64 "\tNbytes = %d\t=====G A P===========", key.fAddr, -key.fLen);
1616 extrainfo.Form(
" name: %-16s title: %s", key.fKeyName.c_str(), key.fKeyTitle.c_str());
1620 if (key.fObjLen !=
static_cast<Int_t>(key.fLen) - key.fKeyLen) {
1621 Float_t cx =
static_cast<float>(key.fObjLen + key.fKeyLen) / key.fLen;
1622 Printf(
"At:%-*" PRIu64 " N=%-8u K=%-3d O=%-8d %-14s CX = %5.2f %s",
nDigits + 1, key.fAddr, key.fLen,
1623 key.fKeyLen, key.fObjLen, key.fClassName.c_str(),
cx,
extrainfo.Data());
1625 Printf(
"At:%-*" PRIu64 " N=%-8u K=%-3d O=%-8d %-14s CX = 1 %s",
nDigits + 1, key.fAddr, key.fLen,
1626 key.fKeyLen, key.fObjLen, key.fClassName.c_str(),
extrainfo.Data());
1631 if (key.fObjLen !=
static_cast<Int_t>(key.fLen) - key.fKeyLen) {
1632 Float_t cx =
static_cast<float>(key.fObjLen + key.fKeyLen) / key.fLen;
1634 key.fLen, key.fClassName.c_str(),
cx,
extrainfo.Data());
1637 key.fLen, key.fClassName.c_str(),
extrainfo.Data());
1667 static constexpr int headerSize = 512;
1669 const std::uint64_t
idcur = fCurAddr;
1672 return std::nullopt;
1675 auto nread = headerSize;
1679 char header[headerSize];
1687 char *buffer = header;
1705 frombuf(buffer, &node.fKeyVersion);
1706 frombuf(buffer, &node.fObjLen);
1707 frombuf(buffer, &node.fDatime);
1708 frombuf(buffer, &node.fKeyLen);
1709 frombuf(buffer, &node.fCycle);
1710 if (node.fKeyVersion > 1000) {
1711 frombuf(buffer, &node.fSeekKey);
1712 frombuf(buffer, &node.fSeekPdir);
1721 const auto readString = [&buffer, &header](
bool skipCheck =
false) {
1724 if (!
skipCheck && ((buffer - header) >= headerSize)) {
1733 if ((buffer - header) +
stringLen > headerSize)
1734 stringLen = headerSize - (buffer - header);
1745 node.fClassName = readString(
true);
1748 node.fClassName =
"FreeSegments";
1750 node.fClassName =
"StreamerInfo";
1752 node.fClassName =
"KeysList";
1754 node.fKeyName = readString();
1755 node.fKeyTitle = readString();
1775 Printf(
"TFile: name=%s, title=%s, option=%s", GetName(), GetTitle(), GetOption());
1797 if ((
st = ReadBufferViaCache(
buf,
len))) {
1810 SysError(
"ReadBuffer",
"error reading from file %s", GetName());
1814 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1842 if ((
st = ReadBufferViaCache(
buf,
len))) {
1857 SysError(
"ReadBuffer",
"error reading from file %s", GetName());
1861 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1892 if (ReadBufferAsync(pos[
j],
len[
j])) {
1902 fCacheRead =
nullptr;
1905 char *
buf2 =
nullptr;
1923 if (!
buf2)
buf2 =
new char[fgReadaheadSize];
1936 fBytesReadExtra += extra;
1937 fBytesRead -= extra;
1938 fgBytesRead -= extra;
1964 SetOffset(off +
len);
1971 if (fWritable && fCacheWrite) {
1972 if (fCacheWrite->ReadBuffer(
buf, off,
len) == 0) {
1973 SetOffset(off +
len);
2005 afree->ReadBuffer(buffer);
2007 if (
afree->GetLast() > fEND)
break;
2033 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",
pidname,GetName(),(
size_t)
pid);
2049 if (!
strcmp(
p->GetTitle(),
pid->GetTitle())) {
2059 p->IncrementCount();
2064 pid->IncrementCount();
2119 if ((
size = GetSize()) == -1) {
2120 Error(
"Recover",
"cannot stat the file %s", GetName());
2126 if (fWritable && !fFree) fFree =
new TList;
2130 while (
idcur < fEND) {
2132 int nread =
sizeof(header);
2138 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2142 char *buffer = header;
2146 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======",
idcur,
nbytes);
2176 char classname[101];
2181 classname[
static_cast<std::size_t
>(
classnameLen)] =
'\0';
2186 &&
strcmp(classname,
"TBasket")) {
2236 if (opt !=
"READ" && opt !=
"UPDATE") {
2237 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2241 if (opt == fOption || (opt ==
"UPDATE" && fOption ==
"CREATE"))
2244 if (opt ==
"READ") {
2248 if (IsOpen() && IsWritable()) {
2249 WriteStreamerInfo();
2275 fD = SysOpen(fRealName,
O_RDONLY, 0666);
2280 SysError(
"ReOpen",
"file %s can not be opened in read mode", GetName());
2302 SysError(
"ReOpen",
"file %s can not be opened in update mode", GetName());
2308 if (fSeekFree > fBEGIN)
2311 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments", GetName());
2324 fOffset =
offset + fArchiveOffset;
2332 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2347 offset += fArchiveOffset;
2356 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2361 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2375 if (fCompress < 0) {
2378 int level = fCompress % 100;
2388 if (level < 0) level = 0;
2389 if (level > 99) level = 99;
2390 if (fCompress < 0) {
2435 if (cache) fCacheReadMap->Add(tree, cache);
2440 fCacheReadMap->Remove(tree);
2445 else if (!tree && fCacheRead && (
action != kDoNotDisconnect)) fCacheRead->SetFile(0,
action);
2457 if (!cache && fCacheWrite)
delete fCacheWrite;
2458 fCacheWrite = cache;
2474 if (
b.IsReading()) {
2505 if (!IsWritable()) {
2506 if (!TestBit(kWriteError)) {
2508 Warning(
"Write",
"file %s not opened in write mode", GetName());
2514 if (!GetTitle() ||
strlen(GetTitle()) == 0)
2515 Info(
"Write",
"writing name = %s", GetName());
2517 Info(
"Write",
"writing name = %s title = %s", GetName(), GetTitle());
2522 WriteStreamerInfo();
2535 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2545 if (IsOpen() && fWritable) {
2548 if ((
st = WriteBufferViaCache(
buf,
len))) {
2556 while ((
siz = SysWrite(fD,
buf,
len)) < 0 && GetErrno() ==
EINTR)
2561 SetBit(kWriteError); SetWritable(
kFALSE);
2562 SysError(
"WriteBuffer",
"error writing to file %s (%ld)", GetName(), (
Long_t)
siz);
2566 SetBit(kWriteError);
2567 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2572 fgBytesWrite +=
siz;
2588 if (!fCacheWrite)
return 0;
2592 if ((
st = fCacheWrite->WriteBuffer(
buf, off,
len)) < 0) {
2593 SetBit(kWriteError);
2594 Error(
"WriteBuffer",
"error writing to cache");
2613 if (fSeekFree != 0) {
2614 MakeFree(fSeekFree, fSeekFree + fNbytesFree -1);
2632 return (
TKey*)
nullptr;
2654 char *start = buffer;
2661 afree->FillBuffer(buffer);
2670 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);
2687 const char *root =
"root";
2688 char *
psave =
new char[fBEGIN];
2689 char *buffer =
psave;
2691 memcpy(buffer, root, 4); buffer += 4;
2699 tobuf(buffer, fNbytesFree);
2701 tobuf(buffer, fNbytesName);
2702 tobuf(buffer, fUnits);
2703 tobuf(buffer, fCompress);
2705 tobuf(buffer, fNbytesInfo);
2707 tobuf(buffer, fEND);
2708 tobuf(buffer, fSeekFree);
2709 tobuf(buffer, fNbytesFree);
2711 tobuf(buffer, fNbytesName);
2712 tobuf(buffer, fUnits);
2713 tobuf(buffer, fCompress);
2714 tobuf(buffer, fSeekInfo);
2715 tobuf(buffer, fNbytesInfo);
2717 if (TestBit(kReproducible))
2720 fUUID.FillBuffer(buffer);
2808 }
else if (opt.
Contains(
"recreate")) {
2812 Error(
"MakeProject",
"cannot create directory '%s'",
dirname);
2830 Error(
"MakeProject",
"cannot create directory %s, already existing",
dirname);
2835 Error(
"MakeProject",
"cannot create directory '%s'",
dirname);
2850 Error(
"MakeProject",
"file %s has no StreamerInfo", GetName());
2865 Error(
"MakeProject",
"Directory name must not be empty.");
2873 Error(
"MakeProject",
"Unable to create the source file %s.",
spath.Data());
2876 fprintf(
sfp,
"namespace std {}\nusing namespace std;\n");
2880 fprintf(
sfp,
"struct DeleteObjectFunctor {\n");
2882 fprintf(
sfp,
" void operator()(const T *ptr) const {\n");
2885 fprintf(
sfp,
" template <typename T, typename Q>\n");
2886 fprintf(
sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2889 fprintf(
sfp,
" template <typename T, typename Q>\n");
2890 fprintf(
sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2893 fprintf(
sfp,
" template <typename T, typename Q>\n");
2894 fprintf(
sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2897 fprintf(
sfp,
" template <typename T, typename Q>\n");
2898 fprintf(
sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2934 if(
rule->IsRenameRule() ||
rule->IsAliasRule() )
2937 if (
rule->HasTarget(
el->GetName()) &&
rule->GetAttributes()[0] != 0 ) {
2940 if (
attr.Contains(
"owner")) {
2941 if (
attr.Contains(
"notowner")) {
2953 if ((
info->GetClass() &&
info->GetClassVersion() ==
info->GetClass()->GetClassVersion())
2954 || (
info->GetClassVersion() >
alternate->GetClassVersion()) ) {
2977 if (
info->GetClassVersion()==-4)
continue;
3006 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
3037 Error(
"MakeProject",
"cannot open file %s", path.
Data());
3053 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3077 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3089 fprintf(fp,
"#ifdef __CLING__\n");
3101 if (
strncmp(
info->GetName(),
"auto_ptr<", std::char_traits<char>::length(
"auto_ptr<")) == 0) {
3130 std::vector<std::string> inside;
3141 what =
"std::pair<";
3151 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3155 tmp.Form(
"template class %s;\n",
what.Data());
3160 what.ReplaceAll(
"std::",
"");
3163 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3171 tmp.Form(
"<class name=\"%s\" />\n",key->
GetName());
3175 tmp.Form(
"template class %s;\n",key->
GetName());
3180 what.ReplaceAll(
"std::",
"");
3192 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3196 if (
what[
what.Length()-1] ==
'>') {
3197 tmp.Form(
"template class %s;\n",
what.Data());
3203 what.ReplaceAll(
"std::",
"");
3204 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3212 if (
element->GetClass() && !
element->GetClass()->IsLoaded() &&
element->GetClass()->GetCollectionProxy()) {
3214 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3218 tmp.Form(
"template class %s;\n",
what.Data());
3227 fprintf(
ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3228 fprintf(
ifp,
"#define PROJECT_INSTANCES_H\n");
3244 cmd.ReplaceAll(
"$SourceFiles",
sources.Data());
3247 cmd.ReplaceAll(
"$ObjectFiles",
object.Data());
3252 cmd.ReplaceAll(
"$BuildDir",
".");
3253 cmd.ReplaceAll(
"$RPath",
"-Wl,-rpath," +
gROOT->GetSharedLibDir());
3261#if defined(_MSC_VER) && defined(_DEBUG)
3282 if (!opt.
Contains(
"nocompilation")) {
3291 chmod(
"makep.cmd",00700);
3296 if (res)
printf(
"Shared lib %s has been generated\n",path.
Data());
3301 if (res)
printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3320 auto listRetcode = GetStreamerInfoListImpl(
true);
3330 if (
gDebug > 0)
Info(
"ReadStreamerInfo",
"called for file %s",GetName());
3351 if (!base)
continue;
3389 Warning(
"ReadStreamerInfo",
"%s has a %s in the list of TStreamerInfo.", GetName(),
info->IsA()->GetName());
3398 if (
info->GetElements()==0) {
3399 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",
info->GetName());
3409 info->BuildCheck(
this);
3412 if (uid >=
asize && uid <100000) fClassIndex->Set(2*
asize);
3415 fClassIndex->fArray[uid] = 1;
3417 else if (!
isstl && !
info->GetClass()->IsSyntheticPair()) {
3418 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",
info->GetName(),uid);
3420 if (
gDebug > 0)
printf(
" -class: %s version: %d info read at slot %d\n",
info->GetName(),
info->GetClassVersion(),uid);
3425 fClassIndex->fArray[0] = 0;
3465 TList *list = GetStreamerInfoList();
3488 pid->IncrementCount();
3492 this->IncrementProcessIDs();
3494 Info(
"WriteProcessID",
"name=%s, file=%s",
name, GetName());
3508 if (!fWritable)
return;
3509 if (!fClassIndex)
return;
3510 if (fIsPcmFile)
return;
3511 if (fClassIndex->fArray[0] == 0
3512 && fSeekInfo != 0) {
3518 if (
gDebug > 0)
Info(
"WriteStreamerInfo",
"called for file %s",GetName());
3533 if (fClassIndex->fArray[uid]) {
3535 if (
gDebug > 0)
printf(
" -class: %s info number %d saved\n",
info->GetName(),uid);
3542 if (
gDebug > 0)
printf(
" -class: %s stored the I/O customization rules\n",
info->GetName());
3558 fClassIndex->fArray[0] = 2;
3566 if (fSeekInfo) MakeFree(fSeekInfo,fSeekInfo+fNbytesInfo-1);
3568 TKey key(&list,
"StreamerInfo",GetBestBuffer(),
this);
3569 fKeys->Remove(&key);
3575 fClassIndex->fArray[0] = 0;
3592 if (fgCacheFileDir ==
"") {
3594 "you want to read through a cache, but you have no valid cache "
3595 "directory set - reading remotely");
3596 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3602 if (!fgCacheFileForce)
3604 "you want to read through a cache, but you are reading "
3605 "local files - CACHEREAD disabled");
3616 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3617 "cannot create the directory %s - CACHEREAD disabled",
3637 if (
objTags->GetEntries() == 2) {
3670 if (!fgCacheFileDisconnected) {
3676 cfurl +=
"?filetype=raw";
3679 ropt +=
"&filetype=raw";
3683 fgCacheFileForce =
kFALSE;
3692 ::Error(
"TFile::OpenFromCache",
3693 "cannot open the cache file to check cache consistency");
3698 ::Error(
"TFile::OpenFromCache",
3699 "cannot open the remote file to check cache consistency");
3709 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3710 "differs from the remote file - forcing an update");
3714 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
3715 "remote file are not readable - forcing an update");
3728 fgCacheFileForce =
kFALSE;
3733 "you want to read through a cache, but I "
3734 "cannot make a cache copy of %s - CACHEREAD disabled",
3811 ::Error(
"TFile::Open",
"no url specified");
3818 if (
auto xurl = ROOT::Internal::GetEOSRedirectedXRootURL(
expandedUrl)) {
3820 if (!
f->IsZombie()) {
3837 while (!(
sto.IsDigit()) && !(
sto.IsNull())) {
sto.Remove(
sto.Length()-1,1); }
3838 if (!(
sto.IsNull())) {
3841 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested",
toms);
3843 sto.Insert(0,
"TIMEOUT=");
3861 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open",
toms -
xtms);
3863 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
3875 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
3876 opts.ReplaceAll(
"TIMEOUT=",
"");
3901 while (
namelist.Tokenize(
n, from,
"|") && !
f) {
3906 fgCacheFileForce)) {
3912 IncrementFileCounter();
3919 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
3939 if (
type == kLocal) {
3949 }
else if (
type == kNet) {
3952 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
3953 if (
h->LoadPlugin() == -1) {
3954 ::Error(
"TFile::Open",
"Failed to load plugin %s",
name.Data());
3960 }
else if (
type == kWeb) {
3963 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
3964 if (
h->LoadPlugin() == -1) {
3965 ::Error(
"TFile::Open",
"Failed to load plugin %s",
name.Data());
3971 }
else if (
type == kFile) {
3974 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
3975 h->LoadPlugin() == 0) {
3976 name.ReplaceAll(
"file:",
"");
3984 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
3985 if (
h->LoadPlugin() == -1) {
3986 ::Error(
"TFile::Open",
"Failed to load plugin %s",
name.Data());
3999 if (
f &&
f->IsZombie()) {
4021 if (
type != kLocal &&
type != kFile &&
4022 f &&
f->IsWritable() && !
f->IsRaw()) {
4066 ::Error(
"TFile::AsyncOpen",
"no url specified");
4089 while (
namelist.Tokenize(
n, from,
"|") && !
f) {
4104 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4105 !
strcmp(
h->GetClass(),
"TNetXNGFile")
4106 &&
h->LoadPlugin() == 0) {
4137 if (!fgAsyncOpenRequests)
4138 fgAsyncOpenRequests =
new TList;
4139 fgAsyncOpenRequests->
Add(fh);
4157 if (fh && fgAsyncOpenRequests) {
4160 fgAsyncOpenRequests->
Remove(fh);
4162 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4165 !
strcmp(
f->GetOption(),
"RECREATE") ||
4176 if (
f)
f->fAsyncHandle = fh;
4188#if defined(R__WINGCC)
4192#elif defined(R__SEEK64)
4204 if (fd < 0)
return 0;
4213 return ::read(fd,
buf,
len);
4221 return ::write(fd,
buf,
len);
4232#if defined (R__SEEK64)
4259 if (TestBit(kDevNull))
return 0;
4264 return ::_commit(fd);
4273 return fCacheWrite ? fCacheWrite->GetBytesInCache() + fBytesWrite : fBytesWrite;
4290 return fgBytesWrite;
4306 return fgReadaheadSize;
4335 if (!
cached.EndsWith(
"/"))
4342 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(
cachedir).Data());
4343 fgCacheFileDir =
"";
4361 return fgCacheFileDir;
4373 if (fgCacheFileDir ==
"") {
4399 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s",
cachetagfile.Data());
4407#if defined(R__WIN32)
4408 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4409#elif defined(R__MACOSX)
4410 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);
4412 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);
4419 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4431 UInt_t to = fgOpenTimeout;
4441 return fgOpenTimeout;
4461 return fgOnlyStaged;
4477 if (!
strcmp(
u.GetFile(), fUrl.GetFile())) {
4479 if (
u.GetPort() == fUrl.GetPort()) {
4480 if (!
strcmp(
u.GetHostFQDN(), fUrl.GetHostFQDN())) {
4499 }
else if (fName.Length() > 0){
4505 if (
u.GetPort() ==
uref.GetPort()) {
4507 if (!
strcmp(
u.GetHostFQDN(),
uref.GetHostFQDN())) {
4531 if (re.Match(
name)) {
4548 if (
opts.Contains(
"remote=1"))
4550 else if (
opts.Contains(
"remote=0"))
4557 const char *
fname =
url.GetFileAndOptions();
4559 if (
fname[0] ==
'/') {
4564 }
else if (
fname[0] ==
'~' ||
fname[0] ==
'$') {
4589 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").Match(
name)) {
4608 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
4619 if (of && (of->
GetSize() > 0)) {
4623 if (
f->Matches(
name))
4628 return kAOSNotAsync;
4636 if (handle && handle->
fFile) {
4654 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
4666 if (of && (of->
GetSize() > 0)) {
4670 if (
f->Matches(
name))
4675 return (
const TUrl *)
nullptr;
4685 for (
int l = 0;
l < 20;
l++) {
4725 opt +=
"filetype=raw";
4727 dURL.SetOptions(opt);
4742 dURL.SetOptions(opt);
4748 ::Error(
"TFile::Cp",
"cannot open destination file %s",
dst);
4761 ::Error(
"TFile::Cp",
"cannot allocate the copy buffer");
4792 read =
sfile->GetBytesRead() - b0;
4793 if ((read <= 0) ||
readop) {
4794 ::Error(
"TFile::Cp",
"cannot read from source file %s. readsize=%lld read=%lld readop=%d",
4803 ::Error(
"TFile::Cp",
"cannot write %lld bytes to destination file %s", read,
dst);
4846 ::Error(
"TFile::Cp",
"cannot open source file %s",
src);
4863#if defined(R__neverLINUX) && !defined(R__WINGCC)
4884#if defined(R__SEEK64)
4912 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
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)
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)
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)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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.
winID h TVirtualViewer3D TVirtualGLPainter p
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
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 type
R__EXTERN TPluginManager * gPluginMgr
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
R__EXTERN TVirtualMutex * gROOTMutex
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
R__EXTERN TSystem * gSystem
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
R__EXTERN TVirtualMonitoringWriter * 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)
This class is a thread-safe associative collection connecting a 256 bits digest/hash to a collection ...
const_iterator end() const
const char * GetMemberName() const
virtual Int_t SetCurrentMember()=0
const char * GetArchiveName() const
TArchiveMember * GetMember() const
static TArchiveFile * Open(const char *url, TFile *file)
Return proper archive file handler depending on passed url.
Long64_t GetMemberFilePosition() const
Return position in archive of current member.
virtual Int_t OpenArchive()=0
Long64_t GetDecompressedSize() const
Array of chars or bytes (8 bits per element).
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t HasInterpreterInfo() const
const ROOT::Detail::TSchemaRuleSet * GetSchemaRules() const
Return the set of the schema rules if any.
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".
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.
virtual bool UseRWLock(Bool_t enable=true)
Set this collection to use a RW lock upon access, making it thread safe.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
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 ReadBuffer(char *&buffer)
Decode Date/Time from output buffer, used by I/O system.
A ROOT file is structured in Directories (like a file system).
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 the current directory.
Int_t ReadKeys(Bool_t forceRead=kTRUE) override
Read the linked list of keys.
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 the size in bytes of the directory header.
Long64_t fSeekParent
Location of parent directory on file.
void BuildDirectoryFile(TFile *motherFile, TDirectory *motherDir)
Initialise directory to defaults.
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write all objects in memory to disk.
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 directory header into output buffer.
void SetWritable(Bool_t writable=kTRUE) override
Set the new value of fWritable recursively.
TList * fKeys
Pointer to keys list in memory.
void ls(Option_t *option="") const override
List Directory contents.
TDirectory::TContext keeps track and restore the current directory.
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.
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
TList * fList
List of objects in memory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
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 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.
virtual Bool_t Flush()
Flush the current write buffer to the file.
Class holding info about the file being opened.
TFile * fFile
TFile instance of the file being opened.
const char * GetOpt() const
Bool_t Matches(const char *name)
Return kTRUE if this async request matches the open request specified by 'url'.
Int_t GetCompress() const
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
static void SetFileBytesWritten(Long64_t bytes=0)
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
virtual TProcessID * ReadProcessID(UShort_t pidf)
The TProcessID with number pidf is read from this file.
void ls(Option_t *option="") const override
List file contents.
ROOT::Detail::TKeyMapIterable WalkTKeys()
Traverses all TKeys in the TFile and returns information about them.
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
static Bool_t GetOnlyStaged()
Returns staged only flag.
static void IncrementFileCounter()
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Try to shrink the cache to the desired size.
Long64_t fSeekFree
Location on disk of free segments structure.
static Int_t fgReadaheadSize
Readahead buffer size.
void FillBuffer(char *&buffer) override
Encode file output buffer.
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
static void SetReadaheadSize(Int_t bufsize=256000)
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
const TList * GetStreamerInfoCache()
Returns the cached list of StreamerInfos used in this file.
static Bool_t GetReadStreamerInfo()
If the streamerinfos are to be read at file opening.
TArchiveFile * fArchive
!Archive file from which we read this file
virtual Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
virtual Bool_t Matches(const char *name)
Return kTRUE if 'url' matches the coordinates of this file.
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=nullptr, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
virtual InfoListRet GetStreamerInfoListImpl(bool lookupSICache)
See documentation of GetStreamerInfoList for more details.
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
Specify if the streamerinfos must be read at file opening.
Bool_t fNoAnchorInName
!True if we don't want to force the anchor to be appended to the file name
static void SetFileBytesRead(Long64_t bytes=0)
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
void Paint(Option_t *option="") override
Paint all objects in the file.
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
TList * fOpenPhases
!Time info about open phases
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
See comments for function SetCompressionSettings.
TFileCacheWrite * GetCacheWrite() const
Return a pointer to the current write cache.
static void SetFileReadCalls(Int_t readcalls=0)
static TString fgCacheFileDir
Directory where to locally stage files.
virtual Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read().
Int_t fVersion
File format version.
void Print(Option_t *option="") const override
Print all objects in the file.
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
virtual EAsyncOpenStatus GetAsyncOpenStatus()
void Streamer(TBuffer &) override
Stream a TFile object.
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
Print file copy progress.
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)
Write buffer via cache.
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
Creates key for object and converts data to buffer.
virtual void WriteFree()
Write FREE linked list on the file.
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
~TFile() override
File destructor.
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
static Long64_t GetFileCounter()
TMap * fCacheReadMap
!Pointer to the read cache (if any)
Long64_t fBEGIN
First used byte in file.
virtual UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pidd is already in the file, if not, add it and return the index number in the...
virtual void MakeProject(const char *dirname, const char *classes="*", Option_t *option="new")
Generate source code necessary to access the objects stored in the file.
Long64_t fArchiveOffset
!Offset at which file starts in archive
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
virtual Long64_t GetSize() const
Returns the current file size.
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Sets only staged flag.
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t bufsize=1000000)
Allows to copy this file to the dst URL.
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write memory objects to this file.
virtual Int_t GetErrno() const
Method returning errno.
virtual void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm.
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
virtual void Init(Bool_t create)
Initialize a TFile object.
static TFileOpenHandle * AsyncOpen(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Submit an asynchronous open request.
virtual void SetCacheWrite(TFileCacheWrite *cache)
Set a pointer to the write cache.
TString fOption
File options.
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
EAsyncOpenStatus
Asynchronous open request status.
virtual void WriteStreamerInfo()
Write the list of TStreamerInfo as a single object in this file The class Streamer description for al...
virtual Long64_t GetBytesWritten() const
Return the total number of bytes written so far to the file.
Int_t fCompress
Compression level and algorithm.
static TFile *& CurrentFile()
Return the current ROOT file if any.
virtual void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
See comments for function SetCompressionSettings.
virtual const TUrl * GetEndpointUrl() const
Int_t fNbytesFree
Number of bytes for free segments structure.
static constexpr Version_t Class_Version()
virtual void ResetErrno() const
Method resetting the errno.
Int_t Sizeof() const override
Return the size in bytes of the file header.
Bool_t FlushWriteCache()
Flush the write cache if active.
Bool_t fIsPcmFile
!True if the file is a ROOT pcm file.
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
virtual Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
TFile()
File default Constructor.
Char_t fUnits
Number of bytes for file pointers.
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=nullptr)
Resolve the file type as a function of the protocol field in 'name'.
virtual void ShowStreamerInfo()
Show the StreamerInfo of all classes written to this file.
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Return file stat information.
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open().
ECacheAction
TTreeCache flushing semantics.
static UInt_t SetOpenTimeout(UInt_t timeout)
Sets open timeout time (in ms). Returns previous timeout value.
virtual void ReadFree()
Read the FREE linked list.
static ROOT::Internal::RConcurrentHashColl fgTsSIHashes
!TS Set of hashes built from read streamer infos
Bool_t fIsRootFile
!True is this is a ROOT file, raw file otherwise
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
TList * fFree
Free segments linked list table.
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
void Delete(const char *namecycle="") override
Delete Objects or/and keys in the current directory.
Bool_t fInitDone
!True if the file has been initialized
virtual void DrawMap(const char *keys="*", Option_t *option="")
Draw map of objects in this file.
virtual void MakeFree(Long64_t first, Long64_t last)
Mark unused bytes on the file.
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
TString fRealName
Effective real file name (not original url)
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
TList * fInfoCache
!Cached list of the streamer infos in this file
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
Long64_t fEND
Last used byte in file.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
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
Close a file.
TClass * IsA() const override
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
virtual Int_t Recover()
Attempt to recover file if not correctly closed.
virtual TList * GetStreamerInfoList() final
Read the list of TStreamerInfo objects written to this file.
virtual void WriteHeader()
Write File Header.
@ k630forwardCompatibility
static TFile * OpenFromCache(const char *name, Option_t *="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Open a file for reading through the file cache.
Int_t fNProcessIDs
Number of TProcessID written to this file.
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)
Read the logical record header starting at a certain postion.
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Float_t GetCompressionFactor()
Return the file compression factor.
virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write().
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
static TList * fgAsyncOpenRequests
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
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 Add(TObject *obj) override
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
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 ...
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
virtual void FillBuffer(char *&buffer)
Encode TNamed into output buffer.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
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.
Iterator of object array.
TObject * Next() override
Return next object in array. Returns 0 when no more objects in array.
Wrapper around a TObject so it can be stored in a TList.
Collectable string class.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual UInt_t GetUniqueID() const
Return the unique object id.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
R__ALWAYS_INLINE Bool_t IsOnHeap() const
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.
R__ALWAYS_INLINE Bool_t IsZombie() const
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 Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Longptr_t ExecPlugin(int nargs)
A TProcessID identifies a ROOT job in a unique way in time and space.
static TObjArray * GetPIDs()
static: returns array of TProcessIDs
static TProcessID * GetSessionProcessID()
static function returning the pointer to the session TProcessID
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().
Sequenceable collection abstract base class.
void SetBaseCheckSum(UInt_t cs)
Describe one element (data member) to be Streamed.
Describes a persistent version of a class.
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void ToUpper()
Change string to upper case.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
virtual const char * GetMakeSharedLib() const
Return the command line use to make a shared library.
virtual Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=nullptr)
Redirect standard output (stdout, stderr) to the specified file.
virtual void IgnoreInterrupt(Bool_t ignore=kTRUE)
If ignore is true ignore the interrupt signal, else restore previous behaviour.
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
static void ResetErrno()
Static function resetting system error number.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
static Int_t GetErrno()
Static function returning system error number.
virtual int Chmod(const char *file, UInt_t mode)
Set the file permission bits. Returns -1 in case or error, 0 otherwise.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory.
virtual int GetPid()
Get process id.
virtual const char * GetIncludePath()
Get the list of include path.
virtual void ShowOutput(RedirectHandle_t *h)
Display the content associated with the redirection described by the opaque handle 'h'.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
virtual int Rename(const char *from, const char *to)
Rename a file.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetFlagsDebug() const
Return the debug flags.
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
virtual const char * GetObjExt() const
Get the object file extension.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual const char * WorkingDirectory()
Return working directory.
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual const char * GetSoExt() const
Get the shared library extension.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual const char * GetFlagsOpt() const
Return the optimization flags.
The TTimeStamp encapsulates seconds and ns since EPOCH.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
void ReadBuffer(char *&buffer)
Stream UUID from input buffer.
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
const char * GetFile() const
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
const char * GetOptions() const
const char * GetProtocol() const
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
virtual Bool_t SendFileReadProgress(TFile *)
virtual Bool_t SendFileCloseEvent(TFile *)
virtual Bool_t SendFileWriteProgress(TFile *)
Abstract Interface class describing Streamer information for one class.
R__EXTERN TVirtualRWMutex * gCoreMutex
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.
@ 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.