80#define _XOPEN_SOURCE 600
94# include <sys/types.h>
99#include "RConfigure.h"
135#include "compiledata.h"
147#include <sys/extattr.h>
168#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
171#define getxattr(path, name, value, size) extattr_get_file(path, EXTATTR_NAMESPACE_USER, name, value, size)
181static struct AddPseudoGlobals {
198 Info(
"TFile",
"default ctor");
334 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
336 auto zombify = [
this] {
340 gROOT->GetListOfClosedObjects()->Add(
this);
350 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
438 if (!fname1 || !fname1[0]) {
439 Error(
"TFile",
"file name is not specified");
445 if (!strcmp(fname1,
"/dev/null") &&
466 Error(
"TFile",
"error expanding path %s", fname1);
482 SysError(
"TFile",
"could not delete %s (errno: %d)",
493 Error(
"TFile",
"file %s already exists", fname);
503 Error(
"TFile",
"no write permission, could not open file %s", fname);
510 Error(
"TFile",
"file %s does not exist", fname);
515 Error(
"TFile",
"no read permission, could not open file %s", fname);
529 SysError(
"TFile",
"file %s can not be opened", fname);
541 SysError(
"TFile",
"file %s can not be opened for reading", fname);
584 gROOT->GetListOfClosedObjects()->Remove(
this);
595 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
621 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
640 Error(
"Init",
"member %s not found in archive %s",
678 char *header =
new char[
kBEGIN+200];
683 Error(
"Init",
"%s failed to read the file type data.",
690 if (strncmp(header,
"root", 4)) {
696 char *buffer = header + 4;
699 frombuf(buffer, &headerLength);
702 Int_t send,sfree,sinfo;
723 if (fBEGIN < 0 || fBEGIN >
fEND) {
725 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
737 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
742 char *buffer_keyloc =
nullptr;
747 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
754 header =
new char[nbytes];
759 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
765 buffer_keyloc = header;
768 buffer_keyloc = header+
fBEGIN;
771 frombuf(buffer,&version); versiondir = version%1000;
776 if (version > 1000) {
781 Int_t sdir,sparent,skeys;
789 buffer_keyloc +=
sizeof(
Int_t);
791 frombuf(buffer_keyloc, &keyversion);
793 if (keyversion > 1000) {
800 cname.ReadBuffer(buffer_keyloc);
801 cname.ReadBuffer(buffer_keyloc);
804 if (fNbytesName < 10 || fNbytesName > 10000) {
805 Error(
"Init",
"cannot read directory info of file %s",
GetName());
822 if (
gEnv->
GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
846 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
849 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
855 Warning(
"Init",
"file %s probably not closed, "
856 "trying to recover",
GetName());
864 Warning(
"Init",
"successfully recovered %d keys", nrecov);
866 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
874 gROOT->GetListOfFiles()->Add(
this);
880 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
881 if (lenIndex < 5000) lenIndex = 5000;
888 gROOT->GetListOfFiles()->Remove(
this);
894 Warning(
"Init",
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file."
895 " The file was produced with version %d.%02d/%02d of ROOT.",
906 while ((key = (
TKey*)next())) {
917 gROOT->GetListOfClosedObjects()->Add(
this);
965 while ((key = iter()) !=
nullptr) {
1023 gROOT->GetListOfFiles()->Remove(
this);
1024 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1025 gROOT->GetListOfClosedObjects()->Add(
this);
1036 return new TKey(obj,
name, bufsize, mother);
1044 return new TKey(obj, cl,
name, bufsize, mother);
1056 static TFile *currentFile =
nullptr;
1088 Info(
"Delete",
"deleting name = %s", namecycle);
1118 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1119 if (
h->LoadPlugin() == -1)
1160 tobuf(buffer, version);
1176 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1177 return std::numeric_limits<Int_t>::max() -1;
1193 Int_t nbytes, objlen, nwh = 64;
1194 char *header =
new char[
fBEGIN];
1200 while (idcur <
fEND-100) {
1215 if (nbytes == 0)
break;
1221 if (!objlen) objlen = nbytes-keylen;
1223 uncomp += keylen + objlen;
1296 Int_t nread = maxbytes;
1299 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1305 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1316 if (nb < 0)
return nread;
1318 const Int_t headerSize = 16;
1319 if (nread < headerSize)
return nread;
1324 if (!olen) olen = nbytes-klen;
1343 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1369 TList *list =
nullptr;
1372 auto key = std::make_unique<TKey>(
this);
1374 auto buf = buffer.data();
1378 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1380 return {
nullptr, 1, hash};
1383 if (lookupSICache) {
1390 Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1391 for(
auto uid : *si_uids)
1393 return {
nullptr, 0, hash};
1396 key->ReadKeyBuffer(buf);
1397 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1400 list = (
TList*)
Get(
"StreamerInfo");
1404 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1406 return {
nullptr, 1, hash};
1409 return {list, 0, hash};
1476 if(!newfree)
return;
1480 if (nbytesl > 2000000000) nbytesl = 2000000000;
1483 char * buffer =
new char[nb];
1484 char * psave = buffer;
1485 tobuf(buffer, nbytes);
1558 bool forComp = options.
Contains(
"forcomp");
1559 bool extended = options.
Contains(
"extended");
1563 Int_t nbytes,date,time,objlen;
1571 constexpr Int_t nwheader = 512;
1573 char header[nwheader];
1574 char classname[512];
1579 unsigned char nDigits = std::log10(
fEND) + 1;
1581 while (idcur <
fEND) {
1583 Int_t nread = nwheader;
1584 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1587 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1595 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1600 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1611 if (versionkey > 1000) {
1620 if ( ((buffer-header) + nwhc) > nwheader )
1621 nwhc = nwheader - (buffer-header);
1622 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1623 classname[(
int)nwhc] =
'\0';
1624 if (idcur ==
fSeekFree) strlcpy(classname,
"FreeSegments",512);
1625 if (idcur ==
fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1626 if (idcur ==
fSeekKeys) strlcpy(classname,
"KeysList",512);
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, &keyname[i]);
1639 keyname[(
int)nwhc] =
'\0';
1641 if ( (buffer-header) >= nwheader )
1647 else if ( ((buffer-header) + nwhc) > nwheader )
1648 nwhc = nwheader - (buffer-header);
1650 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keytitle[i]);
1651 keytitle[(
int)nwhc] =
'\0';
1653 extrainfo.
Form(
" name: %-16s title: %s", keyname, keytitle);
1658 if (objlen != nbytes - keylen) {
1660 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s CX = %5.2f %s", date, time, nDigits + 1, idcur, nbytes, classname,
1661 cx, extrainfo.
Data());
1663 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s %s", date, time, nDigits + 1, idcur, nbytes, classname, extrainfo.
Data());
1667 if (objlen != nbytes - keylen) {
1669 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = %5.2f %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, cx, extrainfo.
Data());
1671 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = 1 %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, extrainfo.
Data());
1677 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s",date,time, nDigits+1, idcur,1,
"END");
1679 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits+1, idcur,1,
"END");
1734 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1781 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1812 for (
Int_t j = 0; j < nbuf; j++) {
1826 char *buf2 =
nullptr;
1829 cur = pos[i]+
len[i];
1832 if (bigRead || (i>=nbuf)) {
1851 for (
Int_t j=0;j<
n;j++) {
1852 memcpy(&buf[k],&buf2[pos[i-
n+j]-curbegin],
len[i-
n+j]);
1862 curbegin = i < nbuf ? pos[i] : 0;
1865 if (buf2)
delete [] buf2;
1915 if (fNbytesFree < 0 || fNbytesFree >
fEND) {
1951 snprintf(pidname,32,
"ProcessID%d",pidf);
1954 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",pidname,
GetName(),(
size_t)pid);
1963 TIter next(pidslist);
1980 p->IncrementCount();
2039 Int_t nbytes,date,time,objlen,nwheader;
2042 char *buffer, *bufread;
2048 Error(
"Recover",
"cannot stat the file %s",
GetName());
2059 Int_t nread = nwheader;
2061 while (idcur <
fEND) {
2063 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
2066 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2074 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
2089 if (versionkey > 1000) {
2098 char *classname =
nullptr;
2099 if (nwhc <= 0 || nwhc > 100)
break;
2100 classname =
new char[nwhc+1];
2101 int i, nwhci = nwhc;
2102 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
2103 classname[nwhci] =
'\0';
2107 && strcmp(classname,
"TBasket")) {
2108 key =
new TKey(
this);
2110 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
2121 delete [] classname;
2126 if (max_file_size <
fEND) max_file_size =
fEND+1000000000;
2133 if (nrecov)
Write();
2156 if (opt !=
"READ" && opt !=
"UPDATE") {
2157 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2164 if (opt ==
"READ") {
2200 SysError(
"ReOpen",
"file %s can not be opened in read mode",
GetName());
2222 SysError(
"ReOpen",
"file %s can not be opened in update mode",
GetName());
2231 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments",
GetName());
2252 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2276 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2281 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2308 if (level < 0) level = 0;
2309 if (level > 99) level = 99;
2364 if (cache) cache->
SetFile(
this, action);
2394 if (
b.IsReading()) {
2455 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2456 return const_cast<TFile*
>(
this)->
Write(
n, opt, bufsize);
2487 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2514 Error(
"WriteBuffer",
"error writing to cache");
2539 auto createKey = [
this]() {
2543 while ((afree = (
TFree*) next())) {
2544 nbytes += afree->
Sizeof();
2546 if (!nbytes)
return (
TKey*)
nullptr;
2552 return (
TKey*)
nullptr;
2557 TKey *key = createKey();
2574 char *start = buffer;
2578 while ((afree = (
TFree*) next())) {
2583 auto actualBytes = buffer-start;
2584 if ( actualBytes != nbytes ) {
2585 if (actualBytes < nbytes) {
2588 memset(buffer,0,nbytes-actualBytes);
2590 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);
2607 const char *root =
"root";
2608 char *psave =
new char[
fBEGIN];
2609 char *buffer = psave;
2611 memcpy(buffer, root, 4); buffer += 4;
2614 tobuf(buffer, version);
2616 if (version < 1000000) {
2620 tobuf(buffer, nfree);
2630 tobuf(buffer, nfree);
2641 Int_t nbytes = buffer - psave;
2732 path +=
"/PROOF-INF";
2734 const char *afile = 0;
2737 if (strcmp(afile,
".") == 0)
continue;
2738 if (strcmp(afile,
"..") == 0)
continue;
2739 filepath.
Form(
"%s/%s", path.
Data(), afile);
2741 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2748 if (strcmp(afile,
".") == 0)
continue;
2749 if (strcmp(afile,
"..") == 0)
continue;
2750 filepath.
Form(
"%s/%s", path.
Data(), afile);
2752 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2756 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2760 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2762 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2777 }
else if (opt.
Contains(
"recreate")) {
2781 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2789 if (strcmp(afile,
".") == 0)
continue;
2790 if (strcmp(afile,
"..") == 0)
continue;
2791 dirpath.
Form(
"%s/%s",dirname,afile);
2799 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2804 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2817 if (filelist) filelist = (
TList*)filelist->
Clone();
2819 Error(
"MakeProject",
"file %s has no StreamerInfo",
GetName());
2823 TString clean_dirname(dirname);
2824 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2825 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2827 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2829 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2834 if (makepar) subdirname = parname;
2835 if (subdirname ==
"") {
2836 Error(
"MakeProject",
"Directory name must not be empty.");
2841 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.
Data());
2842 FILE *sfp = fopen(spath.
Data(),
"w");
2844 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2847 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2848 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.
Data() );
2849 if (!
genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.
Data() );
2850 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.
Data() );
2851 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2852 fprintf(sfp,
" template <typename T>\n");
2853 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2854 fprintf(sfp,
" delete ptr;\n");
2855 fprintf(sfp,
" }\n");
2856 fprintf(sfp,
" template <typename T, typename Q>\n");
2857 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2858 fprintf(sfp,
" // Do nothing\n");
2859 fprintf(sfp,
" }\n");
2860 fprintf(sfp,
" template <typename T, typename Q>\n");
2861 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2862 fprintf(sfp,
" delete ptr.second;\n");
2863 fprintf(sfp,
" }\n");
2864 fprintf(sfp,
" template <typename T, typename Q>\n");
2865 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2866 fprintf(sfp,
" delete ptr.first;\n");
2867 fprintf(sfp,
" }\n");
2868 fprintf(sfp,
" template <typename T, typename Q>\n");
2869 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2870 fprintf(sfp,
" delete ptr.first;\n");
2871 fprintf(sfp,
" delete ptr.second;\n");
2872 fprintf(sfp,
" }\n");
2873 fprintf(sfp,
"};\n\n");
2880 TIter flnext(filelist);
2887 if (strstr(info->
GetName(),
"@@")) {
2904 for(
auto rule : rules) {
2905 if( rule->IsRenameRule() || rule->IsAliasRule() )
2908 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2911 if (
attr.Contains(
"owner")) {
2912 if (
attr.Contains(
"notowner")) {
2935 TIter nextextra(&extrainfos);
2938 filelist->
Add(info);
2949 TIter subnext(list);
2964 subClasses.
Add(subinfo);
2969 subClasses.
Clear(
"nodelete");
2971 extrainfos.
Clear(
"nodelete");
2974 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.
Data());
2975 FILE *allfp = fopen(path,
"a");
2977 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2979 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.
Data());
2983 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
2986 if (!opt.
Contains(
"+") && !makepar) {
2994 FILE *fpMAKE =
nullptr;
2999 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
3001 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
3004 fpMAKE = fopen(path,
"wb");
3006 fpMAKE = fopen(path,
"w");
3009 Error(
"MakeProject",
"cannot open file %s", path.
Data());
3018 FILE *ifp =
nullptr;
3019 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.
Data());
3021 ifp = fopen(path,
"wb");
3023 ifp = fopen(path,
"w");
3026 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3036 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.
Data(),subdirname.
Data(),
gSystem->
GetIncludePath());
3037 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.
Data());
3040 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3043 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3049 FILE *fp = fopen(path,
"wb");
3051 FILE *fp = fopen(path,
"w");
3054 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3063 fprintf(fp,
"<lcgdict>\n");
3066 fprintf(fp,
"#ifdef __CINT__\n");
3078 if (strncmp(info->
GetName(),
"auto_ptr<", strlen(
"auto_ptr<")) == 0) {
3087 for(
auto rule : rules) {
3090 rule->AsString(strrule,
"x");
3093 selections.
Append(strrule);
3096 rule->AsString(strrule);
3097 if (strncmp(strrule.
Data(),
"type=",5)==0) {
3100 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
3107 std::vector<std::string> inside;
3114 switch ( stlkind ) {
3118 what =
"std::pair<";
3128 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3132 tmp.
Form(
"template class %s;\n",
what.Data());
3140 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3148 tmp.
Form(
"<class name=\"%s\" />\n",key->
GetName());
3158 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3169 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3173 if (
what[
what.Length()-1] ==
'>') {
3174 tmp.
Form(
"template class %s;\n",
what.Data());
3181 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3191 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
3195 tmp.
Form(
"template class %s;\n",
what.Data());
3204 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3205 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3206 fprintf(ifp,
"%s",instances.
Data());
3207 fprintf(ifp,
"#endif\n");
3208 fprintf(fp,
"%s",selections.
Data());
3209 fprintf(fp,
"</lcgdict>\n");
3211 fprintf(fp,
"#endif\n");
3225 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3232 TString rootbuild = ROOTBUILD;
3241 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.
Data());
3243 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.
Data());
3244 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.
Data());
3247 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3249 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3258 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3267 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3270 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3279 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3292 chmod(cmod.
Data(), 00700);
3294 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and"
3295 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3304 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3306 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.
Data());
3309 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3312 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3317 if (!makepar && !opt.
Contains(
"nocompilation")) {
3326 chmod(
"makep.cmd",00700);
3331 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3336 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3354 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3355 Error(
"MakeProjectParMake",
"path for output file undefined!");
3360 if (!pack || (pack && strlen(pack) <= 0)) {
3361 Error(
"MakeProjectParMake",
"package name undefined!");
3366 FILE *fmk = fopen(filemake,
"wb");
3368 FILE *fmk = fopen(filemake,
"w");
3376 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3377 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3378 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3379 fprintf(fmk,
"#\n");
3380 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3381 fprintf(fmk,
"#\n");
3382 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3384 fprintf(fmk,
"include Makefile.arch\n");
3386 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3388 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3389 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3390 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3392 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3393 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3394 fprintf(fmk,
"else\n");
3395 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3396 fprintf(fmk,
"endif\n");
3398 fprintf(fmk,
"OBJS = $(PACKO)\n");
3400 fprintf(fmk,
"PROGRAMS =\n");
3402 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3404 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3406 fprintf(fmk,
"all: $(PACKLIB)\n");
3408 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3409 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3410 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3411 fprintf(fmk,
"else\n");
3412 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3413 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3414 fprintf(fmk,
"else\n");
3415 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3416 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3417 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3418 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3419 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3420 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3421 fprintf(fmk,
"else\n");
3422 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3423 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3424 fprintf(fmk,
"endif\n");
3425 fprintf(fmk,
"endif\n");
3426 fprintf(fmk,
"else\n");
3427 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3428 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3429 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3430 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3431 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3432 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3433 fprintf(fmk,
"else\n");
3434 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3435 fprintf(fmk,
"endif\n");
3436 fprintf(fmk,
"endif\n");
3437 fprintf(fmk,
"endif\n");
3438 fprintf(fmk,
"endif\n");
3439 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3441 fprintf(fmk,
"clean:\n");
3442 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3444 fprintf(fmk,
"distclean: clean\n");
3445 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3446 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3447 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3449 fprintf(fmk,
"# Dependencies\n");
3451 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3453 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3454 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3455 fprintf(fmk,
"\t\t@rootcint -f $@ $^\n");
3457 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3458 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3476 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3477 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3485 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3486 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3491 if (!pack || (pack && strlen(pack) <= 0)) {
3492 Error(
"MakeProjectParProofInf",
"package name undefined!");
3499 path.
Form(
"%s/BUILD.sh", proofinf);
3501 FILE *
f = fopen(path.
Data(),
"wb");
3503 FILE *
f = fopen(path.
Data(),
"w");
3506 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3511 fprintf(
f,
"#! /bin/sh\n");
3512 fprintf(
f,
"# Build libEvent library.\n");
3515 fprintf(
f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3516 fprintf(
f,
"# adapt the script to the calling environment\n");
3518 fprintf(
f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3519 fprintf(
f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3520 fprintf(
f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3521 fprintf(
f,
"# echo \"event-BUILD: PROOF client\"\n");
3522 fprintf(
f,
"# else\n");
3523 fprintf(
f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3524 fprintf(
f,
"# fi\n");
3526 fprintf(
f,
"if [ \"\" = \"clean\" ]; then\n");
3527 fprintf(
f,
" make distclean\n");
3528 fprintf(
f,
" exit 0\n");
3531 fprintf(
f,
"make\n");
3532 fprintf(
f,
"rc=$?\n");
3533 fprintf(
f,
"echo \"rc=$?\"\n");
3534 fprintf(
f,
"if [ $? != \"0\" ] ; then\n");
3535 fprintf(
f,
" exit 1\n");
3537 fprintf(
f,
"exit 0\n");
3543 path.
Form(
"%s/SETUP.C", proofinf);
3545 f = fopen(path.
Data(),
"wb");
3547 f = fopen(path.
Data(),
"w");
3550 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3555 fprintf(
f,
"Int_t SETUP()\n");
3559 fprintf(
f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3560 fprintf(
f,
"// adapt the macro to the calling environment\n");
3562 fprintf(
f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3563 fprintf(
f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3564 fprintf(
f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3565 fprintf(
f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3566 fprintf(
f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3567 fprintf(
f,
"// } else {\n");
3568 fprintf(
f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3569 fprintf(
f,
"// }\n");
3571 fprintf(
f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3572 fprintf(
f,
" return -1;\n");
3573 fprintf(
f,
" return 0;\n");
3595 TList *list = listRetcode.fList;
3596 auto retcode = listRetcode.fReturnCode;
3609 if (version > 1000000) version -= 1000000;
3610 if (version < 53419 || (59900 < version && version < 59907)) {
3625 if (!base)
continue;
3636 std::vector<Int_t> si_uids;
3651 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3659 rulelnk = rulelnk->
Next();
3673 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3678 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3680 if ( (!isstl &&
mode ==0) || (isstl &&
mode ==1) ) {
3687 if (uid >= 0 && uid < fClassIndex->
GetSize()) {
3688 si_uids.push_back(uid);
3692 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3756 for (
Int_t i=0;i<npids;i++) {
3768 Info(
"WriteProcessID",
"name=%s, file=%s", name,
GetName());
3802 listOfRules.
SetName(
"listOfRules");
3803 std::set<TClass*> classSet;
3809 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3815 if ( classSet.find( clinfo ) == classSet.end() ) {
3816 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3823 listOfRules.
Add(obj);
3825 classSet.insert(clinfo);
3836 list.
Add(&listOfRules);
3868 "you want to read through a cache, but you have no valid cache "
3869 "directory set - reading remotely");
3870 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3878 "you want to read through a cache, but you are reading "
3879 "local files - CACHEREAD disabled");
3886 cachefilepath += fileurl.
GetFile();
3890 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3891 "cannot create the directory %s - CACHEREAD disabled",
3892 cachefilepathbasedir.
Data());
3897 cachefilepath +=
"__";
3901 if (strstr(
name,
"zip=")) {
3906 Int_t optioncount = 0;
3915 if (optioncount!=0) {
3920 newoptions +=
value;
3930 cachefilepath +=
"__";
3931 cachefilepath += zipname;
3945 char cacheblock[256];
3946 char remotblock[256];
3949 cfurl = cachefilepath;
3950 cfurl +=
"?filetype=raw";
3953 ropt +=
"&filetype=raw";
3966 ::Error(
"TFile::OpenFromCache",
3967 "cannot open the cache file to check cache consistency");
3972 ::Error(
"TFile::OpenFromCache",
3973 "cannot open the remote file to check cache consistency");
3980 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3982 if (memcmp(cacheblock, remotblock, 256)) {
3983 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3984 "differs from the remote file - forcing an update");
3988 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
3989 "remote file are not readable - forcing an update");
4004 const auto cachefilepathtmp = cachefilepath + std::to_string(
gSystem->
GetPid()) +
".tmp";
4007 "you want to read through a cache, but I "
4008 "cannot make a cache copy of %s - CACHEREAD disabled",
4009 cachefilepathbasedir.
Data());
4019 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
name, cachefilepath.
Data());
4022 fileurl.
SetFile(cachefilepath);
4025 tagfile = cachefilepath;
4026 tagfile +=
".ROOT.cachefile";
4084 if (!url || strlen(url) <= 0) {
4085 ::Error(
"TFile::Open",
"no url specified");
4094 if (
gEnv->
GetValue(
"TFile.CrossProtocolRedirects", 1) == 1) {
4097 ssize_t
len = getxattr(fileurl.
GetFile(),
"eos.url.xroot",
nullptr, 0);
4099 std::string xurl(
len, 0);
4100 if (getxattr(fileurl.
GetFile(),
"eos.url.xroot", &xurl[0],
len) ==
len) {
4101 if ((
f =
TFile::Open(xurl.c_str(), options, ftitle, compress, netopt))) {
4102 if (!
f->IsZombie()) {
4121 TString sto = opts(ito + strlen(
"TIMEOUT="), opts.
Length());
4126 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
4128 sto.
Insert(0,
"TIMEOUT=");
4146 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
4148 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
4153 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
4160 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
4166 const char *
option = opts;
4169 TString namelist(expandedUrl);
4186 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4189 if (!strcasecmp(
option,
"CACHEREAD") ||
4229 lfname = urlname.
GetUrl();
4236 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4237 if (
h->LoadPlugin() == -1)
4245 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4246 if (
h->LoadPlugin() == -1)
4254 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4255 h->LoadPlugin() == 0) {
4256 name.ReplaceAll(
"file:",
"");
4264 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
4265 if (
h->LoadPlugin() == -1)
4281 if (
f &&
f->IsZombie()) {
4304 f &&
f->IsWritable() && !
f->IsRaw()) {
4339 const char *ftitle,
Int_t compress,
4347 if (!url || strlen(url) <= 0) {
4348 ::Error(
"TFile::AsyncOpen",
"no url specified");
4360 TString outf =
".TFileAsyncOpen_";
4371 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4386 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4387 (!strcmp(
h->GetClass(),
"TXNetFile") || !strcmp(
h->GetClass(),
"TNetXNGFile"))
4388 &&
h->LoadPlugin() == 0) {
4399 if (!notfound && !
f)
4444 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4446 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4447 !strcmp(
f->GetOption(),
"RECREATE") ||
4458 if (
f)
f->fAsyncHandle = fh;
4470#if defined(R__WINGCC)
4474#elif defined(R__SEEK64)
4475 return ::open64(pathname, flags,
mode);
4477 return ::open(pathname, flags,
mode);
4486 if (fd < 0)
return 0;
4495 return ::read(fd, buf,
len);
4503 return ::write(fd, buf,
len);
4514#if defined (R__SEEK64)
4515 return ::lseek64(fd,
offset, whence);
4517 return ::_lseeki64(fd,
offset, whence);
4519 return ::lseek(fd,
offset, whence);
4546 return ::_commit(fd);
4617 if (!cached.EndsWith(
"/"))
4624 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(cachedir).Data());
4666 cachetagfile +=
".tag.ROOT.cache";
4670 if (lastcleanuptime < cleanupinterval) {
4671 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4677 cachetagfile +=
"?filetype=raw";
4678 TFile *tagfile =
nullptr;
4680 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4681 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4689#if defined(R__WIN32)
4690 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4691#elif defined(R__MACOSX)
4692 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);
4694 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);
4701 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4831 forceRemote =
kTRUE;
4832 else if (opts.
Contains(
"remote=0"))
4841 if (fname[0] ==
'/') {
4843 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4846 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4864 if (localFile && prefix)
4871 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").Match(
name)) {
4875 }
else if (!strncmp(
name,
"file:", 5)) {
4901 if (of && (of->
GetSize() > 0)) {