80#define _XOPEN_SOURCE 600
92# include <sys/types.h>
97#include "RConfigure.h"
133#include "compiledata.h"
164#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
174static struct AddPseudoGlobals {
191 Info(
"TFile",
"default ctor");
327 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
329 auto zombify = [
this] {
333 gROOT->GetListOfClosedObjects()->Add(
this);
343 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
424 if (!create && !recreate && !
update && !read) {
431 if (!fname1 || !fname1[0]) {
432 Error(
"TFile",
"file name is not specified");
438 if (!strcmp(fname1,
"/dev/null") &&
459 Error(
"TFile",
"error expanding path %s", fname1);
475 SysError(
"TFile",
"could not delete %s (errno: %d)",
486 Error(
"TFile",
"file %s already exists", fname);
496 Error(
"TFile",
"no write permission, could not open file %s", fname);
503 Error(
"TFile",
"file %s does not exist", fname);
508 Error(
"TFile",
"no read permission, could not open file %s", fname);
522 SysError(
"TFile",
"file %s can not be opened", fname);
534 SysError(
"TFile",
"file %s can not be opened for reading", fname);
577 gROOT->GetListOfClosedObjects()->Remove(
this);
588 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
614 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
633 Error(
"Init",
"member %s not found in archive %s",
671 char *header =
new char[
kBEGIN+200];
676 Error(
"Init",
"%s failed to read the file type data.",
683 if (strncmp(header,
"root", 4)) {
689 char *buffer = header + 4;
692 frombuf(buffer, &headerLength);
695 Int_t send,sfree,sinfo;
716 if (fBEGIN < 0 || fBEGIN >
fEND) {
718 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
730 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
735 char *buffer_keyloc =
nullptr;
740 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
747 header =
new char[nbytes];
752 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
758 buffer_keyloc = header;
761 buffer_keyloc = header+
fBEGIN;
764 frombuf(buffer,&version); versiondir = version%1000;
769 if (version > 1000) {
774 Int_t sdir,sparent,skeys;
782 buffer_keyloc +=
sizeof(
Int_t);
784 frombuf(buffer_keyloc, &keyversion);
786 if (keyversion > 1000) {
793 cname.ReadBuffer(buffer_keyloc);
794 cname.ReadBuffer(buffer_keyloc);
797 if (fNbytesName < 10 || fNbytesName > 10000) {
798 Error(
"Init",
"cannot read directory info of file %s",
GetName());
834 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
837 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
843 Warning(
"Init",
"file %s probably not closed, "
844 "trying to recover",
GetName());
852 Warning(
"Init",
"successfully recovered %d keys", nrecov);
854 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
862 gROOT->GetListOfFiles()->Add(
this);
868 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
869 if (lenIndex < 5000) lenIndex = 5000;
876 gROOT->GetListOfFiles()->Remove(
this);
882 Warning(
"Init",
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file."
883 " The file was produced with version %d.%02d/%02d of ROOT.",
894 while ((key = (
TKey*)next())) {
905 gROOT->GetListOfClosedObjects()->Add(
this);
953 while ((key = iter()) !=
nullptr) {
1011 gROOT->GetListOfFiles()->Remove(
this);
1012 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1013 gROOT->GetListOfClosedObjects()->Add(
this);
1024 return new TKey(obj,
name, bufsize, mother);
1032 return new TKey(obj, cl,
name, bufsize, mother);
1044 static TFile *currentFile =
nullptr;
1076 Info(
"Delete",
"deleting name = %s", namecycle);
1106 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1107 if (
h->LoadPlugin() == -1)
1109 h->ExecPlugin(3,
this, keys,
option);
1148 tobuf(buffer, version);
1164 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1165 return std::numeric_limits<Int_t>::max() -1;
1181 Int_t nbytes, objlen, nwh = 64;
1182 char *header =
new char[
fBEGIN];
1188 while (idcur <
fEND-100) {
1203 if (nbytes == 0)
break;
1209 if (!objlen) objlen = nbytes-keylen;
1211 uncomp += keylen + objlen;
1284 Int_t nread = maxbytes;
1287 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1293 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1304 if (nb < 0)
return nread;
1306 const Int_t headerSize = 16;
1307 if (nread < headerSize)
return nread;
1312 if (!olen) olen = nbytes-klen;
1331 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1357 TList *list =
nullptr;
1360 auto key = std::make_unique<TKey>(
this);
1362 auto buf = buffer.data();
1366 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1368 return {
nullptr, 1, hash};
1372 if (lookupSICache) {
1377 if (
gDebug > 0)
Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1378 return {
nullptr, 0, hash};
1382 (void) lookupSICache;
1384 key->ReadKeyBuffer(buf);
1385 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1388 list = (
TList*)
Get(
"StreamerInfo");
1392 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1394 return {
nullptr, 1, hash};
1397 return {list, 0, hash};
1464 if(!newfree)
return;
1468 if (nbytesl > 2000000000) nbytesl = 2000000000;
1471 char * buffer =
new char[nb];
1472 char * psave = buffer;
1473 tobuf(buffer, nbytes);
1546 bool forComp = options.
Contains(
"forcomp");
1547 bool extended = options.
Contains(
"extended");
1551 Int_t nbytes,date,time,objlen;
1559 constexpr Int_t nwheader = 512;
1561 char header[nwheader];
1562 char classname[512];
1567 unsigned char nDigits = std::log10(
fEND) + 1;
1569 while (idcur <
fEND) {
1571 Int_t nread = nwheader;
1572 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1575 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1583 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1588 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1599 if (versionkey > 1000) {
1608 if ( ((buffer-header) + nwhc) > nwheader )
1609 nwhc = nwheader - (buffer-header);
1610 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1611 classname[(
int)nwhc] =
'\0';
1612 if (idcur ==
fSeekFree) strlcpy(classname,
"FreeSegments",512);
1613 if (idcur ==
fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1614 if (idcur ==
fSeekKeys) strlcpy(classname,
"KeysList",512);
1617 if ( (buffer-header) >= nwheader )
1623 else if ( ((buffer-header) + nwhc) > nwheader )
1624 nwhc = nwheader - (buffer-header);
1626 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keyname[i]);
1627 keyname[(
int)nwhc] =
'\0';
1629 if ( (buffer-header) >= nwheader )
1635 else if ( ((buffer-header) + nwhc) > nwheader )
1636 nwhc = nwheader - (buffer-header);
1638 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keytitle[i]);
1639 keytitle[(
int)nwhc] =
'\0';
1641 extrainfo.
Form(
" name: %-16s title: %s", keyname, keytitle);
1646 if (objlen != nbytes - keylen) {
1648 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s CX = %5.2f %s", date, time, nDigits + 1, idcur, nbytes, classname,
1649 cx, extrainfo.
Data());
1651 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s %s", date, time, nDigits + 1, idcur, nbytes, classname, extrainfo.
Data());
1655 if (objlen != nbytes - keylen) {
1657 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = %5.2f %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, cx, extrainfo.
Data());
1659 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = 1 %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, extrainfo.
Data());
1665 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s",date,time, nDigits+1, idcur,1,
"END");
1667 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits+1, idcur,1,
"END");
1722 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1769 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1800 for (
Int_t j = 0; j < nbuf; j++) {
1814 char *buf2 =
nullptr;
1817 cur = pos[i]+
len[i];
1820 if (bigRead || (i>=nbuf)) {
1839 for (
Int_t j=0;j<
n;j++) {
1840 memcpy(&buf[k],&buf2[pos[i-
n+j]-curbegin],
len[i-
n+j]);
1850 curbegin = i < nbuf ? pos[i] : 0;
1853 if (buf2)
delete [] buf2;
1903 if (fNbytesFree < 0 || fNbytesFree >
fEND) {
1939 snprintf(pidname,32,
"ProcessID%d",pidf);
1942 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",pidname,
GetName(),(
size_t)pid);
1951 TIter next(pidslist);
1968 p->IncrementCount();
2027 Int_t nbytes,date,time,objlen,nwheader;
2030 char *buffer, *bufread;
2036 Error(
"Recover",
"cannot stat the file %s",
GetName());
2047 Int_t nread = nwheader;
2049 while (idcur <
fEND) {
2051 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
2054 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2062 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
2077 if (versionkey > 1000) {
2086 char *classname =
nullptr;
2087 if (nwhc <= 0 || nwhc > 100)
break;
2088 classname =
new char[nwhc+1];
2089 int i, nwhci = nwhc;
2090 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
2091 classname[nwhci] =
'\0';
2095 && strcmp(classname,
"TBasket")) {
2096 key =
new TKey(
this);
2098 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
2109 delete [] classname;
2114 if (max_file_size <
fEND) max_file_size =
fEND+1000000000;
2121 if (nrecov)
Write();
2144 if (opt !=
"READ" && opt !=
"UPDATE") {
2145 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2152 if (opt ==
"READ") {
2188 SysError(
"ReOpen",
"file %s can not be opened in read mode",
GetName());
2210 SysError(
"ReOpen",
"file %s can not be opened in update mode",
GetName());
2219 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments",
GetName());
2240 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2264 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2269 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2296 if (level < 0) level = 0;
2297 if (level > 99) level = 99;
2352 if (cache) cache->
SetFile(
this, action);
2382 if (
b.IsReading()) {
2443 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2444 return const_cast<TFile*
>(
this)->
Write(
n, opt, bufsize);
2475 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2502 Error(
"WriteBuffer",
"error writing to cache");
2527 auto createKey = [
this]() {
2531 while ((afree = (
TFree*) next())) {
2532 nbytes += afree->
Sizeof();
2534 if (!nbytes)
return (
TKey*)
nullptr;
2540 return (
TKey*)
nullptr;
2545 TKey *key = createKey();
2562 char *start = buffer;
2566 while ((afree = (
TFree*) next())) {
2571 auto actualBytes = buffer-start;
2572 if ( actualBytes != nbytes ) {
2573 if (actualBytes < nbytes) {
2576 memset(buffer,0,nbytes-actualBytes);
2578 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);
2595 const char *root =
"root";
2596 char *psave =
new char[
fBEGIN];
2597 char *buffer = psave;
2599 memcpy(buffer, root, 4); buffer += 4;
2602 tobuf(buffer, version);
2604 if (version < 1000000) {
2608 tobuf(buffer, nfree);
2618 tobuf(buffer, nfree);
2629 Int_t nbytes = buffer - psave;
2720 path +=
"/PROOF-INF";
2722 const char *afile = 0;
2725 if (strcmp(afile,
".") == 0)
continue;
2726 if (strcmp(afile,
"..") == 0)
continue;
2727 filepath.
Form(
"%s/%s", path.
Data(), afile);
2729 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2736 if (strcmp(afile,
".") == 0)
continue;
2737 if (strcmp(afile,
"..") == 0)
continue;
2738 filepath.
Form(
"%s/%s", path.
Data(), afile);
2740 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2744 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2748 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2750 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2765 }
else if (opt.
Contains(
"recreate")) {
2769 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2777 if (strcmp(afile,
".") == 0)
continue;
2778 if (strcmp(afile,
"..") == 0)
continue;
2779 dirpath.
Form(
"%s/%s",dirname,afile);
2787 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2792 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2805 if (filelist) filelist = (
TList*)filelist->
Clone();
2807 Error(
"MakeProject",
"file %s has no StreamerInfo",
GetName());
2811 TString clean_dirname(dirname);
2812 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2813 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2815 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2817 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2822 if (makepar) subdirname = parname;
2823 if (subdirname ==
"") {
2824 Error(
"MakeProject",
"Directory name must not be empty.");
2829 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.
Data());
2830 FILE *sfp = fopen(spath.
Data(),
"w");
2832 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2835 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2836 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.
Data() );
2837 if (!
genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.
Data() );
2838 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.
Data() );
2839 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2840 fprintf(sfp,
" template <typename T>\n");
2841 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2842 fprintf(sfp,
" delete ptr;\n");
2843 fprintf(sfp,
" }\n");
2844 fprintf(sfp,
" template <typename T, typename Q>\n");
2845 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2846 fprintf(sfp,
" // Do nothing\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.second;\n");
2851 fprintf(sfp,
" }\n");
2852 fprintf(sfp,
" template <typename T, typename Q>\n");
2853 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2854 fprintf(sfp,
" delete ptr.first;\n");
2855 fprintf(sfp,
" }\n");
2856 fprintf(sfp,
" template <typename T, typename Q>\n");
2857 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2858 fprintf(sfp,
" delete ptr.first;\n");
2859 fprintf(sfp,
" delete ptr.second;\n");
2860 fprintf(sfp,
" }\n");
2861 fprintf(sfp,
"};\n\n");
2868 TIter flnext(filelist);
2875 if (strstr(info->
GetName(),
"@@")) {
2892 for(
auto rule : rules) {
2893 if( rule->IsRenameRule() || rule->IsAliasRule() )
2896 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2899 if (
attr.Contains(
"owner")) {
2900 if (
attr.Contains(
"notowner")) {
2923 TIter nextextra(&extrainfos);
2926 filelist->
Add(info);
2937 TIter subnext(list);
2952 subClasses.
Add(subinfo);
2957 subClasses.
Clear(
"nodelete");
2959 extrainfos.
Clear(
"nodelete");
2962 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.
Data());
2963 FILE *allfp = fopen(path,
"a");
2965 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2967 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.
Data());
2971 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
2974 if (!opt.
Contains(
"+") && !makepar) {
2982 FILE *fpMAKE =
nullptr;
2987 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
2989 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
2992 fpMAKE = fopen(path,
"wb");
2994 fpMAKE = fopen(path,
"w");
2997 Error(
"MakeProject",
"cannot open file %s", path.
Data());
3006 FILE *ifp =
nullptr;
3007 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.
Data());
3009 ifp = fopen(path,
"wb");
3011 ifp = fopen(path,
"w");
3014 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3024 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.
Data(),subdirname.
Data(),
gSystem->
GetIncludePath());
3025 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.
Data());
3028 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3031 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3037 FILE *fp = fopen(path,
"wb");
3039 FILE *fp = fopen(path,
"w");
3042 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3051 fprintf(fp,
"<lcgdict>\n");
3054 fprintf(fp,
"#ifdef __CINT__\n");
3066 if (strncmp(info->
GetName(),
"auto_ptr<", strlen(
"auto_ptr<")) == 0) {
3075 for(
auto rule : rules) {
3078 rule->AsString(strrule,
"x");
3081 selections.
Append(strrule);
3084 rule->AsString(strrule);
3085 if (strncmp(strrule.
Data(),
"type=",5)==0) {
3088 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
3095 std::vector<std::string> inside;
3102 switch ( stlkind ) {
3106 what =
"std::pair<";
3116 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3120 tmp.
Form(
"template class %s;\n",
what.Data());
3125 what.ReplaceAll(
"std::",
"");
3128 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3136 tmp.
Form(
"<class name=\"%s\" />\n",key->
GetName());
3145 what.ReplaceAll(
"std::",
"");
3146 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3157 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3161 if (
what[
what.Length()-1] ==
'>') {
3162 tmp.
Form(
"template class %s;\n",
what.Data());
3168 what.ReplaceAll(
"std::",
"");
3169 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3179 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3183 tmp.
Form(
"template class %s;\n",
what.Data());
3192 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3193 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3194 fprintf(ifp,
"%s",instances.
Data());
3195 fprintf(ifp,
"#endif\n");
3196 fprintf(fp,
"%s",selections.
Data());
3197 fprintf(fp,
"</lcgdict>\n");
3199 fprintf(fp,
"#endif\n");
3213 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3220 TString rootbuild = ROOTBUILD;
3229 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.
Data());
3231 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.
Data());
3232 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.
Data());
3235 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3237 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3246 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3255 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3258 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3267 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3280 chmod(cmod.
Data(), 00700);
3282 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and"
3283 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3292 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3294 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.
Data());
3297 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3300 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3305 if (!makepar && !opt.
Contains(
"nocompilation")) {
3314 chmod(
"makep.cmd",00700);
3319 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3324 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3342 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3343 Error(
"MakeProjectParMake",
"path for output file undefined!");
3348 if (!pack || (pack && strlen(pack) <= 0)) {
3349 Error(
"MakeProjectParMake",
"package name undefined!");
3354 FILE *fmk = fopen(filemake,
"wb");
3356 FILE *fmk = fopen(filemake,
"w");
3364 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3365 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3366 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3367 fprintf(fmk,
"#\n");
3368 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3369 fprintf(fmk,
"#\n");
3370 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3372 fprintf(fmk,
"include Makefile.arch\n");
3374 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3376 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3377 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3378 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3380 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3381 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3382 fprintf(fmk,
"else\n");
3383 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3384 fprintf(fmk,
"endif\n");
3386 fprintf(fmk,
"OBJS = $(PACKO)\n");
3388 fprintf(fmk,
"PROGRAMS =\n");
3390 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3392 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3394 fprintf(fmk,
"all: $(PACKLIB)\n");
3396 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3397 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3398 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3399 fprintf(fmk,
"else\n");
3400 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3401 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3402 fprintf(fmk,
"else\n");
3403 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3404 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3405 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3406 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3407 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3408 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3409 fprintf(fmk,
"else\n");
3410 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3411 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3412 fprintf(fmk,
"endif\n");
3413 fprintf(fmk,
"endif\n");
3414 fprintf(fmk,
"else\n");
3415 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3416 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3417 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3418 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3419 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3420 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3421 fprintf(fmk,
"else\n");
3422 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3423 fprintf(fmk,
"endif\n");
3424 fprintf(fmk,
"endif\n");
3425 fprintf(fmk,
"endif\n");
3426 fprintf(fmk,
"endif\n");
3427 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3429 fprintf(fmk,
"clean:\n");
3430 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3432 fprintf(fmk,
"distclean: clean\n");
3433 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3434 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3435 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3437 fprintf(fmk,
"# Dependencies\n");
3439 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3441 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3442 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3443 fprintf(fmk,
"\t\t@rootcint -f $@ $^\n");
3445 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3446 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3464 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3465 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3473 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3474 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3479 if (!pack || (pack && strlen(pack) <= 0)) {
3480 Error(
"MakeProjectParProofInf",
"package name undefined!");
3487 path.
Form(
"%s/BUILD.sh", proofinf);
3489 FILE *
f = fopen(path.
Data(),
"wb");
3491 FILE *
f = fopen(path.
Data(),
"w");
3494 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3499 fprintf(
f,
"#! /bin/sh\n");
3500 fprintf(
f,
"# Build libEvent library.\n");
3503 fprintf(
f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3504 fprintf(
f,
"# adapt the script to the calling environment\n");
3506 fprintf(
f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3507 fprintf(
f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3508 fprintf(
f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3509 fprintf(
f,
"# echo \"event-BUILD: PROOF client\"\n");
3510 fprintf(
f,
"# else\n");
3511 fprintf(
f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3512 fprintf(
f,
"# fi\n");
3514 fprintf(
f,
"if [ \"\" = \"clean\" ]; then\n");
3515 fprintf(
f,
" make distclean\n");
3516 fprintf(
f,
" exit 0\n");
3519 fprintf(
f,
"make\n");
3520 fprintf(
f,
"rc=$?\n");
3521 fprintf(
f,
"echo \"rc=$?\"\n");
3522 fprintf(
f,
"if [ $? != \"0\" ] ; then\n");
3523 fprintf(
f,
" exit 1\n");
3525 fprintf(
f,
"exit 0\n");
3531 path.
Form(
"%s/SETUP.C", proofinf);
3533 f = fopen(path.
Data(),
"wb");
3535 f = fopen(path.
Data(),
"w");
3538 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3543 fprintf(
f,
"Int_t SETUP()\n");
3547 fprintf(
f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3548 fprintf(
f,
"// adapt the macro to the calling environment\n");
3550 fprintf(
f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3551 fprintf(
f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3552 fprintf(
f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3553 fprintf(
f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3554 fprintf(
f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3555 fprintf(
f,
"// } else {\n");
3556 fprintf(
f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3557 fprintf(
f,
"// }\n");
3559 fprintf(
f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3560 fprintf(
f,
" return -1;\n");
3561 fprintf(
f,
" return 0;\n");
3583 TList *list = listRetcode.fList;
3584 auto retcode = listRetcode.fReturnCode;
3597 if (version > 1000000) version -= 1000000;
3598 if (version < 53419 || (59900 < version && version < 59907)) {
3613 if (!base)
continue;
3638 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3646 rulelnk = rulelnk->
Next();
3660 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3665 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3667 if ( (!isstl &&
mode ==0) || (isstl &&
mode ==1) ) {
3676 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3742 for (
Int_t i=0;i<npids;i++) {
3754 Info(
"WriteProcessID",
"name=%s, file=%s", name,
GetName());
3788 listOfRules.
SetName(
"listOfRules");
3789 std::set<TClass*> classSet;
3795 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3801 if ( classSet.find( clinfo ) == classSet.end() ) {
3802 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3809 listOfRules.
Add(obj);
3811 classSet.insert(clinfo);
3822 list.
Add(&listOfRules);
3854 "you want to read through a cache, but you have no valid cache "
3855 "directory set - reading remotely");
3856 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3864 "you want to read through a cache, but you are reading "
3865 "local files - CACHEREAD disabled");
3872 cachefilepath += fileurl.
GetFile();
3876 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3877 "cannot create the directory %s - CACHEREAD disabled",
3878 cachefilepathbasedir.
Data());
3883 cachefilepath +=
"__";
3887 if (strstr(
name,
"zip=")) {
3892 Int_t optioncount = 0;
3901 if (optioncount!=0) {
3906 newoptions +=
value;
3916 cachefilepath +=
"__";
3917 cachefilepath += zipname;
3931 char cacheblock[256];
3932 char remotblock[256];
3935 cfurl = cachefilepath;
3936 cfurl +=
"?filetype=raw";
3939 ropt +=
"&filetype=raw";
3952 ::Error(
"TFile::OpenFromCache",
3953 "cannot open the cache file to check cache consistency");
3958 ::Error(
"TFile::OpenFromCache",
3959 "cannot open the remote file to check cache consistency");
3966 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3968 if (memcmp(cacheblock, remotblock, 256)) {
3969 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3970 "differs from the remote file - forcing an update");
3974 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
3975 "remote file are not readable - forcing an update");
3990 const auto cachefilepathtmp = cachefilepath + std::to_string(
gSystem->
GetPid()) +
".tmp";
3993 "you want to read through a cache, but I "
3994 "cannot make a cache copy of %s - CACHEREAD disabled",
3995 cachefilepathbasedir.
Data());
4005 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
name, cachefilepath.
Data());
4008 fileurl.
SetFile(cachefilepath);
4011 tagfile = cachefilepath;
4012 tagfile +=
".ROOT.cachefile";
4070 if (!url || strlen(url) <= 0) {
4071 ::Error(
"TFile::Open",
"no url specified");
4080 if (
gEnv->
GetValue(
"TFile.CrossProtocolRedirects", 1) == 1) {
4083 ssize_t
len = getxattr(fileurl.
GetFile(),
"eos.url.xroot",
nullptr, 0);
4085 std::string xurl(
len, 0);
4086 if (getxattr(fileurl.
GetFile(),
"eos.url.xroot", &xurl[0],
len) ==
len) {
4087 if ((
f =
TFile::Open(xurl.c_str(), options, ftitle, compress, netopt))) {
4088 if (!
f->IsZombie()) {
4107 TString sto = opts(ito + strlen(
"TIMEOUT="), opts.
Length());
4112 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
4114 sto.
Insert(0,
"TIMEOUT=");
4132 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
4134 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
4139 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
4146 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
4152 const char *
option = opts;
4155 TString namelist(expandedUrl);
4172 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4175 if (!strcasecmp(
option,
"CACHEREAD") ||
4215 lfname = urlname.
GetUrl();
4222 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4223 if (
h->LoadPlugin() == -1)
4231 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4232 if (
h->LoadPlugin() == -1)
4240 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4241 h->LoadPlugin() == 0) {
4242 name.ReplaceAll(
"file:",
"");
4250 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
4251 if (
h->LoadPlugin() == -1)
4266 if (
f &&
f->IsZombie()) {
4289 f &&
f->IsWritable() && !
f->IsRaw()) {
4324 const char *ftitle,
Int_t compress,
4332 if (!url || strlen(url) <= 0) {
4333 ::Error(
"TFile::AsyncOpen",
"no url specified");
4345 TString outf =
".TFileAsyncOpen_";
4356 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4371 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4372 (!strcmp(
h->GetClass(),
"TXNetFile") || !strcmp(
h->GetClass(),
"TNetXNGFile"))
4373 &&
h->LoadPlugin() == 0) {
4378 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4379 !strcmp(
h->GetClass(),
"TAlienFile") &&
h->LoadPlugin() == 0) {
4390 if (!notfound && !
f)
4435 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4437 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4438 !strcmp(
f->GetOption(),
"RECREATE") ||
4449 if (
f)
f->fAsyncHandle = fh;
4461#if defined(R__WINGCC)
4465#elif defined(R__SEEK64)
4466 return ::open64(pathname, flags,
mode);
4468 return ::open(pathname, flags,
mode);
4477 if (fd < 0)
return 0;
4486 return ::read(fd, buf,
len);
4494 return ::write(fd, buf,
len);
4505#if defined (R__SEEK64)
4506 return ::lseek64(fd,
offset, whence);
4508 return ::_lseeki64(fd,
offset, whence);
4510 return ::lseek(fd,
offset, whence);
4537 return ::_commit(fd);
4608 if (!cached.EndsWith(
"/"))
4615 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(cachedir).Data());
4657 cachetagfile +=
".tag.ROOT.cache";
4661 if (lastcleanuptime < cleanupinterval) {
4662 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4668 cachetagfile +=
"?filetype=raw";
4669 TFile *tagfile =
nullptr;
4671 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4672 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4680#if defined(R__WIN32)
4681 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4682#elif defined(R__MACOSX)
4683 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);
4685 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);
4692 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4822 forceRemote =
kTRUE;
4823 else if (opts.
Contains(
"remote=0"))
4832 if (fname[0] ==
'/') {
4834 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4837 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4855 if (localFile && prefix)
4862 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").Match(
name)) {
4866 }
else if (!strncmp(
name,
"file:", 5)) {
4892 if (of && (of->
GetSize() > 0)) {
4895 while ((
f = (
TFile *)nxf()))
4896 if (
f->Matches(
name))
4897 return f->GetAsyncOpenStatus();