87#define _XOPEN_SOURCE 600
101# include <sys/types.h>
106#include "RConfigure.h"
142#include "compiledata.h"
154#include <sys/extattr.h>
175#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
178#define getxattr(path, name, value, size) extattr_get_file(path, EXTATTR_NAMESPACE_USER, name, value, size)
188static struct AddPseudoGlobals {
205 Info(
"TFile",
"default ctor");
341 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
343 auto zombify = [
this] {
347 gROOT->GetListOfClosedObjects()->Add(
this);
357 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
438 if (!create && !recreate && !
update && !read) {
445 if (!fname1 || !fname1[0]) {
446 Error(
"TFile",
"file name is not specified");
452 if (!strcmp(fname1,
"/dev/null") &&
472 Error(
"TFile",
"error expanding path %s", fname1);
488 SysError(
"TFile",
"could not delete %s (errno: %d)",
499 Error(
"TFile",
"file %s already exists", fname.
Data());
509 Error(
"TFile",
"no write permission, could not open file %s", fname.
Data());
516 Error(
"TFile",
"file %s does not exist", fname.
Data());
521 Error(
"TFile",
"no read permission, could not open file %s", fname.
Data());
535 SysError(
"TFile",
"file %s can not be opened", fname.
Data());
547 SysError(
"TFile",
"file %s can not be opened for reading", fname.
Data());
588 gROOT->GetListOfClosedObjects()->Remove(
this);
599 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
625 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
644 Error(
"Init",
"member %s not found in archive %s",
682 char *header =
new char[
kBEGIN+200];
687 Error(
"Init",
"%s failed to read the file type data.",
694 if (strncmp(header,
"root", 4)) {
700 char *buffer = header + 4;
703 frombuf(buffer, &headerLength);
706 Int_t send,sfree,sinfo;
727 if (fBEGIN < 0 || fBEGIN >
fEND) {
729 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
741 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
746 char *buffer_keyloc =
nullptr;
751 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
758 header =
new char[nbytes];
763 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
769 buffer_keyloc = header;
772 buffer_keyloc = header+
fBEGIN;
775 frombuf(buffer,&version); versiondir = version%1000;
780 if (version > 1000) {
785 Int_t sdir,sparent,skeys;
793 buffer_keyloc +=
sizeof(
Int_t);
795 frombuf(buffer_keyloc, &keyversion);
797 if (keyversion > 1000) {
804 cname.ReadBuffer(buffer_keyloc);
805 cname.ReadBuffer(buffer_keyloc);
808 if (fNbytesName < 10 || fNbytesName > 10000) {
809 Error(
"Init",
"cannot read directory info of file %s",
GetName());
826 if (
gEnv->
GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
850 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
853 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
859 Warning(
"Init",
"file %s probably not closed, "
860 "trying to recover",
GetName());
868 Warning(
"Init",
"successfully recovered %d keys", nrecov);
870 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
878 gROOT->GetListOfFiles()->Add(
this);
884 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
885 if (lenIndex < 5000) lenIndex = 5000;
892 gROOT->GetListOfFiles()->Remove(
this);
899 const auto separator =
fVersion < 63200 ?
"/" :
".";
900 const auto thisVersion =
gROOT->GetVersionInt();
901 const auto msg =
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file. "
902 "The file was produced with ROOT version %d.%02d%s%02d, "
903 "while the current version is %d.%02d.%02d";
907 thisVersion / 10000, (thisVersion / 100) % (100), thisVersion % 100);
917 while ((key = (
TKey*)next())) {
928 gROOT->GetListOfClosedObjects()->Add(
this);
976 while ((key = iter()) !=
nullptr) {
1034 gROOT->GetListOfFiles()->Remove(
this);
1035 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1036 gROOT->GetListOfClosedObjects()->Add(
this);
1047 return new TKey(obj,
name, bufsize, mother);
1055 return new TKey(obj, cl,
name, bufsize, mother);
1067 static TFile *currentFile =
nullptr;
1099 Info(
"Delete",
"deleting name = %s", namecycle);
1129 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1130 if (
h->LoadPlugin() == -1)
1171 tobuf(buffer, version);
1187 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1188 return std::numeric_limits<Int_t>::max() -1;
1204 Int_t nbytes, objlen, nwh = 64;
1205 char *header =
new char[
fBEGIN];
1211 while (idcur <
fEND-100) {
1226 if (nbytes == 0)
break;
1232 if (!objlen) objlen = nbytes-keylen;
1234 uncomp += keylen + objlen;
1304 if (first <
fBEGIN)
return 0;
1305 if (first >
fEND)
return 0;
1307 Int_t nread = maxbytes;
1308 if (first+maxbytes >
fEND) nread =
fEND-maxbytes;
1310 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1316 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1327 if (nb < 0)
return nread;
1329 const Int_t headerSize = 16;
1330 if (nread < headerSize)
return nread;
1335 if (!olen) olen = nbytes-klen;
1354 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1380 TList *list =
nullptr;
1383 auto key = std::make_unique<TKey>(
this);
1385 auto buf = buffer.data();
1389 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1391 return {
nullptr, 1, hash};
1394 if (lookupSICache) {
1401 Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1402 for(
auto uid : *si_uids)
1404 return {
nullptr, 0, hash};
1407 key->ReadKeyBuffer(buf);
1408 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1411 list = (
TList*)
Get(
"StreamerInfo");
1415 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1417 return {
nullptr, 1, hash};
1420 return {list, 0, hash};
1487 if(!newfree)
return;
1491 if (nbytesl > 2000000000) nbytesl = 2000000000;
1494 char * buffer =
new char[nb];
1495 char * psave = buffer;
1496 tobuf(buffer, nbytes);
1569 bool forComp = options.
Contains(
"forcomp");
1570 bool extended = options.
Contains(
"extended");
1574 Int_t nbytes,date,time,objlen;
1582 constexpr Int_t nwheader = 512;
1584 char header[nwheader];
1585 char classname[512];
1590 unsigned char nDigits = std::log10(
fEND) + 1;
1592 while (idcur <
fEND) {
1594 Int_t nread = nwheader;
1595 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1598 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1606 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1611 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1622 if (versionkey > 1000) {
1631 if ( ((buffer-header) + nwhc) > nwheader )
1632 nwhc = nwheader - (buffer-header);
1633 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1634 classname[(
int)nwhc] =
'\0';
1635 if (idcur ==
fSeekFree) strlcpy(classname,
"FreeSegments",512);
1636 if (idcur ==
fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1637 if (idcur ==
fSeekKeys) strlcpy(classname,
"KeysList",512);
1640 if ( (buffer-header) >= nwheader )
1646 else if ( ((buffer-header) + nwhc) > nwheader )
1647 nwhc = nwheader - (buffer-header);
1649 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keyname[i]);
1650 keyname[(
int)nwhc] =
'\0';
1652 if ( (buffer-header) >= nwheader )
1658 else if ( ((buffer-header) + nwhc) > nwheader )
1659 nwhc = nwheader - (buffer-header);
1661 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keytitle[i]);
1662 keytitle[(
int)nwhc] =
'\0';
1664 extrainfo.
Form(
" name: %-16s title: %s", keyname, keytitle);
1669 if (objlen != nbytes - keylen) {
1671 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s CX = %5.2f %s", date, time, nDigits + 1, idcur, nbytes, classname,
1672 cx, extrainfo.
Data());
1674 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s %s", date, time, nDigits + 1, idcur, nbytes, classname, extrainfo.
Data());
1678 if (objlen != nbytes - keylen) {
1680 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = %5.2f %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, cx, extrainfo.
Data());
1682 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = 1 %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, extrainfo.
Data());
1688 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s",date,time, nDigits+1, idcur,1,
"END");
1690 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits+1, idcur,1,
"END");
1745 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1792 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1823 for (
Int_t j = 0; j < nbuf; j++) {
1837 char *buf2 =
nullptr;
1840 cur = pos[i]+
len[i];
1843 if (bigRead || (i>=nbuf)) {
1862 for (
Int_t j=0;j<
n;j++) {
1863 memcpy(&buf[k],&buf2[pos[i-
n+j]-curbegin],
len[i-
n+j]);
1873 curbegin = i < nbuf ? pos[i] : 0;
1876 if (buf2)
delete [] buf2;
1926 if (fNbytesFree < 0 || fNbytesFree >
fEND) {
1962 snprintf(pidname,32,
"ProcessID%d",pidf);
1965 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",pidname,
GetName(),(
size_t)pid);
1974 TIter next(pidslist);
1991 p->IncrementCount();
2050 Int_t nbytes,date,time,objlen,nwheader;
2053 char *buffer, *bufread;
2059 Error(
"Recover",
"cannot stat the file %s",
GetName());
2070 Int_t nread = nwheader;
2072 while (idcur <
fEND) {
2074 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
2077 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2085 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
2100 if (versionkey > 1000) {
2109 char *classname =
nullptr;
2110 if (nwhc <= 0 || nwhc > 100)
break;
2111 classname =
new char[nwhc+1];
2112 int i, nwhci = nwhc;
2113 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
2114 classname[nwhci] =
'\0';
2118 && strcmp(classname,
"TBasket")) {
2119 key =
new TKey(
this);
2121 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
2132 delete [] classname;
2137 if (max_file_size <
fEND) max_file_size =
fEND+1000000000;
2144 if (nrecov)
Write();
2167 if (opt !=
"READ" && opt !=
"UPDATE") {
2168 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2175 if (opt ==
"READ") {
2211 SysError(
"ReOpen",
"file %s can not be opened in read mode",
GetName());
2233 SysError(
"ReOpen",
"file %s can not be opened in update mode",
GetName());
2242 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments",
GetName());
2263 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2287 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2292 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2319 if (level < 0) level = 0;
2320 if (level > 99) level = 99;
2375 if (cache) cache->
SetFile(
this, action);
2405 if (
b.IsReading()) {
2466 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2467 return const_cast<TFile*
>(
this)->
Write(
n, opt, bufsize);
2498 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2525 Error(
"WriteBuffer",
"error writing to cache");
2550 auto createKey = [
this]() {
2554 while ((afree = (
TFree*) next())) {
2555 nbytes += afree->
Sizeof();
2557 if (!nbytes)
return (
TKey*)
nullptr;
2563 return (
TKey*)
nullptr;
2568 TKey *key = createKey();
2585 char *start = buffer;
2589 while ((afree = (
TFree*) next())) {
2594 auto actualBytes = buffer-start;
2595 if ( actualBytes != nbytes ) {
2596 if (actualBytes < nbytes) {
2599 memset(buffer,0,nbytes-actualBytes);
2601 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);
2618 const char *root =
"root";
2619 char *psave =
new char[
fBEGIN];
2620 char *buffer = psave;
2622 memcpy(buffer, root, 4); buffer += 4;
2625 tobuf(buffer, version);
2627 if (version < 1000000) {
2631 tobuf(buffer, nfree);
2641 tobuf(buffer, nfree);
2652 Int_t nbytes = buffer - psave;
2743 path +=
"/PROOF-INF";
2745 const char *afile = 0;
2748 if (strcmp(afile,
".") == 0)
continue;
2749 if (strcmp(afile,
"..") == 0)
continue;
2750 filepath.
Form(
"%s/%s", path.
Data(), afile);
2752 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2759 if (strcmp(afile,
".") == 0)
continue;
2760 if (strcmp(afile,
"..") == 0)
continue;
2761 filepath.
Form(
"%s/%s", path.
Data(), afile);
2763 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2767 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2771 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2773 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2788 }
else if (opt.
Contains(
"recreate")) {
2792 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2800 if (strcmp(afile,
".") == 0)
continue;
2801 if (strcmp(afile,
"..") == 0)
continue;
2802 dirpath.
Form(
"%s/%s",dirname,afile);
2810 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2815 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2828 if (filelist) filelist = (
TList*)filelist->
Clone();
2830 Error(
"MakeProject",
"file %s has no StreamerInfo",
GetName());
2834 TString clean_dirname(dirname);
2835 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2836 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2838 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2840 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2845 if (makepar) subdirname = parname;
2846 if (subdirname ==
"") {
2847 Error(
"MakeProject",
"Directory name must not be empty.");
2852 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.
Data());
2853 FILE *sfp = fopen(spath.
Data(),
"w");
2855 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2858 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2859 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.
Data() );
2860 if (!
genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.
Data() );
2861 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.
Data() );
2862 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2863 fprintf(sfp,
" template <typename T>\n");
2864 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2865 fprintf(sfp,
" delete ptr;\n");
2866 fprintf(sfp,
" }\n");
2867 fprintf(sfp,
" template <typename T, typename Q>\n");
2868 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2869 fprintf(sfp,
" // Do nothing\n");
2870 fprintf(sfp,
" }\n");
2871 fprintf(sfp,
" template <typename T, typename Q>\n");
2872 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2873 fprintf(sfp,
" delete ptr.second;\n");
2874 fprintf(sfp,
" }\n");
2875 fprintf(sfp,
" template <typename T, typename Q>\n");
2876 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2877 fprintf(sfp,
" delete ptr.first;\n");
2878 fprintf(sfp,
" }\n");
2879 fprintf(sfp,
" template <typename T, typename Q>\n");
2880 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2881 fprintf(sfp,
" delete ptr.first;\n");
2882 fprintf(sfp,
" delete ptr.second;\n");
2883 fprintf(sfp,
" }\n");
2884 fprintf(sfp,
"};\n\n");
2891 TIter flnext(filelist);
2898 if (strstr(info->
GetName(),
"@@")) {
2915 for(
auto rule : rules) {
2916 if( rule->IsRenameRule() || rule->IsAliasRule() )
2919 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2922 if (
attr.Contains(
"owner")) {
2923 if (
attr.Contains(
"notowner")) {
2946 TIter nextextra(&extrainfos);
2949 filelist->
Add(info);
2960 TIter subnext(list);
2975 subClasses.
Add(subinfo);
2980 subClasses.
Clear(
"nodelete");
2982 extrainfos.
Clear(
"nodelete");
2985 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.
Data());
2986 FILE *allfp = fopen(path,
"a");
2988 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2990 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.
Data());
2994 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
2997 if (!opt.
Contains(
"+") && !makepar) {
3005 FILE *fpMAKE =
nullptr;
3010 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
3012 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
3015 fpMAKE = fopen(path,
"wb");
3017 fpMAKE = fopen(path,
"w");
3020 Error(
"MakeProject",
"cannot open file %s", path.
Data());
3029 FILE *ifp =
nullptr;
3030 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.
Data());
3032 ifp = fopen(path,
"wb");
3034 ifp = fopen(path,
"w");
3037 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3047 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.
Data(),subdirname.
Data(),
gSystem->
GetIncludePath());
3048 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.
Data());
3051 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3054 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3060 FILE *fp = fopen(path,
"wb");
3062 FILE *fp = fopen(path,
"w");
3065 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3074 fprintf(fp,
"<lcgdict>\n");
3077 fprintf(fp,
"#ifdef __CINT__\n");
3089 if (strncmp(info->
GetName(),
"auto_ptr<", std::char_traits<char>::length(
"auto_ptr<")) == 0) {
3098 for(
auto rule : rules) {
3101 rule->AsString(strrule,
"x");
3104 selections.
Append(strrule);
3107 rule->AsString(strrule);
3108 if (strncmp(strrule.
Data(),
"type=",5)==0) {
3111 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
3118 std::vector<std::string> inside;
3125 switch ( stlkind ) {
3129 what =
"std::pair<";
3139 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3143 tmp.Form(
"template class %s;\n",
what.Data());
3151 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3159 tmp.Form(
"<class name=\"%s\" />\n",key->
GetName());
3163 tmp.Form(
"template class %s;\n",key->
GetName());
3169 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3180 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3184 if (
what[
what.Length()-1] ==
'>') {
3185 tmp.Form(
"template class %s;\n",
what.Data());
3192 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3202 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3206 tmp.Form(
"template class %s;\n",
what.Data());
3215 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3216 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3217 fprintf(ifp,
"%s",instances.
Data());
3218 fprintf(ifp,
"#endif\n");
3219 fprintf(fp,
"%s",selections.
Data());
3220 fprintf(fp,
"</lcgdict>\n");
3222 fprintf(fp,
"#endif\n");
3236 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3243 TString rootbuild = ROOTBUILD;
3252 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.
Data());
3254 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.
Data());
3255 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.
Data());
3258 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3260 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3269 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3278 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3281 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3290 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3303 chmod(cmod.
Data(), 00700);
3305 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and"
3306 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3315 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3317 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.
Data());
3320 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3323 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3328 if (!makepar && !opt.
Contains(
"nocompilation")) {
3337 chmod(
"makep.cmd",00700);
3342 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3347 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3365 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3366 Error(
"MakeProjectParMake",
"path for output file undefined!");
3371 if (!pack || (pack && strlen(pack) <= 0)) {
3372 Error(
"MakeProjectParMake",
"package name undefined!");
3377 FILE *fmk = fopen(filemake,
"wb");
3379 FILE *fmk = fopen(filemake,
"w");
3387 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3388 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3389 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3390 fprintf(fmk,
"#\n");
3391 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3392 fprintf(fmk,
"#\n");
3393 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3395 fprintf(fmk,
"include Makefile.arch\n");
3397 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3399 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3400 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3401 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3403 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3404 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3405 fprintf(fmk,
"else\n");
3406 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3407 fprintf(fmk,
"endif\n");
3409 fprintf(fmk,
"OBJS = $(PACKO)\n");
3411 fprintf(fmk,
"PROGRAMS =\n");
3413 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3415 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3417 fprintf(fmk,
"all: $(PACKLIB)\n");
3419 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3420 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3421 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3422 fprintf(fmk,
"else\n");
3423 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3424 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3425 fprintf(fmk,
"else\n");
3426 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3427 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3428 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3429 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3430 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3431 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3432 fprintf(fmk,
"else\n");
3433 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3434 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3435 fprintf(fmk,
"endif\n");
3436 fprintf(fmk,
"endif\n");
3437 fprintf(fmk,
"else\n");
3438 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3439 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3440 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3441 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3442 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3443 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3444 fprintf(fmk,
"else\n");
3445 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3446 fprintf(fmk,
"endif\n");
3447 fprintf(fmk,
"endif\n");
3448 fprintf(fmk,
"endif\n");
3449 fprintf(fmk,
"endif\n");
3450 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3452 fprintf(fmk,
"clean:\n");
3453 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3455 fprintf(fmk,
"distclean: clean\n");
3456 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3457 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3458 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3460 fprintf(fmk,
"# Dependencies\n");
3462 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3464 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3465 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3466 fprintf(fmk,
"\t\t@rootcint -f $@ $^\n");
3468 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3469 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3487 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3488 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3496 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3497 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3502 if (!pack || (pack && strlen(pack) <= 0)) {
3503 Error(
"MakeProjectParProofInf",
"package name undefined!");
3510 path.
Form(
"%s/BUILD.sh", proofinf);
3512 FILE *
f = fopen(path.
Data(),
"wb");
3514 FILE *
f = fopen(path.
Data(),
"w");
3517 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3522 fprintf(
f,
"#! /bin/sh\n");
3523 fprintf(
f,
"# Build libEvent library.\n");
3526 fprintf(
f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3527 fprintf(
f,
"# adapt the script to the calling environment\n");
3529 fprintf(
f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3530 fprintf(
f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3531 fprintf(
f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3532 fprintf(
f,
"# echo \"event-BUILD: PROOF client\"\n");
3533 fprintf(
f,
"# else\n");
3534 fprintf(
f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3535 fprintf(
f,
"# fi\n");
3537 fprintf(
f,
"if [ \"\" = \"clean\" ]; then\n");
3538 fprintf(
f,
" make distclean\n");
3539 fprintf(
f,
" exit 0\n");
3542 fprintf(
f,
"make\n");
3543 fprintf(
f,
"rc=$?\n");
3544 fprintf(
f,
"echo \"rc=$?\"\n");
3545 fprintf(
f,
"if [ $? != \"0\" ] ; then\n");
3546 fprintf(
f,
" exit 1\n");
3548 fprintf(
f,
"exit 0\n");
3554 path.
Form(
"%s/SETUP.C", proofinf);
3556 f = fopen(path.
Data(),
"wb");
3558 f = fopen(path.
Data(),
"w");
3561 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3566 fprintf(
f,
"Int_t SETUP()\n");
3570 fprintf(
f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3571 fprintf(
f,
"// adapt the macro to the calling environment\n");
3573 fprintf(
f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3574 fprintf(
f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3575 fprintf(
f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3576 fprintf(
f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3577 fprintf(
f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3578 fprintf(
f,
"// } else {\n");
3579 fprintf(
f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3580 fprintf(
f,
"// }\n");
3582 fprintf(
f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3583 fprintf(
f,
" return -1;\n");
3584 fprintf(
f,
" return 0;\n");
3606 TList *list = listRetcode.fList;
3607 auto retcode = listRetcode.fReturnCode;
3620 if (version > 1000000) version -= 1000000;
3621 if (version < 53419 || (59900 < version && version < 59907)) {
3636 if (!base)
continue;
3647 std::vector<Int_t> si_uids;
3662 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3670 rulelnk = rulelnk->
Next();
3684 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3689 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3691 if ( (!isstl &&
mode ==0) || (isstl &&
mode ==1) ) {
3698 if (uid >= 0 && uid < fClassIndex->
GetSize()) {
3699 si_uids.push_back(uid);
3703 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3767 for (
Int_t i=0;i<npids;i++) {
3779 Info(
"WriteProcessID",
"name=%s, file=%s", name,
GetName());
3813 listOfRules.
SetName(
"listOfRules");
3814 std::set<TClass*> classSet;
3820 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3826 if ( classSet.find( clinfo ) == classSet.end() ) {
3827 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3834 listOfRules.
Add(obj);
3836 classSet.insert(clinfo);
3847 list.
Add(&listOfRules);
3879 "you want to read through a cache, but you have no valid cache "
3880 "directory set - reading remotely");
3881 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3889 "you want to read through a cache, but you are reading "
3890 "local files - CACHEREAD disabled");
3897 cachefilepath += fileurl.
GetFile();
3901 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3902 "cannot create the directory %s - CACHEREAD disabled",
3903 cachefilepathbasedir.
Data());
3908 cachefilepath +=
"__";
3912 if (strstr(
name,
"zip=")) {
3917 Int_t optioncount = 0;
3926 if (optioncount!=0) {
3931 newoptions +=
value;
3941 cachefilepath +=
"__";
3942 cachefilepath += zipname;
3956 char cacheblock[256];
3957 char remotblock[256];
3960 cfurl = cachefilepath;
3961 cfurl +=
"?filetype=raw";
3964 ropt +=
"&filetype=raw";
3977 ::Error(
"TFile::OpenFromCache",
3978 "cannot open the cache file to check cache consistency");
3983 ::Error(
"TFile::OpenFromCache",
3984 "cannot open the remote file to check cache consistency");
3991 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3993 if (memcmp(cacheblock, remotblock, 256)) {
3994 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3995 "differs from the remote file - forcing an update");
3999 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
4000 "remote file are not readable - forcing an update");
4015 const auto cachefilepathtmp = cachefilepath + std::to_string(
gSystem->
GetPid()) +
".tmp";
4018 "you want to read through a cache, but I "
4019 "cannot make a cache copy of %s - CACHEREAD disabled",
4020 cachefilepathbasedir.
Data());
4030 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
name, cachefilepath.
Data());
4033 fileurl.
SetFile(cachefilepath);
4036 tagfile = cachefilepath;
4037 tagfile +=
".ROOT.cachefile";
4095 if (!url || strlen(url) <= 0) {
4096 ::Error(
"TFile::Open",
"no url specified");
4105 if (
gEnv->
GetValue(
"TFile.CrossProtocolRedirects", 1) == 1) {
4108 ssize_t
len = getxattr(fileurl.
GetFile(),
"eos.url.xroot",
nullptr, 0);
4110 std::string xurl(
len, 0);
4111 if (getxattr(fileurl.
GetFile(),
"eos.url.xroot", &xurl[0],
len) ==
len) {
4112 if ((
f =
TFile::Open(xurl.c_str(), options, ftitle, compress, netopt))) {
4113 if (!
f->IsZombie()) {
4132 TString sto = opts(ito + std::char_traits<char>::length(
"TIMEOUT="), opts.
Length());
4137 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
4139 sto.
Insert(0,
"TIMEOUT=");
4157 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
4159 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
4164 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
4171 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
4177 const char *
option = opts;
4180 TString namelist(expandedUrl);
4197 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4200 if (!strcasecmp(
option,
"CACHEREAD") ||
4240 lfname = urlname.
GetUrl();
4247 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4248 if (
h->LoadPlugin() == -1)
4256 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4257 if (
h->LoadPlugin() == -1)
4265 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4266 h->LoadPlugin() == 0) {
4267 name.ReplaceAll(
"file:",
"");
4275 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
4276 if (
h->LoadPlugin() == -1)
4292 if (
f &&
f->IsZombie()) {
4315 f &&
f->IsWritable() && !
f->IsRaw()) {
4350 const char *ftitle,
Int_t compress,
4358 if (!url || strlen(url) <= 0) {
4359 ::Error(
"TFile::AsyncOpen",
"no url specified");
4371 TString outf =
".TFileAsyncOpen_";
4382 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4397 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4398 !strcmp(
h->GetClass(),
"TNetXNGFile")
4399 &&
h->LoadPlugin() == 0) {
4410 if (!notfound && !
f)
4455 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4457 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4458 !strcmp(
f->GetOption(),
"RECREATE") ||
4469 if (
f)
f->fAsyncHandle = fh;
4481#if defined(R__WINGCC)
4485#elif defined(R__SEEK64)
4486 return ::open64(pathname, flags,
mode);
4488 return ::open(pathname, flags,
mode);
4497 if (fd < 0)
return 0;
4506 return ::read(fd, buf,
len);
4514 return ::write(fd, buf,
len);
4525#if defined (R__SEEK64)
4526 return ::lseek64(fd,
offset, whence);
4528 return ::_lseeki64(fd,
offset, whence);
4530 return ::lseek(fd,
offset, whence);
4557 return ::_commit(fd);
4628 if (!cached.EndsWith(
"/"))
4635 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(cachedir).Data());
4677 cachetagfile +=
".tag.ROOT.cache";
4681 if (lastcleanuptime < cleanupinterval) {
4682 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4688 cachetagfile +=
"?filetype=raw";
4689 TFile *tagfile =
nullptr;
4691 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4692 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4700#if defined(R__WIN32)
4701 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4702#elif defined(R__MACOSX)
4703 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);
4705 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);
4712 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4842 forceRemote =
kTRUE;
4843 else if (opts.
Contains(
"remote=0"))
4852 if (fname[0] ==
'/') {
4854 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4857 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4874 if (localFile && prefix)
4881 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").Match(
name)) {
4885 }
else if (!strncmp(
name,
"file:", 5)) {