79#define _XOPEN_SOURCE 600
90# include <sys/types.h>
96#include "RConfigure.h"
128#include "compiledata.h"
164static struct AddPseudoGlobals {
181 Info(
"TFile",
"default ctor");
300 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
370 if (!create && !recreate && !
update && !read) {
377 if (!fname1 || !fname1[0]) {
378 Error(
"TFile",
"file name is not specified");
383 if (!strcmp(fname1,
"/dev/null") &&
401 Error(
"TFile",
"error expanding path %s", fname1);
408 SysError(
"TFile",
"could not delete %s (errno: %d)",
418 Error(
"TFile",
"file %s already exists", fname);
427 Error(
"TFile",
"no write permission, could not open file %s", fname);
433 Error(
"TFile",
"file %s does not exist", fname);
437 Error(
"TFile",
"no read permission, could not open file %s", fname);
450 SysError(
"TFile",
"file %s can not be opened", fname);
461 SysError(
"TFile",
"file %s can not be opened for reading", fname);
476 gROOT->GetListOfClosedObjects()->Add(
this);
512 gROOT->GetListOfClosedObjects()->Remove(
this);
549 Error(
"Init",
"archive %s can only be opened in read mode",
GetName());
568 Error(
"Init",
"member %s not found in archive %s",
606 char *header =
new char[
kBEGIN+200];
611 Error(
"Init",
"%s failed to read the file type data.",
618 if (strncmp(header,
"root", 4)) {
624 char *buffer = header + 4;
627 frombuf(buffer, &headerLength);
630 Int_t send,sfree,sinfo;
651 if (fBEGIN < 0 || fBEGIN >
fEND) {
653 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
664 Warning(
"Init",
"file %s probably not closed, cannot read free segments",
GetName());
669 char *buffer_keyloc =
nullptr;
674 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
680 header =
new char[nbytes];
685 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
691 buffer_keyloc = header;
694 buffer_keyloc = header+
fBEGIN;
697 frombuf(buffer,&version); versiondir = version%1000;
702 if (version > 1000) {
707 Int_t sdir,sparent,skeys;
715 buffer_keyloc +=
sizeof(
Int_t);
717 frombuf(buffer_keyloc, &keyversion);
719 if (keyversion > 1000) {
730 if (fNbytesName < 10 || fNbytesName > 10000) {
731 Error(
"Init",
"cannot read directory info of file %s",
GetName());
737 if ((size =
GetSize()) == -1) {
767 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, "
770 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
776 Warning(
"Init",
"file %s probably not closed, "
777 "trying to recover",
GetName());
785 Warning(
"Init",
"successfully recovered %d keys", nrecov);
787 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
795 gROOT->GetListOfFiles()->Add(
this);
801 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
802 if (lenIndex < 5000) lenIndex = 5000;
809 gROOT->GetListOfFiles()->Remove(
this);
815 Warning(
"Init",
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file."
816 " The file was produced with version %d.%02d/%02d of ROOT.",
827 while ((key = (
TKey*)next())) {
837 gROOT->GetListOfClosedObjects()->Add(
this);
885 while ((key = iter()) !=
nullptr) {
943 gROOT->GetListOfFiles()->Remove(
this);
944 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
945 gROOT->GetListOfClosedObjects()->Add(
this);
956 return new TKey(obj,
name, bufsize, mother);
964 return new TKey(obj, cl,
name, bufsize, mother);
976 static TFile *currentFile =
nullptr;
1008 Info(
"Delete",
"deleting name = %s", namecycle);
1029 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1030 if (
h->LoadPlugin() == -1)
1032 h->ExecPlugin(3,
this, keys, option);
1070 Version_t version = TFile::Class_Version();
1071 tobuf(buffer, version);
1087 if (result >= (
double)std::numeric_limits<Int_t>::max()) {
1088 return std::numeric_limits<Int_t>::max() -1;
1090 return (
Int_t)result;
1104 Int_t nbytes, objlen, nwh = 64;
1105 char *header =
new char[
fBEGIN];
1111 while (idcur <
fEND-100) {
1126 if (nbytes == 0)
break;
1132 if (!objlen) objlen = nbytes-keylen;
1134 uncomp += keylen + objlen;
1205 Int_t nread = maxbytes;
1208 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1214 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1225 if (nb < 0)
return nread;
1227 const Int_t headerSize = 16;
1228 if (nread < headerSize)
return nread;
1233 if (!olen) olen = nbytes-klen;
1251 if (
const_cast<TFile*
>(
this)->
SysStat(
fD, &
id, &size, &flags, &modtime)) {
1252 Error(
"GetSize",
"cannot stat the file %s",
GetName());
1278 TList *list =
nullptr;
1281 auto key = std::make_unique<TKey>(
this);
1283 auto buf = buffer.data();
1287 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1289 return {
nullptr, 1, hash};
1293 if (lookupSICache) {
1296 if (
gDebug > 0)
Info(
"GetStreamerInfo",
"The streamer info record for file %s has already been treated, skipping it.",
GetName());
1297 return {
nullptr, 0, hash};
1301 (
void) lookupSICache;
1303 key->ReadKeyBuffer(buf);
1304 list =
dynamic_cast<TList*
>(key->ReadObjWithBuffer(buffer.data()));
1307 list = (
TList*)
Get(
"StreamerInfo");
1311 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1313 return {
nullptr, 1, hash};
1316 return {list, 0, hash};
1383 if(!newfree)
return;
1387 if (nbytesl > 2000000000) nbytesl = 2000000000;
1390 char * buffer =
new char[nb];
1391 char * psave = buffer;
1392 tobuf(buffer, nbytes);
1451 bool forComp = options.
Contains(
"forcomp");
1455 Int_t nbytes,date,time,objlen,nwheader;
1464 Int_t nread = nwheader;
1467 char classname[512];
1471 while (idcur <
fEND) {
1473 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1476 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1484 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1489 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1500 if (versionkey > 1000) {
1509 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1510 classname[(int)nwhc] =
'\0';
1511 if (idcur ==
fSeekFree) strlcpy(classname,
"FreeSegments",512);
1512 if (idcur ==
fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1513 if (idcur ==
fSeekKeys) strlcpy(classname,
"KeysList",512);
1516 if (objlen != nbytes - keylen) {
1518 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s CX = %5.2f", date, time, nDigits + 1, idcur, nbytes, classname,
1521 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s", date, time, nDigits + 1, idcur, nbytes, classname);
1525 if (objlen != nbytes - keylen) {
1527 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = %5.2f", nDigits+1, idcur, nbytes, keylen, objlen, classname, cx);
1529 Printf(
"At:%-*lld N=%-8d K=%-3d O=%-8d %-14s CX = 1", nDigits+1, idcur, nbytes, keylen, objlen, classname);
1535 Printf(
"%d/%06d At:%-*lld N=%-8d %-14s",date,time, nDigits+1, idcur,1,
"END");
1537 Printf(
"At:%-*lld N=%-8d K= O= %-14s", nDigits+1, idcur,1,
"END");
1592 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1639 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1670 for (
Int_t j = 0; j < nbuf; j++) {
1684 char *buf2 =
nullptr;
1687 cur = pos[i]+len[i];
1690 if (bigRead || (i>=nbuf)) {
1704 Long64_t nahead = pos[i-1]+len[i-1]-curbegin;
1709 for (
Int_t j=0;j<
n;j++) {
1710 memcpy(&buf[k],&buf2[pos[i-
n+j]-curbegin],len[i-
n+j]);
1720 curbegin = i < nbuf ? pos[i] : 0;
1723 if (buf2)
delete [] buf2;
1773 if (fNbytesFree < 0 || fNbytesFree >
fEND) {
1809 snprintf(pidname,32,
"ProcessID%d",pidf);
1812 printf(
"ReadProcessID, name=%s, file=%s, pid=%lx\n",pidname,
GetName(),(
Long_t)pid);
1821 TIter next(pidslist);
1894 Int_t nbytes,date,time,objlen,nwheader;
1897 char *buffer, *bufread;
1902 if ((size =
GetSize()) == -1) {
1903 Error(
"Recover",
"cannot stat the file %s",
GetName());
1914 Int_t nread = nwheader;
1916 while (idcur <
fEND) {
1918 if (idcur+nread >=
fEND) nread =
fEND-idcur-1;
1921 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
1929 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1944 if (versionkey > 1000) {
1953 char *classname =
nullptr;
1954 if (nwhc <= 0 || nwhc > 100)
break;
1955 classname =
new char[nwhc+1];
1956 int i, nwhci = nwhc;
1957 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1958 classname[nwhci] =
'\0';
1962 && strcmp(classname,
"TBasket")) {
1963 key =
new TKey(
this);
1965 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
1976 delete [] classname;
1981 if (max_file_size <
fEND) max_file_size =
fEND+1000000000;
1988 if (nrecov)
Write();
2011 if (opt !=
"READ" && opt !=
"UPDATE") {
2012 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
2019 if (opt ==
"READ") {
2055 SysError(
"ReOpen",
"file %s can not be opened in read mode",
GetName());
2077 SysError(
"ReOpen",
"file %s can not be opened in update mode",
GetName());
2086 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments",
GetName());
2107 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2131 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2135 if ((retpos =
SysSeek(
fD, offset, whence)) < 0)
2136 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2163 if (level < 0) level = 0;
2164 if (level > 99) level = 99;
2219 if (cache) cache->
SetFile(
this, action);
2249 if (
b.IsReading()) {
2252 b.WriteVersion(TFile::IsA());
2310 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2311 return const_cast<TFile*
>(
this)->
Write(
n, opt, bufsize);
2342 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2369 Error(
"WriteBuffer",
"error writing to cache");
2394 auto createKey = [
this]() {
2398 while ((afree = (
TFree*) next())) {
2399 nbytes += afree->
Sizeof();
2401 if (!nbytes)
return (
TKey*)
nullptr;
2407 return (
TKey*)
nullptr;
2412 TKey *key = createKey();
2429 char *start = buffer;
2433 while ((afree = (
TFree*) next())) {
2438 auto actualBytes = buffer-start;
2439 if ( actualBytes != nbytes ) {
2440 if (actualBytes < nbytes) {
2443 memset(buffer,0,nbytes-actualBytes);
2445 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);
2462 const char *root =
"root";
2463 char *psave =
new char[
fBEGIN];
2464 char *buffer = psave;
2466 memcpy(buffer, root, 4); buffer += 4;
2469 tobuf(buffer, version);
2471 if (version < 1000000) {
2475 tobuf(buffer, nfree);
2485 tobuf(buffer, nfree);
2496 Int_t nbytes = buffer - psave;
2587 path +=
"/PROOF-INF";
2589 const char *afile = 0;
2592 if (strcmp(afile,
".") == 0)
continue;
2593 if (strcmp(afile,
"..") == 0)
continue;
2594 filepath.
Form(
"%s/%s", path.
Data(), afile);
2596 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2603 if (strcmp(afile,
".") == 0)
continue;
2604 if (strcmp(afile,
"..") == 0)
continue;
2605 filepath.
Form(
"%s/%s", path.
Data(), afile);
2607 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2611 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2615 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2617 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2632 }
else if (opt.
Contains(
"recreate")) {
2636 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2644 if (strcmp(afile,
".") == 0)
continue;
2645 if (strcmp(afile,
"..") == 0)
continue;
2646 dirpath.
Form(
"%s/%s",dirname,afile);
2654 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2659 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2672 if (filelist) filelist = (
TList*)filelist->
Clone();
2674 Error(
"MakeProject",
"file %s has no StreamerInfo",
GetName());
2678 TString clean_dirname(dirname);
2679 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2680 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2682 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2684 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2689 if (makepar) subdirname = parname;
2690 if (subdirname ==
"") {
2691 Error(
"MakeProject",
"Directory name must not be empty.");
2696 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.
Data());
2697 FILE *sfp = fopen(spath.
Data(),
"w");
2699 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2702 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2703 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.
Data() );
2704 if (!
genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.
Data() );
2705 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.
Data() );
2706 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2707 fprintf(sfp,
" template <typename T>\n");
2708 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2709 fprintf(sfp,
" delete ptr;\n");
2710 fprintf(sfp,
" }\n");
2711 fprintf(sfp,
" template <typename T, typename Q>\n");
2712 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2713 fprintf(sfp,
" // Do nothing\n");
2714 fprintf(sfp,
" }\n");
2715 fprintf(sfp,
" template <typename T, typename Q>\n");
2716 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2717 fprintf(sfp,
" delete ptr.second;\n");
2718 fprintf(sfp,
" }\n");
2719 fprintf(sfp,
" template <typename T, typename Q>\n");
2720 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2721 fprintf(sfp,
" delete ptr.first;\n");
2722 fprintf(sfp,
" }\n");
2723 fprintf(sfp,
" template <typename T, typename Q>\n");
2724 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2725 fprintf(sfp,
" delete ptr.first;\n");
2726 fprintf(sfp,
" delete ptr.second;\n");
2727 fprintf(sfp,
" }\n");
2728 fprintf(sfp,
"};\n\n");
2735 TIter flnext(filelist);
2742 if (strstr(info->
GetName(),
"@@")) {
2759 for(
auto rule : rules) {
2760 if( rule->IsRenameRule() || rule->IsAliasRule() )
2763 if ( rule->HasTarget( el->
GetName()) && rule->GetAttributes()[0] != 0 ) {
2764 TString attr( rule->GetAttributes() );
2790 TIter nextextra(&extrainfos);
2793 filelist->
Add(info);
2804 TIter subnext(list);
2816 if ( (sublen > len) && subinfo->
GetName()[len+1]==
':'
2819 subClasses.
Add(subinfo);
2824 subClasses.
Clear(
"nodelete");
2826 extrainfos.
Clear(
"nodelete");
2829 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.
Data());
2830 FILE *allfp = fopen(path,
"a");
2832 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2834 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.
Data());
2838 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
2841 if (!opt.
Contains(
"+") && !makepar) {
2849 FILE *fpMAKE =
nullptr;
2854 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
2856 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
2859 fpMAKE = fopen(path,
"wb");
2861 fpMAKE = fopen(path,
"w");
2864 Error(
"MakeProject",
"cannot open file %s", path.
Data());
2873 FILE *ifp =
nullptr;
2874 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.
Data());
2876 ifp = fopen(path,
"wb");
2878 ifp = fopen(path,
"w");
2881 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
2891 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.
Data(),subdirname.
Data(),
gSystem->
GetIncludePath());
2892 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.
Data());
2895 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
2898 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.
Data());
2904 FILE *fp = fopen(path,
"wb");
2906 FILE *fp = fopen(path,
"w");
2909 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
2918 fprintf(fp,
"<lcgdict>\n");
2921 fprintf(fp,
"#ifdef __CINT__\n");
2933 if (strncmp(info->
GetName(),
"auto_ptr<", strlen(
"auto_ptr<")) == 0) {
2942 for(
auto rule : rules) {
2945 rule->AsString(strrule,
"x");
2948 selections.
Append(strrule);
2951 rule->AsString(strrule);
2952 if (strncmp(strrule.
Data(),
"type=",5)==0) {
2955 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
2962 std::vector<std::string> inside;
2969 switch ( stlkind ) {
2973 what =
"std::pair<";
2977 if (what[what.
Length()-1]==
'>') {
2983 tmp.
Form(
"<class name=\"%s\" />\n",what.
Data());
2987 tmp.
Form(
"template class %s;\n",what.
Data());
2995 fprintf(fp,
"#pragma link C++ class %s+;\n",what.
Data());
3001 if (strncmp(key->
GetName(),
"pair<",strlen(
"pair<"))==0) {
3003 tmp.
Form(
"<class name=\"%s\" />\n",key->
GetName());
3013 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
3024 tmp.
Form(
"<class name=\"%s\" />\n",what.
Data());
3028 if (what[what.
Length()-1] ==
'>') {
3029 tmp.
Form(
"template class %s;\n",what.
Data());
3036 fprintf(fp,
"#pragma link C++ class %s+;\n",what.
Data());
3046 tmp.
Form(
"<class name=\"%s\" />\n",what.
Data());
3050 tmp.
Form(
"template class %s;\n",what.
Data());
3059 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
3060 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
3061 fprintf(ifp,
"%s",instances.
Data());
3062 fprintf(ifp,
"#endif\n");
3063 fprintf(fp,
"%s",selections.
Data());
3064 fprintf(fp,
"</lcgdict>\n");
3066 fprintf(fp,
"#endif\n");
3080 cmd.
ReplaceAll(
"$ObjectFiles",
object.Data());
3087 TString rootbuild = ROOTBUILD;
3096 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.
Data());
3098 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.
Data());
3099 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.
Data());
3102 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3104 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3113 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3122 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3125 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3134 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3147 chmod(cmod.
Data(), 00700);
3149 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and"
3150 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3159 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3161 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.
Data());
3164 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3167 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3172 if (!makepar && !opt.
Contains(
"nocompilation")) {
3181 chmod(
"makep.cmd",00700);
3186 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3191 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3209 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3210 Error(
"MakeProjectParMake",
"path for output file undefined!");
3215 if (!pack || (pack && strlen(pack) <= 0)) {
3216 Error(
"MakeProjectParMake",
"package name undefined!");
3221 FILE *fmk = fopen(filemake,
"wb");
3223 FILE *fmk = fopen(filemake,
"w");
3231 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3232 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3233 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3234 fprintf(fmk,
"#\n");
3235 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3236 fprintf(fmk,
"#\n");
3237 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3239 fprintf(fmk,
"include Makefile.arch\n");
3241 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3243 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3244 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3245 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3247 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3248 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3249 fprintf(fmk,
"else\n");
3250 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3251 fprintf(fmk,
"endif\n");
3253 fprintf(fmk,
"OBJS = $(PACKO)\n");
3255 fprintf(fmk,
"PROGRAMS =\n");
3257 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3259 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3261 fprintf(fmk,
"all: $(PACKLIB)\n");
3263 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3264 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3265 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3266 fprintf(fmk,
"else\n");
3267 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3268 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3269 fprintf(fmk,
"else\n");
3270 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3271 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3272 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3273 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3274 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3275 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3276 fprintf(fmk,
"else\n");
3277 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3278 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3279 fprintf(fmk,
"endif\n");
3280 fprintf(fmk,
"endif\n");
3281 fprintf(fmk,
"else\n");
3282 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3283 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3284 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3285 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3286 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3287 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3288 fprintf(fmk,
"else\n");
3289 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3290 fprintf(fmk,
"endif\n");
3291 fprintf(fmk,
"endif\n");
3292 fprintf(fmk,
"endif\n");
3293 fprintf(fmk,
"endif\n");
3294 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3296 fprintf(fmk,
"clean:\n");
3297 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3299 fprintf(fmk,
"distclean: clean\n");
3300 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3301 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3302 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3304 fprintf(fmk,
"# Dependencies\n");
3306 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3308 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3309 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3310 fprintf(fmk,
"\t\t@rootcint -f $@ $^\n");
3312 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3313 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3331 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3332 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3340 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3341 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3346 if (!pack || (pack && strlen(pack) <= 0)) {
3347 Error(
"MakeProjectParProofInf",
"package name undefined!");
3354 path.
Form(
"%s/BUILD.sh", proofinf);
3356 FILE *
f = fopen(path.
Data(),
"wb");
3358 FILE *
f = fopen(path.
Data(),
"w");
3361 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3366 fprintf(
f,
"#! /bin/sh\n");
3367 fprintf(
f,
"# Build libEvent library.\n");
3370 fprintf(
f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3371 fprintf(
f,
"# adapt the script to the calling environment\n");
3373 fprintf(
f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3374 fprintf(
f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3375 fprintf(
f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3376 fprintf(
f,
"# echo \"event-BUILD: PROOF client\"\n");
3377 fprintf(
f,
"# else\n");
3378 fprintf(
f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3379 fprintf(
f,
"# fi\n");
3381 fprintf(
f,
"if [ \"\" = \"clean\" ]; then\n");
3382 fprintf(
f,
" make distclean\n");
3383 fprintf(
f,
" exit 0\n");
3386 fprintf(
f,
"make\n");
3387 fprintf(
f,
"rc=$?\n");
3388 fprintf(
f,
"echo \"rc=$?\"\n");
3389 fprintf(
f,
"if [ $? != \"0\" ] ; then\n");
3390 fprintf(
f,
" exit 1\n");
3392 fprintf(
f,
"exit 0\n");
3398 path.
Form(
"%s/SETUP.C", proofinf);
3400 f = fopen(path.
Data(),
"wb");
3402 f = fopen(path.
Data(),
"w");
3405 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3410 fprintf(
f,
"Int_t SETUP()\n");
3414 fprintf(
f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3415 fprintf(
f,
"// adapt the macro to the calling environment\n");
3417 fprintf(
f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3418 fprintf(
f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3419 fprintf(
f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3420 fprintf(
f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3421 fprintf(
f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3422 fprintf(
f,
"// } else {\n");
3423 fprintf(
f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3424 fprintf(
f,
"// }\n");
3426 fprintf(
f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3427 fprintf(
f,
" return -1;\n");
3428 fprintf(
f,
" return 0;\n");
3450 TList *list = listRetcode.fList;
3451 auto retcode = listRetcode.fReturnCode;
3464 if (version > 1000000) version -= 1000000;
3465 if (version < 53419 || (59900 < version && version < 59907)) {
3480 if (!base)
continue;
3492 for (
int mode=0;mode<2; ++mode) {
3505 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3513 rulelnk = rulelnk->
Next();
3517 Warning(
"ReadStreamerInfo",
"%s has a %s in the list of TStreamerInfo.",
GetName(), info->IsA()->
GetName());
3527 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3532 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3534 if ( (!isstl && mode ==0) || (isstl && mode ==1) ) {
3543 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3609 for (
Int_t i=0;i<npids;i++) {
3621 Info(
"WriteProcessID",
"name=%s, file=%s", name,
GetName());
3655 listOfRules.
SetName(
"listOfRules");
3656 std::set<TClass*> classSet;
3663 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->
GetName(),uid);
3669 if ( classSet.find( clinfo ) == classSet.end() ) {
3670 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->
GetName());
3677 listOfRules.
Add(obj);
3679 classSet.insert(clinfo);
3690 list.
Add(&listOfRules);
3722 "you want to read through a cache, but you have no valid cache "
3723 "directory set - reading remotely");
3724 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3733 "you want to read through a cache, but you are reading "
3734 "local files - CACHEREAD disabled");
3741 cachefilepath += fileurl.
GetFile();
3745 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3746 "cannot create the directory %s - CACHEREAD disabled",
3747 cachefilepathbasedir.
Data());
3752 cachefilepath +=
"__";
3756 if (strstr(
name,
"zip=")) {
3761 Int_t optioncount = 0;
3770 if (optioncount!=0) {
3775 newoptions += value;
3785 cachefilepath +=
"__";
3786 cachefilepath += zipname;
3800 char cacheblock[256];
3801 char remotblock[256];
3804 cfurl = cachefilepath;
3805 cfurl +=
"?filetype=raw";
3808 ropt +=
"&filetype=raw";
3821 ::Error(
"TFile::OpenFromCache",
3822 "cannot open the cache file to check cache consistency");
3827 ::Error(
"TFile::OpenFromCache",
3828 "cannot open the remote file to check cache consistency");
3835 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3837 if (memcmp(cacheblock, remotblock, 256)) {
3838 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file "
3839 "differs from the remote file - forcing an update");
3843 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or "
3844 "remote file are not readable - forcing an update");
3859 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I "
3860 "cannot make a cache copy of %s - CACHEREAD disabled",
3861 cachefilepathbasedir.
Data());
3867 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
3871 fileurl.
SetFile(cachefilepath);
3875 tagfile = cachefilepath;
3876 tagfile +=
".ROOT.cachefile";
3932 if (!url || strlen(url) <= 0) {
3933 ::Error(
"TFile::Open",
"no url specified");
3946 TString sto = opts(ito + strlen(
"TIMEOUT="), opts.
Length());
3951 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
3953 sto.
Insert(0,
"TIMEOUT=");
3971 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
3973 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous"
3978 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
3985 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
3991 const char *option = opts;
3994 TString namelist(expandedUrl);
4011 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4014 if (!strcasecmp(option,
"CACHEREAD") ||
4041 f = (
TFile*)
gROOT->ProcessLineFast(
TString::Format(
"new TParallelMergingFile(\"%s\",\"%s\",\"%s\",%d)",
n.Data(),option,ftitle,compress));
4054 lfname = urlname.
GetUrl();
4056 f =
new TFile(lfname.
Data(), option, ftitle, compress);
4061 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4062 if (
h->LoadPlugin() == -1)
4064 f = (
TFile*)
h->ExecPlugin(5,
name.Data(), option, ftitle, compress, netopt);
4070 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name))) {
4071 if (
h->LoadPlugin() == -1)
4073 f = (
TFile*)
h->ExecPlugin(2,
name.Data(), option);
4079 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4080 h->LoadPlugin() == 0) {
4081 name.ReplaceAll(
"file:",
"");
4082 f = (
TFile*)
h->ExecPlugin(4,
name.Data(), option, ftitle, compress);
4084 f =
new TFile(
name.Data(), option, ftitle, compress);
4089 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name.Data()))) {
4090 if (
h->LoadPlugin() == -1)
4094 f = (
TFile*)
h->ExecPlugin(5,
name.Data(), option, ftitle, compress, netopt);
4096 f = (
TFile*)
h->ExecPlugin(4,
name.Data(), option, ftitle, compress);
4105 if (
f &&
f->IsZombie()) {
4128 f &&
f->IsWritable() && !
f->IsRaw()) {
4163 const char *ftitle,
Int_t compress,
4171 if (!url || strlen(url) <= 0) {
4172 ::Error(
"TFile::AsyncOpen",
"no url specified");
4184 TString outf =
".TFileAsyncOpen_";
4195 while (namelist.
Tokenize(
n, from,
"|") && !
f) {
4210 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4211 (!strcmp(
h->GetClass(),
"TXNetFile") || !strcmp(
h->GetClass(),
"TNetXNGFile"))
4212 &&
h->LoadPlugin() == 0) {
4213 f = (
TFile*)
h->ExecPlugin(6,
name.Data(), option, ftitle, compress, netopt,
kTRUE);
4217 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TFile",
name)) &&
4218 !strcmp(
h->GetClass(),
"TAlienFile") &&
h->LoadPlugin() == 0) {
4219 f = (
TFile*)
h->ExecPlugin(5,
name.Data(), option, ftitle, compress,
kTRUE);
4229 if (!notfound && !
f)
4274 if ((
f = fh->
GetFile()) && !(
f->IsZombie())) {
4276 Bool_t cr = (!strcmp(
f->GetOption(),
"CREATE") ||
4277 !strcmp(
f->GetOption(),
"RECREATE") ||
4288 if (
f)
f->fAsyncHandle = fh;
4300#if defined(R__WINGCC)
4304#elif defined(R__SEEK64)
4305 return ::open64(pathname, flags, mode);
4316 if (fd < 0)
return 0;
4325 return ::read(fd, buf, len);
4333 return ::write(fd, buf, len);
4344#if defined (R__SEEK64)
4345 return ::lseek64(fd, offset, whence);
4347 return ::_lseeki64(fd, offset, whence);
4349 return ::lseek(fd, offset, whence);
4376 return ::_commit(fd);
4447 if (!cached.EndsWith(
"/"))
4454 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it",
TString(cachedir).Data());
4496 cachetagfile +=
".tag.ROOT.cache";
4500 if (lastcleanuptime < cleanupinterval) {
4501 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4507 cachetagfile +=
"?filetype=raw";
4508 TFile *tagfile =
nullptr;
4510 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4511 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4519#if defined(R__WIN32)
4520 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4521#elif defined(R__MACOSX)
4522 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);
4524 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);
4531 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4661 forceRemote =
kTRUE;
4662 else if (opts.
Contains(
"remote=0"))
4671 if (fname[0] ==
'/') {
4673 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4676 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4694 if (localFile && prefix)
4701 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").
Match(
name)) {
4705 }
else if (!strncmp(
name,
"file:", 5)) {
4731 if (of && (of->
GetSize() > 0)) {
4734 while ((
f = (
TFile *)nxf()))
4735 if (
f->Matches(
name))
4736 return f->GetAsyncOpenStatus();
4748 if (handle && handle->
fFile) {
4778 if (of && (of->
GetSize() > 0)) {
4781 while ((
f = (
TFile *)nxf()))
4782 if (
f->Matches(
name))
4783 return f->GetEndpointUrl();
4787 return (
const TUrl *)
nullptr;
4795 fprintf(stderr,
"[TFile::Cp] Total %.02f MB\t|", (
Double_t)size/1048576);
4797 for (
int l = 0;
l < 20;
l++) {
4799 if (
l < 20*bytesread/size)
4800 fprintf(stderr,
"=");
4801 else if (
l == 20*bytesread/size)
4802 fprintf(stderr,
">");
4803 else if (
l > 20*bytesread/size)
4804 fprintf(stderr,
".");
4806 fprintf(stderr,
"=");
4812 fprintf(stderr,
"| %.02f %% [%.01f MB/s]\r",
4813 100.0*(size?(bytesread/((
float)size)):1), (lCopy_time>0.)?bytesread/lCopy_time/1048576.:0.);
4837 if (opt !=
"") opt +=
"&";
4846 char *copybuffer =
nullptr;
4848 TFile *sfile =
this;
4849 TFile *dfile =
nullptr;
4865 ::Error(
"TFile::Cp",
"cannot open destination file %s", dst);
4871 rmdestiferror =
kTRUE;
4876 copybuffer =
new char[buffersize];
4878 ::Error(
"TFile::Cp",
"cannot allocate the copy buffer");
4883 Long64_t read, written, totalread, filesize, b00;
4893 if (progressbar)
CpProgress(totalread, filesize,watch);
4898 if (filesize - b1 > (
Long64_t)buffersize) {
4899 readsize = buffersize;
4901 readsize = filesize - b1;
4904 if (readsize == 0)
break;
4910 if ((read <= 0) || readop) {
4911 ::Error(
"TFile::Cp",
"cannot read from source file %s. readsize=%lld read=%lld readop=%d",
4912 sfile->
GetName(), readsize, read, readop);
4919 if ((written != read) || writeop) {
4920 ::Error(
"TFile::Cp",
"cannot write %lld bytes to destination file %s", read, dst);
4924 }
while (read == (
Long64_t)buffersize);
4928 fprintf(stderr,
"\n");
4934 if (dfile) dfile->
Close();
4936 if (dfile)
delete dfile;
4937 if (copybuffer)
delete[] copybuffer;
4939 if (rmdestiferror && (success !=
kTRUE))
4962 if (opt !=
"") opt +=
"&";