72#define _XOPEN_SOURCE 600
84# include <sys/types.h>
89#include "RConfigure.h"
125#include "compiledata.h"
156#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
166static struct AddPseudoGlobals {
183 Info(
"TFile",
"default ctor");
319 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
321 auto zombify = [
this] {
325 gROOT->GetListOfClosedObjects()->Add(
this);
335 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
416 if (!create && !recreate && !
update && !read) {
423 if (!fname1 || !fname1[0]) {
424 Error(
"TFile",
"file name is not specified");
430 if (!strcmp(fname1,
"/dev/null") &&
451 Error(
"TFile",
"error expanding path %s", fname1);
467 SysError(
"TFile",
"could not delete %s (errno: %d)",
478 Error(
"TFile",
"file %s already exists", fname);
488 Error(
"TFile",
"no write permission, could not open file %s", fname);
495 Error(
"TFile",
"file %s does not exist", fname);
500 Error(
"TFile",
"no read permission, could not open file %s", fname);
514 SysError(
"TFile",
"file %s can not be opened", fname);
526 SysError(
"TFile",
"file %s can not be opened for reading", fname);
569 gROOT->GetListOfClosedObjects()->Remove(
this);
580 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
606 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
625 Error(
"Init",
"member %s not found in archive %s",
663 char *header =
new char[
kBEGIN+200];
668 Error(
"Init",
"%s failed to read the file type data.",
675 if (strncmp(header,
"root", 4)) {
681 char *buffer = header + 4;
684 frombuf(buffer, &headerLength);
687 Int_t send,sfree,sinfo;
708 if (fBEGIN < 0 || fBEGIN >
fEND) {
710 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
722 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
727 char *buffer_keyloc =
nullptr;
732 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
739 header =
new char[nbytes];
744 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
750 buffer_keyloc = header;
753 buffer_keyloc = header+
fBEGIN;
756 frombuf(buffer,&version); versiondir = version%1000;
761 if (version > 1000) {
766 Int_t sdir,sparent,skeys;
774 buffer_keyloc +=
sizeof(
Int_t);
776 frombuf(buffer_keyloc, &keyversion);
778 if (keyversion > 1000) {
785 cname.ReadBuffer(buffer_keyloc);
786 cname.ReadBuffer(buffer_keyloc);
789 if (fNbytesName < 10 || fNbytesName > 10000) {
790 Error(
"Init",
"cannot read directory info of file %s",
GetName());
826 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
829 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
835 Warning(
"Init",
"file %s probably not closed, "
836 "trying to recover",
GetName());
844 Warning(
"Init",
"successfully recovered %d keys", nrecov);
846 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
854 gROOT->GetListOfFiles()->Add(
this);
860 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
861 if (lenIndex < 5000) lenIndex = 5000;
868 gROOT->GetListOfFiles()->Remove(
this);
874 Warning(
"Init",
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file."
875 " The file was produced with version %d.%02d/%02d of ROOT.",
886 while ((key = (
TKey*)next())) {
897 gROOT->GetListOfClosedObjects()->Add(
this);
945 while ((key = iter()) !=
nullptr) {
1003 gROOT->GetListOfFiles()->Remove(
this);
1004 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1005 gROOT->GetListOfClosedObjects()->Add(
this);
1016 return new TKey(obj,
name, bufsize, mother);
1024 return new TKey(obj, cl,
name, bufsize, mother);
1036 static TFile *currentFile =
nullptr;
1068 Info(
"Delete",
"deleting name = %s", namecycle);
1098 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1099 if (
h->LoadPlugin() == -1)
1101 h->ExecPlugin(3,
this, keys,
option);
1140 tobuf(buffer, version);
1156 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1157 return std::numeric_limits<Int_t>::max() -1;
1173 Int_t nbytes, objlen, nwh = 64;
1174 char *header =
new char[
fBEGIN];
1180 while (idcur <
fEND-100) {
1195 if (nbytes == 0)
break;
1201 if (!objlen) objlen = nbytes-keylen;
1203 uncomp += keylen + objlen;
1276 Int_t nread = maxbytes;
1279 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1285 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1296 if (nb < 0)
return nread;
1298 const Int_t headerSize = 16;
1299 if (nread < headerSize)
return nread;
1304 if (!olen) olen = nbytes-klen;
1323 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1349 TList *list =
nullptr;
1352 auto key = std::make_unique<TKey>(
this);
1354 auto buf = buffer.data();
1358 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1360 return {
nullptr, 1, hash};
1364 if (lookupSICache) {
1369 if (
gDebug > 0)
Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1370 return {
nullptr, 0, hash};
1374 (
void) lookupSICache;
1376 key->ReadKeyBuffer(buf);
1377 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1380 list = (
TList*)
Get(
"StreamerInfo");
1384 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1386 return {
nullptr, 1, hash};
1389 return {list, 0, hash};
1456 if(!newfree)
return;
1460 if (nbytesl > 2000000000) nbytesl = 2000000000;
1463 char * buffer =
new char[nb];
1464 char * psave = buffer;
1465 tobuf(buffer, nbytes);
1538 bool forComp = options.
Contains(
"forcomp");
1539 bool extended = options.
Contains(
"extended");
1543 Int_t nbytes,date,time,objlen;
1551 constexpr Int_t nwheader = 512;
1553 char header[nwheader];
1554 char classname[512];
1561 while (idcur <
fEND) {
1563 Int_t nread = nwheader;
1564 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1567 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1575 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1580 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1591 if (versionkey > 1000) {
1600 if ( ((buffer-header) + nwhc) > nwheader )
1601 nwhc = nwheader - (buffer-header);
1602 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1603 classname[(
int)nwhc] =
'\0';
1604 if (idcur ==
fSeekFree) strlcpy(classname,
"FreeSegments",512);
1605 if (idcur ==
fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1606 if (idcur ==
fSeekKeys) strlcpy(classname,
"KeysList",512);
1609 if ( (buffer-header) >= nwheader )
1615 else if ( ((buffer-header) + nwhc) > nwheader )
1616 nwhc = nwheader - (buffer-header);
1618 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keyname[i]);
1619 keyname[(
int)nwhc] =
'\0';
1621 if ( (buffer-header) >= nwheader )
1627 else if ( ((buffer-header) + nwhc) > nwheader )
1628 nwhc = nwheader - (buffer-header);
1630 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keytitle[i]);
1631 keytitle[(
int)nwhc] =
'\0';
1633 extrainfo.
Form(
" name: %-16s title: %s", keyname, keytitle);
1638 if (objlen != nbytes - keylen) {
1640 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s CX = %5.2f %s", date, time, nDigits + 1, idcur, nbytes, classname,
1641 cx, extrainfo.
Data());
1643 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s %s", date, time, nDigits + 1, idcur, nbytes, classname, extrainfo.
Data());
1647 if (objlen != nbytes - keylen) {
1649 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = %5.2f %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, cx, extrainfo.
Data());
1651 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = 1 %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, extrainfo.
Data());
1657 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s",date,time, nDigits+1, idcur,1,
"END");
1659 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits+1, idcur,1,
"END");
1714 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1761 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1792 for (
Int_t j = 0; j < nbuf; j++) {
1806 char *buf2 =
nullptr;
1809 cur = pos[i]+
len[i];
1812 if (bigRead || (i>=nbuf)) {
1831 for (
Int_t j=0;j<
n;j++) {
1832 memcpy(&buf[k],&buf2[pos[i-
n+j]-curbegin],
len[i-
n+j]);
1842 curbegin = i < nbuf ? pos[i] : 0;
1845 if (buf2)
delete [] buf2;
1895 if (fNbytesFree < 0 || fNbytesFree >
fEND) {
1931 snprintf(pidname,32,
"ProcessID%d",pidf);
1934 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",pidname,
GetName(),(
size_t)pid);
1943 TIter next(pidslist);
1960 p->IncrementCount();
2019 Int_t nbytes,date,time,objlen,nwheader;
2022 char *buffer, *bufread;
2028 Error(
"Recover",
"cannot stat the file %s",
GetName());
2039 Int_t nread = nwheader;
2041 while (idcur <
fEND) {
2043 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
2046 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2054 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
2069 if (versionkey > 1000) {
2078 char *classname =
nullptr;
2079 if (nwhc <= 0 || nwhc > 100)
break;
2080 classname =
new char[nwhc+1];
2081 int i, nwhci = nwhc;
2082 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
2083 classname[nwhci] =
'\0';
2087 && strcmp(classname,
"TBasket")) {
2088 key =
new TKey(
this);
2090 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
2101 delete [] classname;
2106 if (max_file_size <
fEND) max_file_size =
fEND+1000000000;
2113 if (nrecov)
Write();
2136 if (opt !=
"READ" && opt !=
"UPDATE") {
2137 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2144 if (opt ==
"READ") {
2180 SysError(
"ReOpen",
"file %s can not be opened in read mode",
GetName());
2202 SysError(
"ReOpen",
"file %s can not be opened in update mode",
GetName());
2211 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments",
GetName());
2232 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2256 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2261 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2288 if (level < 0) level = 0;
2289 if (level > 99) level = 99;
2344 if (cache) cache->
SetFile(
this, action);
2374 if (
b.IsReading()) {
2435 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2436 return const_cast<TFile*
>(
this)->
Write(
n, opt, bufsize);
2467 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2494 Error(
"WriteBuffer",
"error writing to cache");
2519 auto createKey = [
this]() {
2523 while ((afree = (
TFree*) next())) {
2524 nbytes += afree->
Sizeof();
2526 if (!nbytes)
return (
TKey*)
nullptr;
2532 return (
TKey*)
nullptr;
2537 TKey *key = createKey();
2554 char *start = buffer;
2558 while ((afree = (
TFree*) next())) {
2563 auto actualBytes = buffer-start;
2564 if ( actualBytes != nbytes ) {
2565 if (actualBytes < nbytes) {
2568 memset(buffer,0,nbytes-actualBytes);
2570 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);
2587 const char *root =
"root";
2588 char *psave =
new char[
fBEGIN];
2589 char *buffer = psave;
2591 memcpy(buffer, root, 4); buffer += 4;
2594 tobuf(buffer, version);
2596 if (version < 1000000) {
2600 tobuf(buffer, nfree);
2610 tobuf(buffer, nfree);
2621 Int_t nbytes = buffer - psave;
2712 path +=
"/PROOF-INF";
2714 const char *afile = 0;
2717 if (strcmp(afile,
".") == 0)
continue;
2718 if (strcmp(afile,
"..") == 0)
continue;
2719 filepath.
Form(
"%s/%s", path.
Data(), afile);
2721 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2728 if (strcmp(afile,
".") == 0)
continue;
2729 if (strcmp(afile,
"..") == 0)
continue;
2730 filepath.
Form(
"%s/%s", path.
Data(), afile);
2732 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2736 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2740 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2742 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2757 }
else if (opt.
Contains(
"recreate")) {
2761 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2769 if (strcmp(afile,
".") == 0)
continue;
2770 if (strcmp(afile,
"..") == 0)
continue;
2771 dirpath.
Form(
"%s/%s",dirname,afile);
2779 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2784 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2797 if (filelist) filelist = (
TList*)filelist->
Clone();
2799 Error(
"MakeProject",
"file %s has no StreamerInfo",
GetName());
2803 TString clean_dirname(dirname);
2804 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2805 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2807 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2809 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2814 if (makepar) subdirname = parname;
2815 if (subdirname ==
"") {
2816 Error(
"MakeProject",
"Directory name must not be empty.");
2821 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.
Data());
2822 FILE *sfp = fopen(spath.
Data(),
"w");
2824 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2827 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2828 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.
Data() );
2829 if (!
genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.
Data() );
2830 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.
Data() );
2831 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2832 fprintf(sfp,
" template <typename T>\n");
2833 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2834 fprintf(sfp,
" delete ptr;\n");
2835 fprintf(sfp,
" }\n");
2836 fprintf(sfp,
" template <typename T, typename Q>\n");
2837 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2838 fprintf(sfp,
" // Do nothing\n");
2839 fprintf(sfp,
" }\n");
2840 fprintf(sfp,
" template <typename T, typename Q>\n");
2841 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2842 fprintf(sfp,
" delete ptr.second;\n");
2843 fprintf(sfp,
" }\n");
2844 fprintf(sfp,
" template <typename T, typename Q>\n");
2845 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2846 fprintf(sfp,
" delete ptr.first;\n");
2847 fprintf(sfp,
" }\n");
2848 fprintf(sfp,
" template <typename T, typename Q>\n");
2849 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2850 fprintf(sfp,
" delete ptr.first;\n");
2851 fprintf(sfp,
" delete ptr.second;\n");
2852 fprintf(sfp,
" }\n");
2853 fprintf(sfp,
"};\n\n");
2860 TIter flnext(filelist);
2867 if (strstr(info->
GetName(),
"@@")) {
2884 for(
auto rule : rules) {
2885 if( rule->IsRenameRule() || rule->IsAliasRule() )
2888 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2891 if (
attr.Contains(
"owner")) {
2892 if (
attr.Contains(
"notowner")) {
2915 TIter nextextra(&extrainfos);
2918 filelist->
Add(info);
2929 TIter subnext(list);
2944 subClasses.
Add(subinfo);
2949 subClasses.
Clear(
"nodelete");
2951 extrainfos.
Clear(
"nodelete");
2954 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.
Data());
2955 FILE *allfp = fopen(path,
"a");
2957 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2959 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.
Data());
2963 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
2966 if (!opt.
Contains(
"+") && !makepar) {
2974 FILE *fpMAKE =
nullptr;
2979 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
2981 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
2984 fpMAKE = fopen(path,
"wb");
2986 fpMAKE = fopen(path,
"w");
2989 Error(
"MakeProject",
"cannot open file %s", path.
Data());
2998 FILE *ifp =
nullptr;
2999 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.
Data());
3001 ifp = fopen(path,
"wb");
3003 ifp = fopen(path,
"w");
3006 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3016 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.
Data(),subdirname.
Data(),
gSystem->
GetIncludePath());
3017 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.
Data());
3020 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3023 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3029 FILE *fp = fopen(path,
"wb");
3031 FILE *fp = fopen(path,
"w");
3034 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3043 fprintf(fp,
"<lcgdict>\n");
3046 fprintf(fp,
"#ifdef __CINT__\n");
3058 if (strncmp(info->
GetName(),
"auto_ptr<", strlen(
"auto_ptr<")) == 0) {
3067 for(
auto rule : rules) {
3070 rule->AsString(strrule,
"x");
3073 selections.
Append(strrule);
3076 rule->AsString(strrule);
3077 if (strncmp(strrule.
Data(),
"type=",5)==0) {
3080 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
3087 std::vector<std::string> inside;
3094 switch ( stlkind ) {
3098 what =
"std::pair<";
3108 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3112 tmp.
Form(
"template class %s;\n",
what.Data());
3117 what.ReplaceAll(
"std::",
"");
3120 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3128 tmp.
Form(
"<class name=\"%s\" />\n",key->
GetName());
3137 what.ReplaceAll(
"std::",
"");
3138 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3149 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3153 if (
what[
what.Length()-1] ==
'>') {
3154 tmp.
Form(
"template class %s;\n",
what.Data());
3160 what.ReplaceAll(
"std::",
"");
3161 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3171 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3175 tmp.
Form(
"template class %s;\n",
what.Data());
3184 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3185 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3186 fprintf(ifp,
"%s",instances.
Data());
3187 fprintf(ifp,
"#endif\n");
3188 fprintf(fp,
"%s",selections.
Data());
3189 fprintf(fp,
"</lcgdict>\n");
3191 fprintf(fp,
"#endif\n");
3205 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3212 TString rootbuild = ROOTBUILD;
3221 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.
Data());
3223 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.
Data());
3224 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.
Data());
3227 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3229 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3238 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3247 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3250 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3259 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3272 chmod(cmod.
Data(), 00700);
3274 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and"
3275 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3284 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3286 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.
Data());
3289 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3292 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3297 if (!makepar && !opt.
Contains(
"nocompilation")) {
3306 chmod(
"makep.cmd",00700);
3311 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3316 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3334 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3335 Error(
"MakeProjectParMake",
"path for output file undefined!");
3340 if (!pack || (pack && strlen(pack) <= 0)) {
3341 Error(
"MakeProjectParMake",
"package name undefined!");
3346 FILE *fmk = fopen(filemake,
"wb");
3348 FILE *fmk = fopen(filemake,
"w");
3356 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3357 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3358 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3359 fprintf(fmk,
"#\n");
3360 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3361 fprintf(fmk,
"#\n");
3362 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3364 fprintf(fmk,
"include Makefile.arch\n");
3366 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3368 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3369 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3370 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3372 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3373 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3374 fprintf(fmk,
"else\n");
3375 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3376 fprintf(fmk,
"endif\n");
3378 fprintf(fmk,
"OBJS = $(PACKO)\n");
3380 fprintf(fmk,
"PROGRAMS =\n");
3382 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3384 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3386 fprintf(fmk,
"all: $(PACKLIB)\n");
3388 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3389 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3390 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3391 fprintf(fmk,
"else\n");
3392 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3393 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3394 fprintf(fmk,
"else\n");
3395 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3396 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3397 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3398 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3399 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3400 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3401 fprintf(fmk,
"else\n");
3402 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3403 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3404 fprintf(fmk,
"endif\n");
3405 fprintf(fmk,
"endif\n");
3406 fprintf(fmk,
"else\n");
3407 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3408 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3409 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3410 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3411 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3412 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3413 fprintf(fmk,
"else\n");
3414 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3415 fprintf(fmk,
"endif\n");
3416 fprintf(fmk,
"endif\n");
3417 fprintf(fmk,
"endif\n");
3418 fprintf(fmk,
"endif\n");
3419 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3421 fprintf(fmk,
"clean:\n");
3422 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3424 fprintf(fmk,
"distclean: clean\n");
3425 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3426 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3427 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3429 fprintf(fmk,
"# Dependencies\n");
3431 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3433 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3434 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3435 fprintf(fmk,
"\t\t@rootcint -f $@ $^\n");
3437 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3438 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3456 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3457 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3465 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3466 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3471 if (!pack || (pack && strlen(pack) <= 0)) {
3472 Error(
"MakeProjectParProofInf",
"package name undefined!");
3479 path.
Form(
"%s/BUILD.sh", proofinf);
3481 FILE *
f = fopen(path.
Data(),
"wb");
3483 FILE *
f = fopen(path.
Data(),
"w");
3486 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3491 fprintf(
f,
"#! /bin/sh\n");
3492 fprintf(
f,
"# Build libEvent library.\n");
3495 fprintf(
f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3496 fprintf(
f,
"# adapt the script to the calling environment\n");
3498 fprintf(
f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3499 fprintf(
f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3500 fprintf(
f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3501 fprintf(
f,
"# echo \"event-BUILD: PROOF client\"\n");
3502 fprintf(
f,
"# else\n");
3503 fprintf(
f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3504 fprintf(
f,
"# fi\n");
3506 fprintf(
f,
"if [ \"\" = \"clean\" ]; then\n");
3507 fprintf(
f,
" make distclean\n");
3508 fprintf(
f,
" exit 0\n");
3511 fprintf(
f,
"make\n");
3512 fprintf(
f,
"rc=$?\n");
3513 fprintf(
f,
"echo \"rc=$?\"\n");
3514 fprintf(
f,
"if [ $? != \"0\" ] ; then\n");
3515 fprintf(
f,
" exit 1\n");
3517 fprintf(
f,
"exit 0\n");
3523 path.
Form(
"%s/SETUP.C", proofinf);
3525 f = fopen(path.
Data(),
"wb");
3527 f = fopen(path.
Data(),
"w");
3530 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3535 fprintf(
f,
"Int_t SETUP()\n");
3539 fprintf(
f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3540 fprintf(
f,
"// adapt the macro to the calling environment\n");
3542 fprintf(
f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3543 fprintf(
f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3544 fprintf(
f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3545 fprintf(
f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3546 fprintf(
f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3547 fprintf(
f,
"// } else {\n");
3548 fprintf(
f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3549 fprintf(
f,
"// }\n");
3551 fprintf(
f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3552 fprintf(
f,
" return -1;\n");
3553 fprintf(
f,
" return 0;\n");
3575 TList *list = listRetcode.fList;
3576 auto retcode = listRetcode.fReturnCode;
3589 if (version > 1000000) version -= 1000000;
3590 if (version < 53419 || (59900 < version && version < 59907)) {
3605 if (!base)
continue;
3630 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3638 rulelnk = rulelnk->
Next();
3652 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3657 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3659 if ( (!isstl &&
mode ==0) || (isstl &&
mode ==1) ) {
3668 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3734 for (
Int_t i=0;i<npids;i++) {
3746 Info(
"WriteProcessID",
"name=%s, file=%s", name,
GetName());
3780 listOfRules.
SetName(
"listOfRules");
3781 std::set<TClass*> classSet;
3787 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3793 if ( classSet.find( clinfo ) == classSet.end() ) {
3794 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3801 listOfRules.
Add(obj);
3803 classSet.insert(clinfo);
3814 list.
Add(&listOfRules);
3846 "you want to read through a cache, but you have no valid cache "
3847 "directory set - reading remotely");
3848 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3856 "you want to read through a cache, but you are reading "
3857 "local files - CACHEREAD disabled");
3864 cachefilepath += fileurl.
GetFile();
3868 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3869 "cannot create the directory %s - CACHEREAD disabled",
3870 cachefilepathbasedir.
Data());
3875 cachefilepath +=
"__";
3879 if (strstr(
name,
"zip=")) {
3884 Int_t optioncount = 0;
3893 if (optioncount!=0) {
3898 newoptions +=
value;
3908 cachefilepath +=
"__";
3909 cachefilepath += zipname;
3923 char cacheblock[256];
3924 char remotblock[256];
3927 cfurl = cachefilepath;
3928 cfurl +=
"?filetype=raw";
3931 ropt +=
"&filetype=raw";
3944 ::Error(
"TFile::OpenFromCache",
3945 "cannot open the cache file to check cache consistency");
3950 ::Error(
"TFile::OpenFromCache",
3951 "cannot open the remote file to check cache consistency");
3958 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3960 if (memcmp(cacheblock, remotblock, 256)) {
3961 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3962 "differs from the remote file - forcing an update");
3966 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
3967 "remote file are not readable - forcing an update");
3982 const auto cachefilepathtmp = cachefilepath + std::to_string(
gSystem->
GetPid()) +
".tmp";
3985 "you want to read through a cache, but I "
3986 "cannot make a cache copy of %s - CACHEREAD disabled",
3987 cachefilepathbasedir.
Data());
3997 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
name, cachefilepath.
Data());
4000 fileurl.
SetFile(cachefilepath);
4003 tagfile = cachefilepath;
4004 tagfile +=
".ROOT.cachefile";
4062 if (!url || strlen(url) <= 0) {
4063 ::Error(
"TFile::Open",
"no url specified");
4072 if (
gEnv->
GetValue(
"TFile.CrossProtocolRedirects", 1) == 1) {
4075 ssize_t
len = getxattr(fileurl.
GetFile(),
"eos.url.xroot",
nullptr, 0);
4077 std::string xurl(
len, 0);
4078 if (getxattr(fileurl.
GetFile(),
"eos.url.xroot", &xurl[0],
len) ==
len) {
4079 if ((
f =
TFile::Open(xurl.c_str(), options, ftitle, compress, netopt))) {
4080 if (!
f->IsZombie()) {
4099 TString sto = opts(ito + strlen(
"TIMEOUT="), opts.
Length());
4104 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
4106 sto.
Insert(0,
"TIMEOUT=");
4124 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
4126 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
4131 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
4138 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
4144 const char *
option = opts;
4147 TString namelist(expandedUrl);
4164 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4167 if (!strcasecmp(
option,
"CACHEREAD") ||
4207 lfname = urlname.
GetUrl();
4214 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4215 if (
h->LoadPlugin() == -1)
4223 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4224 if (
h->LoadPlugin() == -1)
4232 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4233 h->LoadPlugin() == 0) {
4234 name.ReplaceAll(
"file:",
"");
4242 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
4243 if (
h->LoadPlugin() == -1)
4258 if (
f &&
f->IsZombie()) {
4281 f &&
f->IsWritable() && !
f->IsRaw()) {
4316 const char *ftitle,
Int_t compress,
4324 if (!url || strlen(url) <= 0) {
4325 ::Error(
"TFile::AsyncOpen",
"no url specified");
4337 TString outf =
".TFileAsyncOpen_";
4348 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4363 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4364 (!strcmp(
h->GetClass(),
"TXNetFile") || !strcmp(
h->GetClass(),
"TNetXNGFile"))
4365 &&
h->LoadPlugin() == 0) {
4370 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4371 !strcmp(
h->GetClass(),
"TAlienFile") &&
h->LoadPlugin() == 0) {
4382 if (!notfound && !
f)
4427 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4429 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4430 !strcmp(
f->GetOption(),
"RECREATE") ||
4441 if (
f)
f->fAsyncHandle = fh;
4453#if defined(R__WINGCC)
4457#elif defined(R__SEEK64)
4458 return ::open64(pathname, flags,
mode);
4469 if (fd < 0)
return 0;
4478 return ::read(fd, buf,
len);
4486 return ::write(fd, buf,
len);
4497#if defined (R__SEEK64)
4498 return ::lseek64(fd,
offset, whence);
4500 return ::_lseeki64(fd,
offset, whence);
4502 return ::lseek(fd,
offset, whence);
4529 return ::_commit(fd);
4600 if (!cached.EndsWith(
"/"))
4607 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(cachedir).Data());
4649 cachetagfile +=
".tag.ROOT.cache";
4653 if (lastcleanuptime < cleanupinterval) {
4654 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4660 cachetagfile +=
"?filetype=raw";
4661 TFile *tagfile =
nullptr;
4663 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4664 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4672#if defined(R__WIN32)
4673 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4674#elif defined(R__MACOSX)
4675 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);
4677 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);
4684 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4814 forceRemote =
kTRUE;
4815 else if (opts.
Contains(
"remote=0"))
4824 if (fname[0] ==
'/') {
4826 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4829 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4847 if (localFile && prefix)
4854 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").
Match(
name)) {
4858 }
else if (!strncmp(
name,
"file:", 5)) {
4884 if (of && (of->
GetSize() > 0)) {
4887 while ((
f = (
TFile *)nxf()))
4888 if (
f->Matches(
name))
4889 return f->GetAsyncOpenStatus();