90#define _XOPEN_SOURCE 600
104# include <sys/types.h>
109#include "RConfigure.h"
145#include "compiledata.h"
157#include <sys/extattr.h>
178#define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0)
181#define getxattr(path, name, value, size) extattr_get_file(path, EXTATTR_NAMESPACE_USER, name, value, size)
191static struct AddPseudoGlobals {
208 Info(
"TFile",
"default ctor");
344 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
346 auto zombify = [
this] {
350 gROOT->GetListOfClosedObjects()->Add(
this);
360 "please use TFile::Open to access remote files:\n\tauto f = std::unique_ptr<TFile>{TFile::Open(\"%s\")};",
441 if (!create && !recreate && !
update && !read) {
448 if (!fname1 || !fname1[0]) {
449 Error(
"TFile",
"file name is not specified");
455 if (!strcmp(fname1,
"/dev/null") &&
475 Error(
"TFile",
"error expanding path %s", fname1);
491 SysError(
"TFile",
"could not delete %s (errno: %d)",
502 Error(
"TFile",
"file %s already exists", fname.
Data());
512 Error(
"TFile",
"no write permission, could not open file %s", fname.
Data());
519 Error(
"TFile",
"file %s does not exist", fname.
Data());
524 Error(
"TFile",
"no read permission, could not open file %s", fname.
Data());
538 SysError(
"TFile",
"file %s can not be opened", fname.
Data());
550 SysError(
"TFile",
"file %s can not be opened for reading", fname.
Data());
591 gROOT->GetListOfClosedObjects()->Remove(
this);
602 Info(
"~TFile",
"dtor called for %s [%zx]",
GetName(),(
size_t)
this);
628 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
647 Error(
"Init",
"member %s not found in archive %s",
685 char *header =
new char[
kBEGIN+200];
690 Error(
"Init",
"%s failed to read the file type data.",
697 if (strncmp(header,
"root", 4)) {
703 char *buffer = header + 4;
706 frombuf(buffer, &headerLength);
709 Int_t send,sfree,sinfo;
730 if (fBEGIN < 0 || fBEGIN >
fEND) {
732 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
744 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
749 char *buffer_keyloc =
nullptr;
754 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
761 header =
new char[nbytes];
766 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
772 buffer_keyloc = header;
775 buffer_keyloc = header+
fBEGIN;
778 frombuf(buffer,&version); versiondir = version%1000;
783 if (version > 1000) {
788 Int_t sdir,sparent,skeys;
796 buffer_keyloc +=
sizeof(
Int_t);
798 frombuf(buffer_keyloc, &keyversion);
800 if (keyversion > 1000) {
807 cname.ReadBuffer(buffer_keyloc);
808 cname.ReadBuffer(buffer_keyloc);
811 if (fNbytesName < 10 || fNbytesName > 10000) {
812 Error(
"Init",
"cannot read directory info of file %s",
GetName());
829 if (
gEnv->
GetValue(
"TFile.v630forwardCompatibility", 0) == 1)
853 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
856 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
862 Warning(
"Init",
"file %s probably not closed, "
863 "trying to recover",
GetName());
871 Warning(
"Init",
"successfully recovered %d keys", nrecov);
873 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
881 gROOT->GetListOfFiles()->Add(
this);
887 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
888 if (lenIndex < 5000) lenIndex = 5000;
895 gROOT->GetListOfFiles()->Remove(
this);
902 const auto separator =
fVersion < 63200 ?
"/" :
".";
903 const auto thisVersion =
gROOT->GetVersionInt();
904 const auto msg =
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file. "
905 "The file was produced with ROOT version %d.%02d%s%02d, "
906 "while the current version is %d.%02d.%02d";
910 thisVersion / 10000, (thisVersion / 100) % (100), thisVersion % 100);
920 while ((key = (
TKey*)next())) {
931 gROOT->GetListOfClosedObjects()->Add(
this);
979 while ((key = iter()) !=
nullptr) {
1037 gROOT->GetListOfFiles()->Remove(
this);
1038 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
1039 gROOT->GetListOfClosedObjects()->Add(
this);
1050 return new TKey(obj,
name, bufsize, mother);
1058 return new TKey(obj, cl,
name, bufsize, mother);
1070 static TFile *currentFile =
nullptr;
1102 Info(
"Delete",
"deleting name = %s", namecycle);
1132 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1133 if (
h->LoadPlugin() == -1)
1174 tobuf(buffer, version);
1190 if (
result >= (
double)std::numeric_limits<Int_t>::max()) {
1191 return std::numeric_limits<Int_t>::max() -1;
1207 Int_t nbytes, objlen, nwh = 64;
1208 char *header =
new char[
fBEGIN];
1214 while (idcur <
fEND-100) {
1229 if (nbytes == 0)
break;
1235 if (!objlen) objlen = nbytes-keylen;
1237 uncomp += keylen + objlen;
1307 if (first <
fBEGIN)
return 0;
1308 if (first >
fEND)
return 0;
1310 Int_t nread = maxbytes;
1311 if (first+maxbytes >
fEND) nread =
fEND-maxbytes;
1313 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1319 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1330 if (nb < 0)
return nread;
1332 const Int_t headerSize = 16;
1333 if (nread < headerSize)
return nread;
1338 if (!olen) olen = nbytes-klen;
1357 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1383 TList *list =
nullptr;
1386 auto key = std::make_unique<TKey>(
this);
1388 auto buf = buffer.data();
1392 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1394 return {
nullptr, 1, hash};
1397 if (lookupSICache) {
1404 Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1405 for(
auto uid : *si_uids)
1407 return {
nullptr, 0, hash};
1410 key->ReadKeyBuffer(buf);
1411 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1414 list = (
TList*)
Get(
"StreamerInfo");
1418 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1420 return {
nullptr, 1, hash};
1423 return {list, 0, hash};
1490 if(!newfree)
return;
1494 if (nbytesl > 2000000000) nbytesl = 2000000000;
1497 char * buffer =
new char[nb];
1498 char * psave = buffer;
1499 tobuf(buffer, nbytes);
1572 bool forComp = options.
Contains(
"forcomp");
1573 bool extended = options.
Contains(
"extended");
1577 Int_t nbytes,date,time,objlen;
1585 constexpr Int_t nwheader = 512;
1587 char header[nwheader];
1588 char classname[512];
1593 unsigned char nDigits = std::log10(
fEND) + 1;
1595 while (idcur <
fEND) {
1597 Int_t nread = nwheader;
1598 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1601 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1609 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1614 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1625 if (versionkey > 1000) {
1634 if ( ((buffer-header) + nwhc) > nwheader )
1635 nwhc = nwheader - (buffer-header);
1636 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1637 classname[(
int)nwhc] =
'\0';
1638 if (idcur ==
fSeekFree) strlcpy(classname,
"FreeSegments",512);
1639 if (idcur ==
fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1640 if (idcur ==
fSeekKeys) strlcpy(classname,
"KeysList",512);
1643 if ( (buffer-header) >= nwheader )
1649 else if ( ((buffer-header) + nwhc) > nwheader )
1650 nwhc = nwheader - (buffer-header);
1652 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keyname[i]);
1653 keyname[(
int)nwhc] =
'\0';
1655 if ( (buffer-header) >= nwheader )
1661 else if ( ((buffer-header) + nwhc) > nwheader )
1662 nwhc = nwheader - (buffer-header);
1664 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &keytitle[i]);
1665 keytitle[(
int)nwhc] =
'\0';
1667 extrainfo.
Form(
" name: %-16s title: %s", keyname, keytitle);
1672 if (objlen != nbytes - keylen) {
1674 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s CX = %5.2f %s", date, time, nDigits + 1, idcur, nbytes, classname,
1675 cx, extrainfo.
Data());
1677 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s %s", date, time, nDigits + 1, idcur, nbytes, classname, extrainfo.
Data());
1681 if (objlen != nbytes - keylen) {
1683 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = %5.2f %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, cx, extrainfo.
Data());
1685 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = 1 %s", nDigits+1, idcur, nbytes, keylen, objlen, classname, extrainfo.
Data());
1691 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s",date,time, nDigits+1, idcur,1,
"END");
1693 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits+1, idcur,1,
"END");
1748 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1795 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1826 for (
Int_t j = 0; j < nbuf; j++) {
1840 char *buf2 =
nullptr;
1843 cur = pos[i]+
len[i];
1846 if (bigRead || (i>=nbuf)) {
1865 for (
Int_t j=0;j<
n;j++) {
1866 memcpy(&buf[k],&buf2[pos[i-
n+j]-curbegin],
len[i-
n+j]);
1876 curbegin = i < nbuf ? pos[i] : 0;
1879 if (buf2)
delete [] buf2;
1929 if (fNbytesFree < 0 || fNbytesFree >
fEND) {
1965 snprintf(pidname,32,
"ProcessID%d",pidf);
1968 printf(
"ReadProcessID, name=%s, file=%s, pid=%zx\n",pidname,
GetName(),(
size_t)pid);
1977 TIter next(pidslist);
1994 p->IncrementCount();
2053 Int_t nbytes,date,time,objlen,nwheader;
2056 char *buffer, *bufread;
2062 Error(
"Recover",
"cannot stat the file %s",
GetName());
2073 Int_t nread = nwheader;
2075 while (idcur <
fEND) {
2077 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
2080 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
2088 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
2103 if (versionkey > 1000) {
2112 char *classname =
nullptr;
2113 if (nwhc <= 0 || nwhc > 100)
break;
2114 classname =
new char[nwhc+1];
2115 int i, nwhci = nwhc;
2116 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
2117 classname[nwhci] =
'\0';
2121 && strcmp(classname,
"TBasket")) {
2122 key =
new TKey(
this);
2124 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
2135 delete [] classname;
2140 if (max_file_size <
fEND) max_file_size =
fEND+1000000000;
2147 if (nrecov)
Write();
2170 if (opt !=
"READ" && opt !=
"UPDATE") {
2171 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2178 if (opt ==
"READ") {
2214 SysError(
"ReOpen",
"file %s can not be opened in read mode",
GetName());
2236 SysError(
"ReOpen",
"file %s can not be opened in update mode",
GetName());
2245 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments",
GetName());
2266 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2290 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2295 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2322 if (level < 0) level = 0;
2323 if (level > 99) level = 99;
2378 if (cache) cache->
SetFile(
this, action);
2408 if (
b.IsReading()) {
2469 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2470 return const_cast<TFile*
>(
this)->
Write(
n, opt, bufsize);
2501 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2528 Error(
"WriteBuffer",
"error writing to cache");
2553 auto createKey = [
this]() {
2557 while ((afree = (
TFree*) next())) {
2558 nbytes += afree->
Sizeof();
2560 if (!nbytes)
return (
TKey*)
nullptr;
2566 return (
TKey*)
nullptr;
2571 TKey *key = createKey();
2588 char *start = buffer;
2592 while ((afree = (
TFree*) next())) {
2597 auto actualBytes = buffer-start;
2598 if ( actualBytes != nbytes ) {
2599 if (actualBytes < nbytes) {
2602 memset(buffer,0,nbytes-actualBytes);
2604 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);
2621 const char *root =
"root";
2622 char *psave =
new char[
fBEGIN];
2623 char *buffer = psave;
2625 memcpy(buffer, root, 4); buffer += 4;
2628 tobuf(buffer, version);
2630 if (version < 1000000) {
2634 tobuf(buffer, nfree);
2644 tobuf(buffer, nfree);
2655 Int_t nbytes = buffer - psave;
2746 path +=
"/PROOF-INF";
2748 const char *afile = 0;
2751 if (strcmp(afile,
".") == 0)
continue;
2752 if (strcmp(afile,
"..") == 0)
continue;
2753 filepath.
Form(
"%s/%s", path.
Data(), afile);
2755 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2762 if (strcmp(afile,
".") == 0)
continue;
2763 if (strcmp(afile,
"..") == 0)
continue;
2764 filepath.
Form(
"%s/%s", path.
Data(), afile);
2766 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2770 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2774 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2776 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2791 }
else if (opt.
Contains(
"recreate")) {
2795 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2803 if (strcmp(afile,
".") == 0)
continue;
2804 if (strcmp(afile,
"..") == 0)
continue;
2805 dirpath.
Form(
"%s/%s",dirname,afile);
2813 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2818 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2831 if (filelist) filelist = (
TList*)filelist->
Clone();
2833 Error(
"MakeProject",
"file %s has no StreamerInfo",
GetName());
2837 TString clean_dirname(dirname);
2838 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2839 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2841 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2843 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2848 if (makepar) subdirname = parname;
2849 if (subdirname ==
"") {
2850 Error(
"MakeProject",
"Directory name must not be empty.");
2855 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.
Data());
2856 FILE *sfp = fopen(spath.
Data(),
"w");
2858 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2861 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2862 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.
Data() );
2863 if (!
genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.
Data() );
2864 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.
Data() );
2865 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2866 fprintf(sfp,
" template <typename T>\n");
2867 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2868 fprintf(sfp,
" delete ptr;\n");
2869 fprintf(sfp,
" }\n");
2870 fprintf(sfp,
" template <typename T, typename Q>\n");
2871 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2872 fprintf(sfp,
" // Do nothing\n");
2873 fprintf(sfp,
" }\n");
2874 fprintf(sfp,
" template <typename T, typename Q>\n");
2875 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2876 fprintf(sfp,
" delete ptr.second;\n");
2877 fprintf(sfp,
" }\n");
2878 fprintf(sfp,
" template <typename T, typename Q>\n");
2879 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2880 fprintf(sfp,
" delete ptr.first;\n");
2881 fprintf(sfp,
" }\n");
2882 fprintf(sfp,
" template <typename T, typename Q>\n");
2883 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2884 fprintf(sfp,
" delete ptr.first;\n");
2885 fprintf(sfp,
" delete ptr.second;\n");
2886 fprintf(sfp,
" }\n");
2887 fprintf(sfp,
"};\n\n");
2894 TIter flnext(filelist);
2901 if (strstr(info->
GetName(),
"@@")) {
2918 for(
auto rule : rules) {
2919 if( rule->IsRenameRule() || rule->IsAliasRule() )
2922 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2925 if (
attr.Contains(
"owner")) {
2926 if (
attr.Contains(
"notowner")) {
2949 TIter nextextra(&extrainfos);
2952 filelist->
Add(info);
2963 TIter subnext(list);
2978 subClasses.
Add(subinfo);
2983 subClasses.
Clear(
"nodelete");
2985 extrainfos.
Clear(
"nodelete");
2988 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.
Data());
2989 FILE *allfp = fopen(path,
"a");
2991 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2993 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.
Data());
2997 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
3000 if (!opt.
Contains(
"+") && !makepar) {
3008 FILE *fpMAKE =
nullptr;
3013 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
3015 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
3018 fpMAKE = fopen(path,
"wb");
3020 fpMAKE = fopen(path,
"w");
3023 Error(
"MakeProject",
"cannot open file %s", path.
Data());
3032 FILE *ifp =
nullptr;
3033 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.
Data());
3035 ifp = fopen(path,
"wb");
3037 ifp = fopen(path,
"w");
3040 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3050 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.
Data(),subdirname.
Data(),
gSystem->
GetIncludePath());
3051 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.
Data());
3054 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3057 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
3063 FILE *fp = fopen(path,
"wb");
3065 FILE *fp = fopen(path,
"w");
3068 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
3077 fprintf(fp,
"<lcgdict>\n");
3080 fprintf(fp,
"#ifdef __CINT__\n");
3092 if (strncmp(info->
GetName(),
"auto_ptr<", strlen(
"auto_ptr<")) == 0) {
3101 for(
auto rule : rules) {
3104 rule->AsString(strrule,
"x");
3107 selections.
Append(strrule);
3110 rule->AsString(strrule);
3111 if (strncmp(strrule.
Data(),
"type=",5)==0) {
3114 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
3121 std::vector<std::string> inside;
3128 switch ( stlkind ) {
3132 what =
"std::pair<";
3142 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3146 tmp.Form(
"template class %s;\n",
what.Data());
3154 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3162 tmp.Form(
"<class name=\"%s\" />\n",key->
GetName());
3166 tmp.Form(
"template class %s;\n",key->
GetName());
3172 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3183 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3187 if (
what[
what.Length()-1] ==
'>') {
3188 tmp.Form(
"template class %s;\n",
what.Data());
3195 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
3205 tmp.Form(
"<class name=\"%s\" />\n",
what.Data());
3209 tmp.Form(
"template class %s;\n",
what.Data());
3218 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3219 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3220 fprintf(ifp,
"%s",instances.
Data());
3221 fprintf(ifp,
"#endif\n");
3222 fprintf(fp,
"%s",selections.
Data());
3223 fprintf(fp,
"</lcgdict>\n");
3225 fprintf(fp,
"#endif\n");
3239 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3246 TString rootbuild = ROOTBUILD;
3255 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.
Data());
3257 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.
Data());
3258 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.
Data());
3261 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3263 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3272 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3281 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3284 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3293 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3306 chmod(cmod.
Data(), 00700);
3308 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and"
3309 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3318 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3320 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.
Data());
3323 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3326 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3331 if (!makepar && !opt.
Contains(
"nocompilation")) {
3340 chmod(
"makep.cmd",00700);
3345 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3350 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3368 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3369 Error(
"MakeProjectParMake",
"path for output file undefined!");
3374 if (!pack || (pack && strlen(pack) <= 0)) {
3375 Error(
"MakeProjectParMake",
"package name undefined!");
3380 FILE *fmk = fopen(filemake,
"wb");
3382 FILE *fmk = fopen(filemake,
"w");
3390 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3391 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3392 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3393 fprintf(fmk,
"#\n");
3394 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3395 fprintf(fmk,
"#\n");
3396 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3398 fprintf(fmk,
"include Makefile.arch\n");
3400 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3402 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3403 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3404 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3406 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3407 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3408 fprintf(fmk,
"else\n");
3409 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3410 fprintf(fmk,
"endif\n");
3412 fprintf(fmk,
"OBJS = $(PACKO)\n");
3414 fprintf(fmk,
"PROGRAMS =\n");
3416 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3418 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3420 fprintf(fmk,
"all: $(PACKLIB)\n");
3422 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3423 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3424 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3425 fprintf(fmk,
"else\n");
3426 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3427 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3428 fprintf(fmk,
"else\n");
3429 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3430 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3431 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3432 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3433 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3434 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3435 fprintf(fmk,
"else\n");
3436 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3437 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3438 fprintf(fmk,
"endif\n");
3439 fprintf(fmk,
"endif\n");
3440 fprintf(fmk,
"else\n");
3441 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3442 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3443 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3444 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3445 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3446 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3447 fprintf(fmk,
"else\n");
3448 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3449 fprintf(fmk,
"endif\n");
3450 fprintf(fmk,
"endif\n");
3451 fprintf(fmk,
"endif\n");
3452 fprintf(fmk,
"endif\n");
3453 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3455 fprintf(fmk,
"clean:\n");
3456 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3458 fprintf(fmk,
"distclean: clean\n");
3459 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3460 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3461 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3463 fprintf(fmk,
"# Dependencies\n");
3465 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3467 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3468 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3469 fprintf(fmk,
"\t\t@rootcint -f $@ $^\n");
3471 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3472 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3490 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3491 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3499 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3500 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3505 if (!pack || (pack && strlen(pack) <= 0)) {
3506 Error(
"MakeProjectParProofInf",
"package name undefined!");
3513 path.
Form(
"%s/BUILD.sh", proofinf);
3515 FILE *
f = fopen(path.
Data(),
"wb");
3517 FILE *
f = fopen(path.
Data(),
"w");
3520 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3525 fprintf(
f,
"#! /bin/sh\n");
3526 fprintf(
f,
"# Build libEvent library.\n");
3529 fprintf(
f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3530 fprintf(
f,
"# adapt the script to the calling environment\n");
3532 fprintf(
f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3533 fprintf(
f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3534 fprintf(
f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3535 fprintf(
f,
"# echo \"event-BUILD: PROOF client\"\n");
3536 fprintf(
f,
"# else\n");
3537 fprintf(
f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3538 fprintf(
f,
"# fi\n");
3540 fprintf(
f,
"if [ \"\" = \"clean\" ]; then\n");
3541 fprintf(
f,
" make distclean\n");
3542 fprintf(
f,
" exit 0\n");
3545 fprintf(
f,
"make\n");
3546 fprintf(
f,
"rc=$?\n");
3547 fprintf(
f,
"echo \"rc=$?\"\n");
3548 fprintf(
f,
"if [ $? != \"0\" ] ; then\n");
3549 fprintf(
f,
" exit 1\n");
3551 fprintf(
f,
"exit 0\n");
3557 path.
Form(
"%s/SETUP.C", proofinf);
3559 f = fopen(path.
Data(),
"wb");
3561 f = fopen(path.
Data(),
"w");
3564 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3569 fprintf(
f,
"Int_t SETUP()\n");
3573 fprintf(
f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3574 fprintf(
f,
"// adapt the macro to the calling environment\n");
3576 fprintf(
f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3577 fprintf(
f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3578 fprintf(
f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3579 fprintf(
f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3580 fprintf(
f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3581 fprintf(
f,
"// } else {\n");
3582 fprintf(
f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3583 fprintf(
f,
"// }\n");
3585 fprintf(
f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3586 fprintf(
f,
" return -1;\n");
3587 fprintf(
f,
" return 0;\n");
3609 TList *list = listRetcode.fList;
3610 auto retcode = listRetcode.fReturnCode;
3623 if (version > 1000000) version -= 1000000;
3624 if (version < 53419 || (59900 < version && version < 59907)) {
3639 if (!base)
continue;
3650 std::vector<Int_t> si_uids;
3665 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3673 rulelnk = rulelnk->
Next();
3687 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3692 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3694 if ( (!isstl &&
mode ==0) || (isstl &&
mode ==1) ) {
3701 if (uid >= 0 && uid < fClassIndex->
GetSize()) {
3702 si_uids.push_back(uid);
3706 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3770 for (
Int_t i=0;i<npids;i++) {
3782 Info(
"WriteProcessID",
"name=%s, file=%s", name,
GetName());
3816 listOfRules.
SetName(
"listOfRules");
3817 std::set<TClass*> classSet;
3823 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3829 if ( classSet.find( clinfo ) == classSet.end() ) {
3830 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3837 listOfRules.
Add(obj);
3839 classSet.insert(clinfo);
3850 list.
Add(&listOfRules);
3882 "you want to read through a cache, but you have no valid cache "
3883 "directory set - reading remotely");
3884 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3892 "you want to read through a cache, but you are reading "
3893 "local files - CACHEREAD disabled");
3900 cachefilepath += fileurl.
GetFile();
3904 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3905 "cannot create the directory %s - CACHEREAD disabled",
3906 cachefilepathbasedir.
Data());
3911 cachefilepath +=
"__";
3915 if (strstr(
name,
"zip=")) {
3920 Int_t optioncount = 0;
3929 if (optioncount!=0) {
3934 newoptions +=
value;
3944 cachefilepath +=
"__";
3945 cachefilepath += zipname;
3959 char cacheblock[256];
3960 char remotblock[256];
3963 cfurl = cachefilepath;
3964 cfurl +=
"?filetype=raw";
3967 ropt +=
"&filetype=raw";
3980 ::Error(
"TFile::OpenFromCache",
3981 "cannot open the cache file to check cache consistency");
3986 ::Error(
"TFile::OpenFromCache",
3987 "cannot open the remote file to check cache consistency");
3994 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3996 if (memcmp(cacheblock, remotblock, 256)) {
3997 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3998 "differs from the remote file - forcing an update");
4002 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
4003 "remote file are not readable - forcing an update");
4018 const auto cachefilepathtmp = cachefilepath + std::to_string(
gSystem->
GetPid()) +
".tmp";
4021 "you want to read through a cache, but I "
4022 "cannot make a cache copy of %s - CACHEREAD disabled",
4023 cachefilepathbasedir.
Data());
4033 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
name, cachefilepath.
Data());
4036 fileurl.
SetFile(cachefilepath);
4039 tagfile = cachefilepath;
4040 tagfile +=
".ROOT.cachefile";
4098 if (!url || strlen(url) <= 0) {
4099 ::Error(
"TFile::Open",
"no url specified");
4108 if (
gEnv->
GetValue(
"TFile.CrossProtocolRedirects", 1) == 1) {
4111 ssize_t
len = getxattr(fileurl.
GetFile(),
"eos.url.xroot",
nullptr, 0);
4113 std::string xurl(
len, 0);
4114 if (getxattr(fileurl.
GetFile(),
"eos.url.xroot", &xurl[0],
len) ==
len) {
4115 if ((
f =
TFile::Open(xurl.c_str(), options, ftitle, compress, netopt))) {
4116 if (!
f->IsZombie()) {
4135 TString sto = opts(ito + strlen(
"TIMEOUT="), opts.
Length());
4140 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
4142 sto.
Insert(0,
"TIMEOUT=");
4160 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
4162 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
4167 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
4174 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
4180 const char *
option = opts;
4183 TString namelist(expandedUrl);
4200 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4203 if (!strcasecmp(
option,
"CACHEREAD") ||
4243 lfname = urlname.
GetUrl();
4250 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4251 if (
h->LoadPlugin() == -1)
4259 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4260 if (
h->LoadPlugin() == -1)
4268 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4269 h->LoadPlugin() == 0) {
4270 name.ReplaceAll(
"file:",
"");
4278 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
4279 if (
h->LoadPlugin() == -1)
4295 if (
f &&
f->IsZombie()) {
4318 f &&
f->IsWritable() && !
f->IsRaw()) {
4353 const char *ftitle,
Int_t compress,
4361 if (!url || strlen(url) <= 0) {
4362 ::Error(
"TFile::AsyncOpen",
"no url specified");
4374 TString outf =
".TFileAsyncOpen_";
4385 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4400 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4401 !strcmp(
h->GetClass(),
"TNetXNGFile")
4402 &&
h->LoadPlugin() == 0) {
4413 if (!notfound && !
f)
4458 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4460 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4461 !strcmp(
f->GetOption(),
"RECREATE") ||
4472 if (
f)
f->fAsyncHandle = fh;
4484#if defined(R__WINGCC)
4488#elif defined(R__SEEK64)
4489 return ::open64(pathname, flags,
mode);
4491 return ::open(pathname, flags,
mode);
4500 if (fd < 0)
return 0;
4509 return ::read(fd, buf,
len);
4517 return ::write(fd, buf,
len);
4528#if defined (R__SEEK64)
4529 return ::lseek64(fd,
offset, whence);
4531 return ::_lseeki64(fd,
offset, whence);
4533 return ::lseek(fd,
offset, whence);
4560 return ::_commit(fd);
4631 if (!cached.EndsWith(
"/"))
4638 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(cachedir).Data());
4680 cachetagfile +=
".tag.ROOT.cache";
4684 if (lastcleanuptime < cleanupinterval) {
4685 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4691 cachetagfile +=
"?filetype=raw";
4692 TFile *tagfile =
nullptr;
4694 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4695 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4703#if defined(R__WIN32)
4704 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4705#elif defined(R__MACOSX)
4706 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);
4708 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);
4715 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4845 forceRemote =
kTRUE;
4846 else if (opts.
Contains(
"remote=0"))
4855 if (fname[0] ==
'/') {
4857 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4860 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4877 if (localFile && prefix)
4884 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").Match(
name)) {
4888 }
else if (!strncmp(
name,
"file:", 5)) {