79 #define _XOPEN_SOURCE 600 90 # include <sys/types.h> 94 #include "Compression.h" 96 #include "RConfigure.h" 128 #include "compiledata.h" 144 TList *TFile::fgAsyncOpenRequests = 0;
158 static struct AddPseudoGlobals {
184 fCacheReadMap =
new TMap();
197 fAsyncOpenStatus = kAOSNotAsync;
198 SetBit(kBinaryFile,
kTRUE);
214 Info(
"TFile",
"default ctor");
323 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
331 fNoAnchorInName =
kTRUE;
338 fname1 = fUrl.GetFile();
342 if (strstr(fUrl.GetOptions(),
"filetype=raw"))
347 if (strstr(fUrl.GetOptions(),
"filetype=pcm"))
356 fAsyncOpenStatus = kAOSNotAsync;
362 fVersion =
gROOT->GetVersionInt();
365 fCompress = compress;
379 fCacheReadMap =
new TMap();
382 SetBit(kBinaryFile,
kTRUE);
389 if (fIsRootFile && !fIsPcmFile && fOption !=
"NEW" && fOption !=
"CREATE" 390 && fOption !=
"RECREATE") {
398 if (!strlen(fArchive->GetMemberName()))
403 if (fOption ==
"NET")
406 if (fOption ==
"WEB") {
412 if (fOption ==
"NEW")
419 if (!create && !recreate && !
update && !
read) {
426 if (!fname1 || !fname1[0]) {
427 Error(
"TFile",
"file name is not specified");
432 if (!strcmp(fname1,
"/dev/null") &&
447 fRealName = GetName();
448 fname = fRealName.Data();
450 Error(
"TFile",
"error expanding path %s", fname1);
457 SysError(
"TFile",
"could not delete %s (errno: %d)",
467 Error(
"TFile",
"file %s already exists", fname);
476 Error(
"TFile",
"no write permission, could not open file %s", fname);
482 Error(
"TFile",
"file %s does not exist", fname);
486 Error(
"TFile",
"no read permission, could not open file %s", fname);
494 fD = SysOpen(fname, O_RDWR | O_CREAT, 0644);
496 fD = SysOpen(fname, O_RDWR | O_CREAT |
O_BINARY, S_IREAD | S_IWRITE);
499 SysError(
"TFile",
"file %s can not be opened", fname);
505 fD = SysOpen(fname, O_RDONLY, 0644);
507 fD = SysOpen(fname, O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
510 SysError(
"TFile",
"file %s can not be opened for reading", fname);
524 gROOT->GetListOfClosedObjects()->Add(
this);
535 MayNotUse(
"TFile::TFile(const TFile &)");
557 gROOT->GetListOfClosedObjects()->Remove(
this);
558 gROOT->GetUUIDs()->RemoveUUID(GetUniqueID());
568 Info(
"~TFile",
"dtor called for %s [%lx]", GetName(),(
Long_t)
this);
593 if (fOption !=
"READ") {
594 Error(
"Init",
"archive %s can only be opened in read mode", GetName());
601 fArchive->OpenArchive();
603 if (fIsArchive)
return;
606 if (!fNoAnchorInName)
607 if (!strchr(GetName(),
'#'))
610 if (fArchive->SetCurrentMember() != -1)
611 fArchiveOffset = fArchive->GetMemberFilePosition();
613 Error(
"Init",
"member %s not found in archive %s",
614 fArchive->GetMemberName(), fArchive->GetArchiveName());
637 TKey *key =
new TKey(fName, fTitle, IsA(), nbytes,
this);
638 fNbytesName = key->
GetKeylen() + namelen;
651 char *header =
new char[
kBEGIN+200];
656 Error(
"Init",
"%s failed to read the file type data.",
663 if (strncmp(header,
"root", 4)) {
664 Error(
"Init",
"%s not a ROOT file", GetName());
669 char *buffer = header + 4;
672 frombuf(buffer, &headerLength);
674 if (fVersion < 1000000) {
675 Int_t send,sfree,sinfo;
696 if (fBEGIN < 0 || fBEGIN > fEND) {
698 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
699 GetName(),fBEGIN,fEND);
706 if (fSeekFree > fBEGIN) {
709 Warning(
"Init",
"file %s probably not closed, cannot read free segments",GetName());
714 char *buffer_keyloc = 0;
717 if ( (nbytes + fBEGIN) > fEND) {
719 Error(
"Init",
"file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)",
720 GetName(),fBEGIN+nbytes,fEND);
723 if (nbytes+fBEGIN >
kBEGIN+200) {
725 header =
new char[nbytes];
730 Error(
"Init",
"%s failed to read the file header information at %lld (size=%d)",
731 GetName(),fBEGIN,nbytes);
735 buffer = header+fNbytesName;
736 buffer_keyloc = header;
738 buffer = header+fBEGIN+fNbytesName;
739 buffer_keyloc = header+fBEGIN;
742 frombuf(buffer,&version); versiondir = version%1000;
743 fDatimeC.ReadBuffer(buffer);
744 fDatimeM.ReadBuffer(buffer);
747 if (version > 1000) {
752 Int_t sdir,sparent,skeys;
757 if (versiondir > 1) fUUID.ReadBuffer(buffer);
760 buffer_keyloc +=
sizeof(
Int_t);
762 frombuf(buffer_keyloc, &keyversion);
764 if (keyversion > 1000) {
773 fTitle.ReadBuffer(buffer_keyloc);
775 if (fNbytesName < 10 || fNbytesName > 10000) {
776 Error(
"Init",
"cannot read directory info of file %s", GetName());
782 if ((size = GetSize()) == -1) {
783 Error(
"Init",
"cannot stat the file %s", GetName());
792 if (fSeekKeys > fBEGIN && fEND <= size) {
800 Error(
"Init",
"file %s has no keys", GetName());
804 }
else if ((fBEGIN+nbytes == fEND) && (fEND == size)) {
806 Warning(
"Init",
"file %s has no keys", GetName());
812 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld, " 813 "trying to recover", GetName(), size, fEND);
815 Error(
"Init",
"file %s is truncated at %lld bytes: should be %lld",
816 GetName(), size, fEND);
821 Warning(
"Init",
"file %s probably not closed, " 822 "trying to recover", GetName());
824 Warning(
"Init",
"file %s probably not closed", GetName());
828 Int_t nrecov = Recover();
830 Warning(
"Init",
"successfully recovered %d keys", nrecov);
832 Warning(
"Init",
"no keys recovered, file has been made a Zombie");
840 gROOT->GetListOfFiles()->Add(
this);
841 gROOT->GetUUIDs()->AddUUID(fUUID,
this);
846 Int_t lenIndex =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
847 if (lenIndex < 5000) lenIndex = 5000;
848 fClassIndex =
new TArrayC(lenIndex);
850 if (fSeekInfo > fBEGIN) {
854 gROOT->GetListOfFiles()->Remove(
this);
857 }
else if (fVersion !=
gROOT->GetVersionInt() && fVersion > 30000) {
858 Warning(
"Init",
"no StreamerInfo found in %s therefore preventing schema evolution when reading this file.",GetName());
867 while ((key = (
TKey*)next())) {
868 if (!strcmp(key->
GetClassName(),
"TProcessID")) fNProcessIDs++;
870 fProcessIDs =
new TObjArray(fNProcessIDs+1);
877 gROOT->GetListOfClosedObjects()->Add(
this);
903 if (!IsOpen())
return;
905 if (fIsArchive || !fIsRootFile) {
921 if (fCacheRead) fCacheRead->Close();
923 TIter iter(fCacheReadMap);
925 while ((key = iter()) != 0) {
970 TIter next(fProcessIDs);
983 gROOT->GetListOfFiles()->Remove(
this);
984 gROOT->GetListOfBrowsers()->RecursiveRemove(
this);
985 gROOT->GetListOfClosedObjects()->Add(
this);
996 return new TKey(obj,
name, bufsize, mother);
1004 return new TKey(obj, cl,
name, bufsize, mother);
1016 static TFile *currentFile = 0;
1048 Info(
"Delete",
"deleting name = %s", namecycle);
1069 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFileDrawMap"))) {
1081 if (IsOpen() && fWritable) {
1083 if (SysSync(fD) < 0) {
1085 SetBit(kWriteError); SetWritable(
kFALSE);
1086 SysError(
"Flush",
"error flushing file %s", GetName());
1098 if (fCacheWrite && IsOpen() && fWritable)
1099 return fCacheWrite->Flush();
1110 Version_t version = TFile::Class_Version();
1111 tobuf(buffer, version);
1124 Double_t mean = fSumBuffer/fWritten;
1139 Int_t nbytes, objlen, nwh = 64;
1140 char *header =
new char[fBEGIN];
1144 comp = uncomp = fBEGIN;
1146 while (idcur < fEND-100) {
1161 if (nbytes == 0)
break;
1167 if (!objlen) objlen = nbytes-keylen;
1169 uncomp += keylen + objlen;
1198 if (!fCacheRead && fCacheReadMap->GetSize() == 1) {
1199 TIter next(fCacheReadMap);
1205 if (!cache)
return fCacheRead;
1237 if (first < fBEGIN)
return 0;
1238 if (first > fEND)
return 0;
1240 Int_t nread = maxbytes;
1241 if (first+maxbytes > fEND) nread = fEND-maxbytes;
1243 Warning(
"GetRecordHeader",
"%s: parameter maxbytes = %d must be >= 4",
1249 Warning(
"GetRecordHeader",
"%s: failed to read header data (maxbytes = %d)",
1260 if (nb < 0)
return nread;
1262 const Int_t headerSize = 16;
1263 if (nread < headerSize)
return nread;
1268 if (!olen) olen = nbytes-klen;
1282 if (fArchive && fArchive->GetMember()) {
1283 size = fArchive->GetMember()->GetDecompressedSize();
1286 if (const_cast<TFile*>(
this)->SysStat(fD, &
id, &size, &flags, &modtime)) {
1287 Error(
"GetSize",
"cannot stat the file %s", GetName());
1299 return fInfoCache ? fInfoCache : (fInfoCache=GetStreamerInfoList());
1320 if (fIsPcmFile)
return 0;
1326 char *buffer =
new char[fNbytesInfo+1];
1331 Warning(
"GetRecordHeader",
"%s: failed to read the StreamerInfo data from disk.",
1341 list = (
TList*)Get(
"StreamerInfo");
1345 Info(
"GetStreamerInfoList",
"cannot find the StreamerInfo record in file %s",
1363 std::cout <<
ClassName()<<
"**\t\t"<<GetName()<<
"\t"<<GetTitle()<<std::endl;
1392 if(!newfree)
return;
1396 if (nbytesl > 2000000000) nbytesl = 2000000000;
1399 char * buffer =
new char[nb];
1400 char * psave = buffer;
1401 tobuf(buffer, nbytes);
1402 if (last == fEND-1) fEND = nfirst;
1409 WriteBuffer(psave, nb);
1410 if (fMustFlush) Flush();
1451 Int_t nbytes,date,time,objlen,nwheader;
1460 Int_t nread = nwheader;
1463 char classname[512];
1465 while (idcur < fEND) {
1467 if (idcur+nread >= fEND) nread = fEND-idcur-1;
1470 Warning(
"Map",
"%s: failed to read the key data from disk at %lld.",
1478 Printf(
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1483 Printf(
"Address = %lld\tNbytes = %d\t=====G A P===========", idcur, nbytes);
1494 if (versionkey > 1000) {
1503 for (
int i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1504 classname[(int)nwhc] =
'\0';
1505 if (idcur == fSeekFree) strlcpy(classname,
"FreeSegments",512);
1506 if (idcur == fSeekInfo) strlcpy(classname,
"StreamerInfo",512);
1507 if (idcur == fSeekKeys) strlcpy(classname,
"KeysList",512);
1509 if (objlen != nbytes-keylen) {
1511 Printf(
"%d/%06d At:%lld N=%-8d %-14s CX = %5.2f",date,time,idcur,nbytes,classname,cx);
1513 Printf(
"%d/%06d At:%lld N=%-8d %-14s",date,time,idcur,nbytes,classname);
1517 Printf(
"%d/%06d At:%lld N=%-8d %-14s",date,time,idcur,1,
"END");
1525 GetList()->R__FOR_EACH(
TObject,Paint)(option);
1533 Printf(
"TFile: name=%s, title=%s, option=%s", GetName(), GetTitle(), GetOption());
1555 if ((st = ReadBufferViaCache(buf, len))) {
1564 while ((siz = SysRead(fD, buf, len)) < 0 &&
GetErrno() == EINTR)
1568 SysError(
"ReadBuffer",
"error reading from file %s", GetName());
1572 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1573 GetName(), (
Long_t)siz, len);
1600 if ((st = ReadBufferViaCache(buf, len))) {
1611 while ((siz = SysRead(fD, buf, len)) < 0 &&
GetErrno() == EINTR)
1615 SysError(
"ReadBuffer",
"error reading from file %s", GetName());
1619 Error(
"ReadBuffer",
"error reading all requested bytes from file %s, got %ld of %d",
1620 GetName(), (
Long_t)siz, len);
1650 for (
Int_t j = 0; j < nbuf; j++) {
1651 if (ReadBufferAsync(pos[j], len[j])) {
1667 cur = pos[i]+len[i];
1669 if (cur -curbegin < fgReadaheadSize) {
n++; i++; bigRead =
kFALSE;}
1670 if (bigRead || (i>=nbuf)) {
1682 if (buf2 == 0) buf2 =
new char[fgReadaheadSize];
1684 Long64_t nahead = pos[i-1]+len[i-1]-curbegin;
1689 for (
Int_t j=0;j<
n;j++) {
1690 memcpy(&buf[k],&buf2[pos[i-n+j]-curbegin],len[i-n+j]);
1695 fBytesReadExtra += extra;
1696 fBytesRead -= extra;
1697 fgBytesRead -= extra;
1703 if (buf2)
delete [] buf2;
1718 Int_t st = fCacheRead->ReadBuffer(buf, off, len);
1723 SetOffset(off + len);
1730 if (fWritable && fCacheWrite) {
1731 if (fCacheWrite->ReadBuffer(buf, off, len) == 0) {
1732 SetOffset(off + len);
1753 if (fNbytesFree < 0 || fNbytesFree > fEND) {
1757 TKey *headerfree =
new TKey(fSeekFree, fNbytesFree,
this);
1766 if (afree->
GetLast() > fEND)
break;
1779 TObjArray *pids = GetListOfProcessIDs();
1789 snprintf(pidname,32,
"ProcessID%d",pidf);
1792 printf(
"ReadProcessID, name=%s, file=%s, pid=%lx\n",pidname,GetName(),(
Long_t)pid);
1800 TIter next(pidslist);
1860 Int_t nbytes,date,time,objlen,nwheader;
1863 char *buffer, *bufread;
1868 if ((size = GetSize()) == -1) {
1869 Error(
"Recover",
"cannot stat the file %s", GetName());
1875 if (fWritable && !fFree) fFree =
new TList;
1880 Int_t nread = nwheader;
1882 while (idcur < fEND) {
1884 if (idcur+nread >= fEND) nread = fEND-idcur-1;
1887 Error(
"Recover",
"%s: failed to read the key data from disk at %lld.",
1895 Error(
"Recover",
"Address = %lld\tNbytes = %d\t=====E R R O R=======", idcur, nbytes);
1900 if (fWritable)
new TFree(fFree,idcur,idcur-nbytes-1);
1910 if (versionkey > 1000) {
1919 char *classname = 0;
1920 if (nwhc <= 0 || nwhc > 100)
break;
1921 classname =
new char[nwhc+1];
1922 int i, nwhci = nwhc;
1923 for (i = 0;i < nwhc; i++)
frombuf(buffer, &classname[i]);
1924 classname[nwhci] =
'\0';
1928 && strcmp(classname,
"TBasket")) {
1929 key =
new TKey(
this);
1931 if (!strcmp(key->
GetName(),
"StreamerInfo")) {
1932 fSeekInfo = seekkey;
1934 fNbytesInfo = nbytes;
1939 Info(
"Recover",
"%s, recovered key %s:%s at address %lld",GetName(),key->
GetClassName(),key->
GetName(),idcur);
1942 delete [] classname;
1947 if (max_file_size < fEND) max_file_size = fEND+1000000000;
1950 last->
AddFree(fFree,fEND,max_file_size);
1952 new TFree(fFree,fEND,max_file_size);
1954 if (nrecov) Write();
1977 if (opt !=
"READ" && opt !=
"UPDATE") {
1978 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
1982 if (opt == fOption || (opt ==
"UPDATE" && fOption ==
"CREATE"))
1985 if (opt ==
"READ") {
1989 if (IsOpen() && IsWritable()) {
1990 WriteStreamerInfo();
2018 fD = SysOpen(fRealName, O_RDONLY, 0644);
2020 fD = SysOpen(fRealName, O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
2023 SysError(
"ReOpen",
"file %s can not be opened in read mode", GetName());
2040 fD = SysOpen(fRealName, O_RDWR | O_CREAT, 0644);
2042 fD = SysOpen(fRealName, O_RDWR | O_CREAT |
O_BINARY, S_IREAD | S_IWRITE);
2045 SysError(
"ReOpen",
"file %s can not be opened in update mode", GetName());
2051 if (fSeekFree > fBEGIN)
2054 Warning(
"ReOpen",
"file %s probably not closed, cannot read free segments", GetName());
2067 fOffset = offset + fArchiveOffset;
2075 Error(
"SetOffset",
"seeking from end in archive is not (yet) supported");
2076 fOffset = fEND + offset;
2090 offset += fArchiveOffset;
2099 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
2103 if ((retpos = SysSeek(fD, offset, whence)) < 0)
2104 SysError(
"Seek",
"cannot seek to position %lld in file %s, retpos=%lld",
2105 offset, GetName(), retpos);
2117 if (algorithm < 0 || algorithm >= ROOT::kUndefinedCompressionAlgorithm) algorithm = 0;
2118 if (fCompress < 0) {
2120 fCompress = 100 * algorithm + 1;
2122 int level = fCompress % 100;
2123 fCompress = 100 * algorithm + level;
2132 if (level < 0) level = 0;
2133 if (level > 99) level = 99;
2134 if (fCompress < 0) {
2138 int algorithm = fCompress / 100;
2139 if (algorithm >= ROOT::kUndefinedCompressionAlgorithm) algorithm = 0;
2140 fCompress = 100 * algorithm + level;
2151 fCompress = settings;
2179 if (cache) fCacheReadMap->Add(tree, cache);
2184 fCacheReadMap->Remove(tree);
2185 if (tpf && (tpf->
GetFile() ==
this) && (action != kDoNotDisconnect)) tpf->
SetFile(0, action);
2188 if (cache) cache->
SetFile(
this, action);
2189 else if (!tree && fCacheRead && (action != kDoNotDisconnect)) fCacheRead->SetFile(0, action);
2201 if (!cache && fCacheWrite)
delete fCacheWrite;
2202 fCacheWrite = cache;
2216 void TFile::Streamer(
TBuffer &b)
2231 fSumBuffer += double(bufsize);
2232 fSum2Buffer += double(bufsize) * double(bufsize);
2249 if (!IsWritable()) {
2250 if (!TestBit(kWriteError)) {
2252 Warning(
"Write",
"file %s not opened in write mode", GetName());
2258 if (!GetTitle() || strlen(GetTitle()) == 0)
2259 Info(
"Write",
"writing name = %s", GetName());
2261 Info(
"Write",
"writing name = %s title = %s", GetName(), GetTitle());
2266 WriteStreamerInfo();
2279 Error(
"Write const",
"A const TFile object should not be saved. We try to proceed anyway.");
2280 return const_cast<TFile*
>(
this)->Write(
n, opt, bufsize);
2289 if (IsOpen() && fWritable) {
2292 if ((st = WriteBufferViaCache(buf, len))) {
2300 while ((siz = SysWrite(fD, buf, len)) < 0 &&
GetErrno() == EINTR)
2305 SetBit(kWriteError); SetWritable(
kFALSE);
2306 SysError(
"WriteBuffer",
"error writing to file %s (%ld)", GetName(), (
Long_t)siz);
2310 SetBit(kWriteError);
2311 Error(
"WriteBuffer",
"error writing all requested bytes to file %s, wrote %ld of %d",
2312 GetName(), (
Long_t)siz, len);
2316 fgBytesWrite += siz;
2332 if (!fCacheWrite)
return 0;
2336 if ((st = fCacheWrite->WriteBuffer(buf, off, len)) < 0) {
2337 SetBit(kWriteError);
2338 Error(
"WriteBuffer",
"error writing to cache");
2357 if (fSeekFree != 0){
2358 MakeFree(fSeekFree, fSeekFree + fNbytesFree -1);
2364 while ((afree = (
TFree*) next())) {
2365 nbytes += afree->
Sizeof();
2367 if (!nbytes)
return;
2369 TKey *key =
new TKey(fName,fTitle,IsA(),nbytes,
this);
2375 char *start = buffer;
2378 while ((afree = (
TFree*) next())) {
2381 if ( (buffer-start)!=nbytes ) {
2384 memset(buffer,0,nbytes-(buffer-start));
2399 if (lastfree) fEND = lastfree->
GetFirst();
2400 const char *root =
"root";
2401 char *psave =
new char[fBEGIN];
2402 char *buffer = psave;
2403 Int_t nfree = fFree->GetSize();
2404 memcpy(buffer, root, 4); buffer += 4;
2405 Int_t version = fVersion;
2406 if (version <1000000 && fEND > kStartBigFile) {version += 1000000; fUnits = 8;}
2407 tobuf(buffer, version);
2409 if (version < 1000000) {
2412 tobuf(buffer, fNbytesFree);
2413 tobuf(buffer, nfree);
2414 tobuf(buffer, fNbytesName);
2415 tobuf(buffer, fUnits);
2416 tobuf(buffer, fCompress);
2418 tobuf(buffer, fNbytesInfo);
2420 tobuf(buffer, fEND);
2421 tobuf(buffer, fSeekFree);
2422 tobuf(buffer, fNbytesFree);
2423 tobuf(buffer, nfree);
2424 tobuf(buffer, fNbytesName);
2425 tobuf(buffer, fUnits);
2426 tobuf(buffer, fCompress);
2427 tobuf(buffer, fSeekInfo);
2428 tobuf(buffer, fNbytesInfo);
2430 fUUID.FillBuffer(buffer);
2431 Int_t nbytes = buffer - psave;
2433 WriteBuffer(psave, nbytes);
2522 path +=
"/PROOF-INF";
2524 const char *afile = 0;
2527 if (strcmp(afile,
".") == 0)
continue;
2528 if (strcmp(afile,
"..") == 0)
continue;
2529 filepath.
Form(
"%s/%s", path.
Data(), afile);
2531 Warning(
"MakeProject",
"1: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2538 if (strcmp(afile,
".") == 0)
continue;
2539 if (strcmp(afile,
"..") == 0)
continue;
2540 filepath.
Form(
"%s/%s", path.
Data(), afile);
2542 Warning(
"MakeProject",
"2: problems unlinking '%s' ('%s', '%s')", filepath.
Data(), path.
Data(), afile);
2546 Warning(
"MakeProject",
"problems unlinking '%s'", path.
Data());
2550 path.
Form(
"%s/%s/PROOF-INF", pardir.
Data(), parname.
Data());
2552 Error(
"MakeProject",
"problems creating '%s'", path.
Data());
2567 }
else if (opt.
Contains(
"recreate")) {
2571 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2578 if (afile == 0)
break;
2579 if (strcmp(afile,
".") == 0)
continue;
2580 if (strcmp(afile,
"..") == 0)
continue;
2581 dirpath.
Form(
"%s/%s",dirname,afile);
2589 Error(
"MakeProject",
"cannot create directory %s, already existing",dirname);
2594 Error(
"MakeProject",
"cannot create directory '%s'",dirname);
2606 TList *filelist = (
TList*)GetStreamerInfoCache();
2607 if (filelist) filelist = (
TList*)filelist->
Clone();
2608 if (filelist == 0) {
2609 Error(
"MakeProject",
"file %s has no StreamerInfo", GetName());
2613 TString clean_dirname(dirname);
2614 if (makepar) clean_dirname.
Form(
"%s/%s", pardir.
Data(), parname.
Data());
2615 if (clean_dirname[clean_dirname.
Length()-1]==
'/') {
2617 }
else if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2619 if (clean_dirname[clean_dirname.
Length()-1]==
'\\') {
2624 if (makepar) subdirname = parname;
2625 if (subdirname ==
"") {
2626 Error(
"MakeProject",
"Directory name must not be empty.");
2631 TString spath; spath.
Form(
"%s/%sProjectSource.cxx",clean_dirname.
Data(),subdirname.Data());
2632 FILE *sfp = fopen(spath.
Data(),
"w");
2634 Error(
"MakeProject",
"Unable to create the source file %s.",spath.
Data());
2637 fprintf(sfp,
"namespace std {}\nusing namespace std;\n");
2638 fprintf(sfp,
"#include \"%sProjectHeaders.h\"\n\n",subdirname.Data() );
2639 if (!genreflex) fprintf(sfp,
"#include \"%sLinkDef.h\"\n\n",subdirname.Data() );
2640 fprintf(sfp,
"#include \"%sProjectDict.cxx\"\n\n",subdirname.Data() );
2641 fprintf(sfp,
"struct DeleteObjectFunctor {\n");
2642 fprintf(sfp,
" template <typename T>\n");
2643 fprintf(sfp,
" void operator()(const T *ptr) const {\n");
2644 fprintf(sfp,
" delete ptr;\n");
2645 fprintf(sfp,
" }\n");
2646 fprintf(sfp,
" template <typename T, typename Q>\n");
2647 fprintf(sfp,
" void operator()(const std::pair<T,Q> &) const {\n");
2648 fprintf(sfp,
" // Do nothing\n");
2649 fprintf(sfp,
" }\n");
2650 fprintf(sfp,
" template <typename T, typename Q>\n");
2651 fprintf(sfp,
" void operator()(const std::pair<T,Q*> &ptr) const {\n");
2652 fprintf(sfp,
" delete ptr.second;\n");
2653 fprintf(sfp,
" }\n");
2654 fprintf(sfp,
" template <typename T, typename Q>\n");
2655 fprintf(sfp,
" void operator()(const std::pair<T*,Q> &ptr) const {\n");
2656 fprintf(sfp,
" delete ptr.first;\n");
2657 fprintf(sfp,
" }\n");
2658 fprintf(sfp,
" template <typename T, typename Q>\n");
2659 fprintf(sfp,
" void operator()(const std::pair<T*,Q*> &ptr) const {\n");
2660 fprintf(sfp,
" delete ptr.first;\n");
2661 fprintf(sfp,
" delete ptr.second;\n");
2662 fprintf(sfp,
" }\n");
2663 fprintf(sfp,
"};\n\n");
2670 TIter flnext(filelist);
2677 if (strstr(info->
GetName(),
"@@")) {
2694 for(
auto rule : rules) {
2695 if( rule->IsRenameRule() || rule->IsAliasRule() )
2698 if ( rule->HasTarget( el->GetName()) && rule->GetAttributes()[0] != 0 ) {
2701 if (
attr.Contains(
"owner")) {
2702 if (
attr.Contains(
"notowner")) {
2725 TIter nextextra(&extrainfos);
2728 filelist->
Add(info);
2739 TIter subnext(list);
2751 if ( (sublen > len) && subinfo->
GetName()[len+1]==
':' 2754 subClasses.
Add(subinfo);
2759 subClasses.
Clear(
"nodelete");
2762 path.
Form(
"%s/%sProjectHeaders.h",clean_dirname.
Data(),subdirname.Data());
2763 FILE *allfp = fopen(path,
"a");
2765 Error(
"MakeProject",
"Cannot open output file:%s\n",path.
Data());
2767 fprintf(allfp,
"#include \"%sProjectInstances.h\"\n", subdirname.Data());
2771 printf(
"MakeProject has generated %d classes in %s\n",ngener,clean_dirname.
Data());
2774 if (!opt.
Contains(
"+") && !makepar) {
2787 path.
Form(
"%s/makep.cmd",clean_dirname.
Data());
2789 path.
Form(
"%s/MAKEP",clean_dirname.
Data());
2792 fpMAKE = fopen(path,
"wb");
2794 fpMAKE = fopen(path,
"w");
2797 Error(
"MakeProject",
"cannot open file %s", path.
Data());
2807 path.
Form(
"%s/%sProjectInstances.h",clean_dirname.
Data(),subdirname.Data());
2809 ifp = fopen(path,
"wb");
2811 ifp = fopen(path,
"w");
2814 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
2824 fprintf(fpMAKE,
"genreflex %sProjectHeaders.h -o %sProjectDict.cxx --comments --iocomments %s ",subdirname.Data(),subdirname.Data(),
gSystem->
GetIncludePath());
2825 path.
Form(
"%s/%sSelection.xml",clean_dirname.
Data(),subdirname.Data());
2828 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.Data());
2831 path.
Form(
"%s/%sLinkDef.h",clean_dirname.
Data(),subdirname.Data());
2837 FILE *fp = fopen(path,
"wb");
2839 FILE *fp = fopen(path,
"w");
2842 Error(
"MakeProject",
"cannot open path file %s", path.
Data());
2851 fprintf(fp,
"<lcgdict>\n");
2854 fprintf(fp,
"#ifdef __CINT__\n");
2872 for(
auto rule : rules) {
2875 rule->AsString(strrule,
"x");
2878 selections.
Append(strrule);
2881 rule->AsString(strrule);
2882 if (strncmp(strrule.
Data(),
"type=",5)==0) {
2885 fprintf(fp,
"#pragma %s;\n",strrule.
Data());
2892 std::vector<std::string> inside;
2899 switch ( stlkind ) {
2903 what =
"std::pair<";
2907 if (what[what.
Length()-1]==
'>') {
2913 tmp.
Form(
"<class name=\"%s\" />\n",what.
Data());
2917 tmp.
Form(
"template class %s;\n",what.
Data());
2925 fprintf(fp,
"#pragma link C++ class %s+;\n",what.
Data());
2931 if (strncmp(key->
GetName(),
"pair<",strlen(
"pair<"))==0) {
2933 tmp.
Form(
"<class name=\"%s\" />\n",key->
GetName());
2943 fprintf(fp,
"#pragma link C++ class %s+;\n",key->
GetName());
2954 tmp.
Form(
"<class name=\"%s\" />\n",
what.Data());
2958 if (
what[
what.Length()-1] ==
'>') {
2959 tmp.
Form(
"template class %s;\n",
what.Data());
2965 what.ReplaceAll(
"std::",
"");
2966 fprintf(fp,
"#pragma link C++ class %s+;\n",
what.Data());
2974 if (element->GetClass() && !element->GetClass()->IsLoaded() && element->GetClass()->GetCollectionProxy()) {
2976 tmp.
Form(
"<class name=\"%s\" />\n",what.
Data());
2980 tmp.
Form(
"template class %s;\n",what.
Data());
2989 fprintf(ifp,
"#ifndef PROJECT_INSTANCES_H\n");
2990 fprintf(ifp,
"#define PROJECT_INSTANCES_H\n");
2991 fprintf(ifp,
"%s",instances.
Data());
2992 fprintf(ifp,
"#endif\n");
2993 fprintf(fp,
"%s",selections.
Data());
2994 fprintf(fp,
"</lcgdict>\n");
2996 fprintf(fp,
"#endif\n");
3017 TString rootbuild = ROOTBUILD;
3026 fprintf(fpMAKE,
"-s %sSelection.xml \n",subdirname.Data());
3028 fprintf(fpMAKE,
"%sProjectHeaders.h ",subdirname.Data());
3029 fprintf(fpMAKE,
"%sLinkDef.h \n",subdirname.Data());
3032 fprintf(fpMAKE,
"%s\n",cmd.
Data());
3034 printf(
"%s/MAKEP file has been generated\n", clean_dirname.
Data());
3042 if (MakeProjectParMake(parname, filemake.
Data()) != 0) {
3043 Error(
"MakeProject",
"problems creating PAR make file '%s'", filemake.
Data());
3052 Warning(
"MakeProject",
"problems expanding '%s'", mkarchsrc.
Data());
3055 Error(
"MakeProject",
"problems retrieving '%s' to '%s'", mkarchsrc.
Data(), mkarchdst.
Data());
3063 if (MakeProjectParProofInf(parname, proofinf.
Data()) != 0) {
3064 Error(
"MakeProject",
"problems creating BUILD.sh and/or SETUP.C under '%s'", proofinf.
Data());
3077 chmod(cmod.
Data(), 00700);
3079 Printf(
"Files Makefile, Makefile.arch, PROOF-INF/BUILD.sh and" 3080 " PROOF-INF/SETUP.C have been generated under '%s'", clean_dirname.
Data());
3089 Info(
"MakeProject",
"PAR file %s.par generated", clean_dirname.
Data());
3091 Warning(
"MakeProject",
"problems changing directory back to '%s'", curdir.Data());
3094 Error(
"MakeProject",
"problems changing directory to '%s' - skipping PAR file generation", pardir.
Data());
3097 Warning(
"MakeProject",
"on Windows systems the PAR file cannot be generated out of the package directory!");
3102 if (!makepar && !opt.
Contains(
"nocompilation")) {
3111 chmod(
"makep.cmd",00700);
3116 if (res) printf(
"Shared lib %s has been generated\n",path.
Data());
3121 if (res) printf(
"Shared lib %s has been dynamically linked\n",path.
Data());
3125 extrainfos.
Clear(
"nodelete");
3141 if (!filemake || (filemake && strlen(filemake) <= 0)) {
3142 Error(
"MakeProjectParMake",
"path for output file undefined!");
3147 if (!pack || (pack && strlen(pack) <= 0)) {
3148 Error(
"MakeProjectParMake",
"package name undefined!");
3153 FILE *fmk = fopen(filemake,
"wb");
3155 FILE *fmk = fopen(filemake,
"w");
3163 fprintf(fmk,
"# Makefile for the ROOT test programs.\n");
3164 fprintf(fmk,
"# This Makefile shows how to compile and link applications\n");
3165 fprintf(fmk,
"# using the ROOT libraries on all supported platforms.\n");
3166 fprintf(fmk,
"#\n");
3167 fprintf(fmk,
"# Copyright (c) 2000 Rene Brun and Fons Rademakers\n");
3168 fprintf(fmk,
"#\n");
3169 fprintf(fmk,
"# Author: this makefile has been automatically generated via TFile::MakeProject\n");
3171 fprintf(fmk,
"include Makefile.arch\n");
3173 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3175 fprintf(fmk,
"PACKO = %sProjectSource.$(ObjSuf)\n", pack);
3176 fprintf(fmk,
"PACKS = %sProjectSource.$(SrcSuf) %sProjectDict.$(SrcSuf)\n", pack, pack);
3177 fprintf(fmk,
"PACKSO = lib%s.$(DllSuf)\n", pack);
3179 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3180 fprintf(fmk,
"PACKLIB = lib%s.lib\n", pack);
3181 fprintf(fmk,
"else\n");
3182 fprintf(fmk,
"PACKLIB = $(PACKSO)\n");
3183 fprintf(fmk,
"endif\n");
3185 fprintf(fmk,
"OBJS = $(PACKO)\n");
3187 fprintf(fmk,
"PROGRAMS =\n");
3189 fprintf(fmk,
"#------------------------------------------------------------------------------\n");
3191 fprintf(fmk,
".SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)\n");
3193 fprintf(fmk,
"all: $(PACKLIB)\n");
3195 fprintf(fmk,
"$(PACKSO): $(PACKO)\n");
3196 fprintf(fmk,
"ifeq ($(ARCH),aix)\n");
3197 fprintf(fmk,
"\t\t/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3198 fprintf(fmk,
"else\n");
3199 fprintf(fmk,
"ifeq ($(ARCH),aix5)\n");
3200 fprintf(fmk,
"\t\t/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^\n");
3201 fprintf(fmk,
"else\n");
3202 fprintf(fmk,
"ifeq ($(PLATFORM),macosx)\n");
3203 fprintf(fmk,
"# We need to make both the .dylib and the .so\n");
3204 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)\n");
3205 fprintf(fmk,
"ifneq ($(subst $(MACOSX_MINOR),,1234),1234)\n");
3206 fprintf(fmk,
"ifeq ($(MACOSX_MINOR),4)\n");
3207 fprintf(fmk,
"\t\tln -sf $@ $(subst .$(DllSuf),.so,$@)\n");
3208 fprintf(fmk,
"else\n");
3209 fprintf(fmk,
"\t\t$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \\\n");
3210 fprintf(fmk,
"\t\t $(OutPutOpt) $(subst .$(DllSuf),.so,$@)\n");
3211 fprintf(fmk,
"endif\n");
3212 fprintf(fmk,
"endif\n");
3213 fprintf(fmk,
"else\n");
3214 fprintf(fmk,
"ifeq ($(PLATFORM),win32)\n");
3215 fprintf(fmk,
"\t\tbindexplib $* $^ > $*.def\n");
3216 fprintf(fmk,
"\t\tlib -nologo -MACHINE:IX86 $^ -def:$*.def \\\n");
3217 fprintf(fmk,
"\t\t $(OutPutOpt)$(PACKLIB)\n");
3218 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \\\n");
3219 fprintf(fmk,
"\t\t $(OutPutOpt)$@\n");
3220 fprintf(fmk,
"else\n");
3221 fprintf(fmk,
"\t\t$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS) $(EXPLLINKLIBS)\n");
3222 fprintf(fmk,
"endif\n");
3223 fprintf(fmk,
"endif\n");
3224 fprintf(fmk,
"endif\n");
3225 fprintf(fmk,
"endif\n");
3226 fprintf(fmk,
"\t\t@echo \"$@ done\"\n");
3228 fprintf(fmk,
"clean:\n");
3229 fprintf(fmk,
"\t\t@rm -f $(OBJS) core\n");
3231 fprintf(fmk,
"distclean: clean\n");
3232 fprintf(fmk,
"\t\t@rm -f $(PROGRAMS) $(PACKSO) $(PACKLIB) *Dict.* *.def *.exp \\\n");
3233 fprintf(fmk,
"\t\t *.so *.lib *.dll *.d *.log .def so_locations\n");
3234 fprintf(fmk,
"\t\t@rm -rf cxx_repository\n");
3236 fprintf(fmk,
"# Dependencies\n");
3238 fprintf(fmk,
"%sProjectSource.$(ObjSuf): %sProjectHeaders.h %sLinkDef.h %sProjectDict.$(SrcSuf)\n", pack, pack, pack, pack);
3240 fprintf(fmk,
"%sProjectDict.$(SrcSuf): %sProjectHeaders.h %sLinkDef.h\n", pack, pack, pack);
3241 fprintf(fmk,
"\t\t@echo \"Generating dictionary $@...\"\n");
3242 fprintf(fmk,
"\t\t@rootcint -f $@ -c $^\n");
3244 fprintf(fmk,
".$(SrcSuf).$(ObjSuf):\n");
3245 fprintf(fmk,
"\t\t$(CXX) $(CXXFLAGS) -c $<\n");
3263 if (!proofinf || (proofinf && strlen(proofinf) <= 0)) {
3264 Error(
"MakeProjectParProofInf",
"directory path undefined!");
3272 Error(
"MakeProjectParProofInf",
"path '%s' %s", proofinf,
3273 ((rcst == 0) ?
"is not a directory" :
"does not exist"));
3278 if (!pack || (pack && strlen(pack) <= 0)) {
3279 Error(
"MakeProjectParProofInf",
"package name undefined!");
3286 path.
Form(
"%s/BUILD.sh", proofinf);
3288 FILE *
f = fopen(path.
Data(),
"wb");
3290 FILE *f = fopen(path.
Data(),
"w");
3293 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3298 fprintf(f,
"#! /bin/sh\n");
3299 fprintf(f,
"# Build libEvent library.\n");
3302 fprintf(f,
"# The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3303 fprintf(f,
"# adapt the script to the calling environment\n");
3305 fprintf(f,
"# if test ! \"x$ROOTPROOFLITE\" = \"x\"; then\n");
3306 fprintf(f,
"# echo \"event-BUILD: PROOF-Lite node (session has $ROOTPROOFLITE workers)\"\n");
3307 fprintf(f,
"# elif test ! \"x$ROOTPROOFCLIENT\" = \"x\"; then\n");
3308 fprintf(f,
"# echo \"event-BUILD: PROOF client\"\n");
3309 fprintf(f,
"# else\n");
3310 fprintf(f,
"# echo \"event-BUILD: standard PROOF node\"\n");
3311 fprintf(f,
"# fi\n");
3313 fprintf(f,
"if [ \"\" = \"clean\" ]; then\n");
3314 fprintf(f,
" make distclean\n");
3315 fprintf(f,
" exit 0\n");
3318 fprintf(f,
"make\n");
3319 fprintf(f,
"rc=$?\n");
3320 fprintf(f,
"echo \"rc=$?\"\n");
3321 fprintf(f,
"if [ $? != \"0\" ] ; then\n");
3322 fprintf(f,
" exit 1\n");
3324 fprintf(f,
"exit 0\n");
3330 path.
Form(
"%s/SETUP.C", proofinf);
3332 f = fopen(path.
Data(),
"wb");
3334 f = fopen(path.
Data(),
"w");
3337 Error(
"MakeProjectParProofInf",
"cannot create file '%s' (errno: %d)",
3342 fprintf(f,
"Int_t SETUP()\n");
3346 fprintf(f,
"// The environment variables ROOTPROOFLITE and ROOTPROOFCLIENT can be used to\n");
3347 fprintf(f,
"// adapt the macro to the calling environment\n");
3349 fprintf(f,
"// if (gSystem->Getenv(\"ROOTPROOFLITE\")) {\n");
3350 fprintf(f,
"// Printf(\"event-SETUP: PROOF-Lite node (session has %%s workers)\",\n");
3351 fprintf(f,
"// gSystem->Getenv(\"ROOTPROOFLITE\"));\n");
3352 fprintf(f,
"// } else if (gSystem->Getenv(\"ROOTPROOFCLIENT\")) {\n");
3353 fprintf(f,
"// Printf(\"event-SETUP: PROOF client\");\n");
3354 fprintf(f,
"// } else {\n");
3355 fprintf(f,
"// Printf(\"event-SETUP: standard PROOF node\");\n");
3356 fprintf(f,
"// }\n");
3358 fprintf(f,
" if (gSystem->Load(\"lib%s\") == -1)\n", pack);
3359 fprintf(f,
" return -1;\n");
3360 fprintf(f,
" return 0;\n");
3381 TList *list = GetStreamerInfoList();
3389 if (
gDebug > 0)
Info(
"ReadStreamerInfo",
"called for file %s",GetName());
3393 Int_t version = fVersion;
3394 if (version > 1000000) version -= 1000000;
3395 if (version < 53419 || (59900 < version && version < 59907)) {
3410 if (!base)
continue;
3422 for (
int mode=0;mode<2; ++mode) {
3435 if (strcmp(obj->
GetName(),
"listOfRules")==0) {
3443 rulelnk = rulelnk->
Next();
3447 Warning(
"ReadStreamerInfo",
"%s has a %s in the list of TStreamerInfo.", GetName(), info->IsA()->
GetName());
3457 Warning(
"ReadStreamerInfo",
"The StreamerInfo for %s does not have a list of elements.",info->
GetName());
3462 Bool_t isstl = element && strcmp(
"This",element->
GetName())==0;
3464 if ( (!isstl && mode ==0) || (isstl && mode ==1) ) {
3469 Int_t asize = fClassIndex->GetSize();
3470 if (uid >= asize && uid <100000) fClassIndex->Set(2*asize);
3471 if (uid >= 0 && uid < fClassIndex->GetSize()) fClassIndex->fArray[uid] = 1;
3473 printf(
"ReadStreamerInfo, class:%s, illegal uid=%d\n",info->
GetName(),uid);
3480 fClassIndex->fArray[0] = 0;
3498 fgReadInfo = readinfo;
3516 TList *list = GetStreamerInfoList();
3531 TObjArray *pids = GetListOfProcessIDs();
3532 Int_t npids = GetNProcessIDs();
3533 for (
Int_t i=0;i<npids;i++) {
3541 snprintf(name,32,
"ProcessID%d",npids);
3542 this->WriteTObject(pid,name);
3543 this->IncrementProcessIDs();
3545 Info(
"WriteProcessID",
"name=%s, file=%s", name, GetName());
3559 if (!fWritable)
return;
3560 if (!fClassIndex)
return;
3561 if (fIsPcmFile)
return;
3563 if (fClassIndex->fArray[0] == 0)
return;
3564 if (
gDebug > 0)
Info(
"WriteStreamerInfo",
"called for file %s",GetName());
3574 listOfRules.
SetName(
"listOfRules");
3575 std::set<TClass*> classSet;
3579 Int_t uid = info->GetNumber();
3580 if (fClassIndex->fArray[uid]) {
3582 if (
gDebug > 0) printf(
" -class: %s info number %d saved\n",info->GetName(),uid);
3587 if (clinfo && clinfo->GetSchemaRules()) {
3588 if ( classSet.find( clinfo ) == classSet.end() ) {
3589 if (
gDebug > 0) printf(
" -class: %s stored the I/O customization rules\n",info->GetName());
3595 rule->AsString(obj->
String());
3596 listOfRules.
Add(obj);
3598 classSet.insert(clinfo);
3605 fClassIndex->fArray[0] = 2;
3609 list.
Add(&listOfRules);
3613 Int_t compress = fCompress;
3617 if (fSeekInfo) MakeFree(fSeekInfo,fSeekInfo+fNbytesInfo-1);
3619 TKey key(&list,
"StreamerInfo",GetBestBuffer(),
this);
3620 fKeys->Remove(&key);
3626 fClassIndex->fArray[0] = 0;
3627 fCompress = compress;
3644 if (fgCacheFileDir ==
"") {
3646 "you want to read through a cache, but you have no valid cache " 3647 "directory set - reading remotely");
3648 ::Info(
"TFile::OpenFromCache",
"set cache directory using TFile::SetCacheFileDir()");
3655 if (!fgCacheFileForce)
3657 "you want to read through a cache, but you are reading " 3658 "local files - CACHEREAD disabled");
3664 cachefilepath = fgCacheFileDir;
3665 cachefilepath += fileurl.
GetFile();
3669 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I " 3670 "cannot create the directory %s - CACHEREAD disabled",
3671 cachefilepathbasedir.
Data());
3676 cachefilepath +=
"__";
3680 if (strstr(
name,
"zip=")) {
3685 Int_t optioncount = 0;
3694 if (optioncount!=0) {
3699 newoptions +=
value;
3709 cachefilepath +=
"__";
3710 cachefilepath += zipname;
3723 if (!fgCacheFileDisconnected) {
3724 char cacheblock[256];
3725 char remotblock[256];
3728 cfurl = cachefilepath;
3729 cfurl +=
"?filetype=raw";
3732 ropt +=
"&filetype=raw";
3735 Bool_t forcedcache = fgCacheFileForce;
3736 fgCacheFileForce =
kFALSE;
3741 fgCacheFileForce = forcedcache;
3745 ::Error(
"TFile::OpenFromCache",
3746 "cannot open the cache file to check cache consistency");
3751 ::Error(
"TFile::OpenFromCache",
3752 "cannot open the remote file to check cache consistency");
3759 if ((!cachefile->
ReadBuffer(cacheblock,256)) &&
3761 if (memcmp(cacheblock, remotblock, 256)) {
3762 ::Warning(
"TFile::OpenFromCache",
"the header of the cache file " 3763 "differs from the remote file - forcing an update");
3767 ::Warning(
"TFile::OpenFromCache",
"the header of the cache and/or " 3768 "remote file are not readable - forcing an update");
3780 Bool_t forcedcache = fgCacheFileForce;
3781 fgCacheFileForce =
kFALSE;
3783 ::Warning(
"TFile::OpenFromCache",
"you want to read through a cache, but I " 3784 "cannot make a cache copy of %s - CACHEREAD disabled",
3785 cachefilepathbasedir.
Data());
3786 fgCacheFileForce = forcedcache;
3787 if (fgOpenTimeout != 0)
3790 fgCacheFileForce = forcedcache;
3791 ::Info(
"TFile::OpenFromCache",
"using local cache copy of %s [%s]",
3795 fileurl.
SetFile(cachefilepath);
3799 tagfile = cachefilepath;
3800 tagfile +=
".ROOT.cachefile";
3854 if (!url || strlen(url) <= 0) {
3855 ::Error(
"TFile::Open",
"no url specified");
3868 TString sto = opts(ito + strlen(
"TIMEOUT="), opts.
Length());
3873 if (
gDebug > 0)
::Info(
"TFile::Open",
"timeout of %d millisec requested", toms);
3875 sto.
Insert(0,
"TIMEOUT=");
3893 ::Info(
"TFile::Open",
"waited %d millisec for asynchronous open", toms - xtms);
3895 ::Info(
"TFile::Open",
"timeout option not supported (requires asynchronous" 3900 ::Error(
"TFile::Open",
"timeout expired while opening '%s'", expandedUrl.
Data());
3907 ::Warning(
"TFile::Open",
"incomplete 'TIMEOUT=' option specification - ignored");
3913 const char *option = opts;
3916 TString namelist(expandedUrl);
3933 while (namelist.
Tokenize(n, from,
"|") && !
f) {
3936 if (!strcasecmp(option,
"CACHEREAD") ||
3937 ((!strcasecmp(option,
"READ") || !option[0]) && fgCacheFileForce)) {
3943 IncrementFileCounter();
3950 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
3951 TIter nxr(fgAsyncOpenRequests);
3959 if (urlOptions.BeginsWith(
"pmerge") || urlOptions.Contains(
"&pmerge") || urlOptions.Contains(
" pmerge")) {
3970 if (
type == kLocal) {
3976 lfname = urlname.
GetUrl();
3978 f =
new TFile(lfname.
Data(), option, ftitle, compress);
3980 }
else if (
type == kNet) {
3983 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFile", name))) {
3989 }
else if (
type == kWeb) {
3992 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFile", name))) {
3998 }
else if (
type == kFile) {
4001 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFile", name)) &&
4006 f =
new TFile(name.
Data(), option, ftitle, compress);
4011 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFile", name.
Data()))) {
4033 f =
TFile::Open( newUrl, option, ftitle, compress );
4051 if (
type != kLocal &&
type != kFile &&
4096 if (!url || strlen(url) <= 0) {
4097 ::Error(
"TFile::AsyncOpen",
"no url specified");
4109 TString outf =
".TFileAsyncOpen_";
4120 while (namelist.
Tokenize(n, from,
"|") && !
f) {
4133 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFile", name)) &&
4134 (!strcmp(h->
GetClass(),
"TXNetFile") || !strcmp(h->
GetClass(),
"TNetXNGFile"))
4140 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TFile", name)) &&
4152 if (!notfound && !f)
4172 if (!fgAsyncOpenRequests)
4173 fgAsyncOpenRequests =
new TList;
4174 fgAsyncOpenRequests->
Add(fh);
4192 if (fh && fgAsyncOpenRequests) {
4195 fgAsyncOpenRequests->
Remove(fh);
4223 #if defined(R__WINGCC) 4227 #elif defined(R__SEEK64) 4228 return ::open64(pathname, flags, mode);
4239 if (fd < 0)
return 0;
4267 #if defined (R__SEEK64) 4268 return ::lseek64(fd, offset, whence);
4269 #elif defined(WIN32) 4270 return ::_lseeki64(fd, offset, whence);
4272 return ::lseek(fd, offset, whence);
4294 if (TestBit(kDevNull))
return 0;
4299 return ::_commit(fd);
4308 return fCacheWrite ? fCacheWrite->GetBytesInCache() + fBytesWrite : fBytesWrite;
4325 return fgBytesWrite;
4341 return fgReadaheadSize;
4377 ::Error(
"TFile::SetCacheFileDir",
"no sufficient permissions on cache directory %s or cannot create it", cachedir);
4378 fgCacheFileDir =
"";
4385 fgCacheFileDir = cached;
4386 fgCacheFileDisconnected = operatedisconnected;
4387 fgCacheFileForce = forcecacheread;
4396 return fgCacheFileDir;
4408 if (fgCacheFileDir ==
"") {
4418 TString cachetagfile = fgCacheFileDir;
4419 cachetagfile +=
".tag.ROOT.cache";
4423 if (lastcleanuptime < cleanupinterval) {
4424 ::Info(
"TFile::ShrinkCacheFileDir",
"clean-up is skipped - last cleanup %lu seconds ago - you requested %lu", lastcleanuptime, cleanupinterval);
4430 cachetagfile +=
"?filetype=raw";
4433 if (!(tagfile =
TFile::Open(cachetagfile,
"RECREATE"))) {
4434 ::Error(
"TFile::ShrinkCacheFileDir",
"cannot create the cache tag file %s", cachetagfile.
Data());
4442 #if defined(R__WIN32) 4443 cmd =
"echo <TFile::ShrinkCacheFileDir>: cleanup to be implemented";
4444 #elif defined(R__MACOSX) 4445 cmd.
Format(
"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);
4447 cmd.
Format(
"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);
4454 ::Error(
"TFile::ShrinkCacheFileDir",
"error executing clean-up script");
4466 UInt_t to = fgOpenTimeout;
4467 fgOpenTimeout = timeout;
4476 return fgOpenTimeout;
4487 fgOnlyStaged = onlystaged;
4496 return fgOnlyStaged;
4512 if (!strcmp(u.
GetFile(), fUrl.GetFile())) {
4514 if (u.
GetPort() == fUrl.GetPort()) {
4515 if (!strcmp(u.
GetHostFQDN(), fUrl.GetHostFQDN())) {
4533 return fFile->Matches(url);
4534 }
else if (fName.Length() > 0){
4566 if (re.
Match(name)) {
4584 forceRemote =
kTRUE;
4585 else if (opts.
Contains(
"remote=0"))
4594 if (fname[0] ==
'/') {
4596 lfname.
Form(
"%s%s", prefix->
Data(), fname);
4599 }
else if (fname[0] ==
'~' || fname[0] ==
'$') {
4617 if (localFile && prefix)
4623 type = (localFile) ? kLocal : type;
4624 }
else if (
TPMERegexp(
"^(http[s]?|s3http[s]?|[a]?s3|gs|gshttp[s]?){1}:",
"i").
Match(name)) {
4628 }
else if (!strncmp(name,
"file:", 5)) {
4643 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
4644 TIter nxr(fgAsyncOpenRequests);
4654 if (of && (of->
GetSize() > 0)) {
4657 while ((f = (
TFile *)nxf()))
4663 return kAOSNotAsync;
4671 if (handle && handle->
fFile) {
4689 if (fgAsyncOpenRequests && (fgAsyncOpenRequests->GetSize() > 0)) {
4690 TIter nxr(fgAsyncOpenRequests);
4701 if (of && (of->
GetSize() > 0)) {
4704 while ((f = (
TFile *)nxf()))
4710 return (
const TUrl *)0;
4718 fprintf(stderr,
"[TFile::Cp] Total %.02f MB\t|", (
Double_t)size/1048576);
4720 for (
int l = 0;
l < 20;
l++) {
4722 if (
l < 20*bytesread/size)
4723 fprintf(stderr,
"=");
4724 else if (
l == 20*bytesread/size)
4725 fprintf(stderr,
">");
4726 else if (
l > 20*bytesread/size)
4727 fprintf(stderr,
".");
4729 fprintf(stderr,
"=");
4735 fprintf(stderr,
"| %.02f %% [%.01f MB/s]\r",
4736 100.0*(size?(bytesread/((
float)size)):1), (lCopy_time>0.)?bytesread/lCopy_time/1048576.:0.);
4760 if (opt !=
"") opt +=
"&";
4769 char *copybuffer = 0;
4771 TFile *sfile =
this;
4788 ::Error(
"TFile::Cp",
"cannot open destination file %s", dst);
4794 rmdestiferror =
kTRUE;
4799 copybuffer =
new char[buffersize];
4801 ::Error(
"TFile::Cp",
"cannot allocate the copy buffer");
4819 if (progressbar) CpProgress(totalread, filesize,watch);
4824 if (filesize - b1 > (
Long64_t)buffersize) {
4825 readsize = buffersize;
4827 readsize = filesize - b1;
4830 if (readsize == 0)
break;
4836 if ((read <= 0) || readop) {
4837 ::Error(
"TFile::Cp",
"cannot read from source file %s. readsize=%lld read=%lld readop=%d",
4845 if ((written != read) || writeop) {
4846 ::Error(
"TFile::Cp",
"cannot write %lld bytes to destination file %s", read, dst);
4850 }
while (read == (
Long64_t)buffersize);
4853 CpProgress(totalread, filesize,watch);
4854 fprintf(stderr,
"\n");
4860 if (dfile) dfile->
Close();
4862 if (dfile)
delete dfile;
4863 if (copybuffer)
delete[] copybuffer;
4865 if (rmdestiferror && (success !=
kTRUE))
4888 if (opt !=
"") opt +=
"&";
4894 opt +=
TString::Format(
"&cachesz=%d&readaheadsz=%d&rmpolicy=1", 4*buffersize, 2*buffersize);
4903 ::Error(
"TFile::Cp",
"cannot open source file %s", src);
4905 success = sfile->
Cp(dst, progressbar, buffersize);
4908 if (sfile) sfile->
Close();
4909 if (sfile)
delete sfile;
4918 #if defined(R__neverLINUX) && !defined(R__WINGCC) 4930 int advice = POSIX_FADV_WILLNEED;
4935 advice = POSIX_FADV_NORMAL;
4939 #if defined(R__SEEK64) 4940 Int_t result = posix_fadvise64(fD, offset, len, advice);
4942 Int_t result = posix_fadvise(fD, offset, len, advice);
4947 return (result != 0);
4967 if ((cr = GetCacheRead())) {
4969 return ((bytes < 0) ? 0 : bytes);
virtual Bool_t SendFileCloseEvent(TFile *)
virtual void Map()
List the contents of a file sequentially.
Describe Streamer information for one class version.
virtual Bool_t SendFileWriteProgress(TFile *)
void SetFile(const char *file)
virtual Int_t Sizeof() const
Return the size in bytes of the directory header.
static TProcessID * GetPID()
static: returns pointer to current TProcessID
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetName() const
Returns name of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
double read(const std::string &file_name)
reading
void frombuf(char *&buf, Bool_t *x)
virtual void DrawMap(const char *keys="*", Option_t *option="")
Draw map of objects in this file.
virtual Int_t Recover()
Attempt to recover file if not correctly closed.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
const char * GetArchiveName() const
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Return file stat information.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual const char * GetFlagsOpt() const
Return the optimization flags.
int GetErrno()
return errno
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
static Bool_t AddRule(const char *rule)
Add a schema evolution customization rule.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
EAsyncOpenStatus
Asynchronous open request status.
virtual const char * WorkingDirectory()
Return working directory.
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
double write(int n, const std::string &file_name, const std::string &vector_type, int compress=0)
writing
virtual void FillBuffer(char *&buffer)
Encode file output buffer.
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
void Fatal(const char *location, const char *msgfmt,...)
Collectable string class.
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
Bool_t Matches(const char *name)
Return kTRUE if this async request matches the open request specified by 'url'.
static void IncrementFileCounter()
virtual void ReadFree()
Read the FREE linked list.
A cache when reading files over the network.
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the splited type.
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
T ReadBuffer(TBufferFile *buf)
One of the template functions used to read objects from messages.
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
This class represents a WWW compatible URL.
virtual char * GetBuffer() const
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void RemoveLast()
Remove the last object of the list.
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
Creates key for object and converts data to buffer.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Class holding info about the file being opened.
const char * GetProtocol() const
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
virtual const char * GetClassName() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
static void SetFileReadCalls(Int_t readcalls=0)
virtual Int_t GetEntries() const
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
Bool_t HasInterpreterInfo() const
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
static TArchiveFile * Open(const char *url, TFile *file)
Return proper archive file handler depending on passed url.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Long64_t GetBytesWritten() const
Return the total number of bytes written so far to the file.
Int_t LoadPlugin()
Load the plugin library for this handler.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Try to shrink the cache to the desired size.
virtual Int_t Sizeof() const
Return size of the TNamed part of the TObject.
void ToLower()
Change string to lower-case.
virtual void FillBuffer(char *&buffer)
Encode TNamed into output buffer.
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Iterator of object array.
R__EXTERN TVirtualMutex * gROOTMutex
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
virtual const char * GetSoExt() const
Get the shared library extension.
const char * GetOptions() const
Int_t GenerateHeaderFile(const char *dirname, const TList *subClasses=0, const TList *extrainfos=0)
Generate header file for the class described by this TStreamerInfo the function is called by TFile::M...
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsize=0)
Write all objects in memory to disk.
Type GetType(const std::string &Name)
virtual const char * GetFlagsDebug() const
Return the debug flags.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
TObject * At(Int_t idx) const
virtual void IgnoreInterrupt(Bool_t ignore=kTRUE)
If ignore is true ignore the interrupt signal, else restore previous behaviour.
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
Specify if the streamerinfos must be read at file opening.
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
static void SetReadaheadSize(Int_t bufsize=256000)
TString & Insert(Ssiz_t pos, const char *s)
virtual void FillBuffer(char *&buffer)
Encode directory header into output buffer.
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void SysError(const char *location, const char *msgfmt,...)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
virtual void FillBuffer(char *&buffer)
Encode fre structure into output buffer.
static Int_t GetErrno()
Static function returning system error number.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
TFree * AddFree(TList *lfree, Long64_t first, Long64_t last)
Add a new free segment to the list of free segments.
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
static void SetFileBytesWritten(Long64_t bytes=0)
const char * GetFile() const
virtual Int_t GetErrno() const
Method returning errno. Is overriden in TRFIOFile.
static TObjArray * GetPIDs()
static: returns array of TProcessIDs
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
virtual Int_t GetClassVersion() const =0
Sequenceable collection abstract base class.
virtual void ResetErrno() const
Method resetting the errno. Is overridden in TRFIOFile.
void Stop()
Stop the stopwatch.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual FILE * TempFileName(TString &base, const char *dir=0)
Create a secure temporary file by appending a unique 6 letter string to base.
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
static Bool_t GetReadStreamerInfo()
If the streamerinfos are to be read at file opening.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual void SetCompressionLevel(Int_t level=1)
See comments for function SetCompressionSettings.
virtual void MakeProject(const char *dirname, const char *classes="*", Option_t *option="new")
Generate source code necessary to access the objects stored in the file.
virtual void WriteFree()
Write FREE linked list on the file.
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=0)
Resolve the file type as a function of the protocol field in 'name'.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
static TFile * OpenFromCache(const char *name, Option_t *="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Open a file for reading through the file cache.
void Clear()
Clear string without changing its capacity.
static void GetDateTime(UInt_t datetime, Int_t &date, Int_t &time)
Static function that returns the date and time.
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
virtual Int_t WriteFile(Int_t cycle=1, TFile *f=0)
Write the encoded object supported by this key.
void Info(const char *location, const char *msgfmt,...)
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
TString & Append(const char *cs)
std::vector< std::vector< double > > Data
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const std::string ClassName(PyObject *pyobj)
Retrieve the class name from the given python object (which may be just an instance of the class)...
const char * GetAnchor() const
void tobuf(char *&buf, Bool_t x)
void Continue()
Resume a stopped stopwatch.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
A TProcessID identifies a ROOT job in a unique way in time and space.
virtual TString GetNewUrl()
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TPluginManager * gPluginMgr
virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write().
void MayNotUse(const char *method)
This function can be used in classes that should override a certain function, but in the inherited cl...
virtual Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen)
Read the logical record header starting at a certain postion.
virtual void ls(Option_t *option="") const
List Directory contents.
virtual Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
virtual void ShowStreamerInfo()
Show the StreamerInfo of all classes written to this file.
virtual Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read().
const char * GetOpt() const
void ResetErrno()
reset errno
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
TClass * GetClass() const
R__EXTERN TSystem * gSystem
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open().
UInt_t GetCheckSum() const
virtual void WriteStreamerInfo()
Write the list of TStreamerInfo as a single object in this file The class Streamer description for al...
A ROOT file is structured in Directories (like a file system).
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
Long_t ExecPlugin(int nargs, const T &... params)
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void Delete(const char *namecycle="")
Delete object namecycle.
void SetBaseCheckSum(UInt_t cs)
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
const TMatches FindRules(const TString &source) const
Return all the rules that are about the given 'source' class.
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Int_t IncrementCount()
Increase the reference count to this object.
virtual Bool_t ReadFile()
Read the key structure from the file.
virtual void MakeFree(Long64_t first, Long64_t last)
Mark unused bytes on the file.
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
Int_t DecrementCount()
The reference fCount is used to delete the TProcessID in the TFile destructor when fCount = 0...
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
Print file copy progress.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
The ROOT global object gROOT contains a list of all defined classes.
virtual void Draw(Option_t *option="")
Fill Graphics Structure and Paint.
virtual void Delete(const char *namecycle="")
Delete Objects or/and keys in a directory.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual TList * GetStreamerInfoList()
Read the list of TStreamerInfo objects written to this file.
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
void Build(TFile *motherFile=0, TDirectory *motherDir=0)
Initialise directory to defaults.
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
virtual const char * GetMakeSharedLib() const
Return the command line use to make a shared library.
void SetName(const char *name)
virtual TObject * ReadObjWithBuffer(char *bufferRead)
To read a TObject* from bufferRead.
void Warning(const char *location, const char *msgfmt,...)
virtual void Init(Bool_t create)
Initialize a TFile object.
Long64_t GetFirst() const
virtual void FreeDirectory(void *dirp)
Free a directory.
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
static TFile *& CurrentFile()
Return the current ROOT file if any.
virtual TObjLink * FirstLink() const
Option_t * GetOption() const
#define R__LOCKGUARD2(mutex)
static void GenerateMissingStreamerInfos(TList *extrainfos, TStreamerElement *element)
Generate an empty StreamerInfo for types that are used in templates parameters but are not known in t...
virtual Long64_t GetBytesRead() const
virtual void ReadBuffer(char *&buffer)
Decode one free structure from input buffer.
static Bool_t fgOnlyStaged
Before the file is opened, it is checked, that the file is staged, if not, the open fails...
static Bool_t GetOnlyStaged()
Returns staged only flag.
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
virtual Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=0)
Redirect standard output (stdout, stderr) to the specified file.
void CheckInit()
Initialize fObjects.
void SetHost(const char *host)
TString & Remove(Ssiz_t pos)
TFile()
File default Constructor.
static void Add(TGlobalMappedFunction *gmf)
virtual int Chmod(const char *file, UInt_t mode)
Set the file permission bits. Returns -1 in case or error, 0 otherwise.
Version_t GetClassVersion() const
void ReadKeyBuffer(char *&buffer)
Decode input buffer.
void SetAnchor(const char *anchor)
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
virtual const char * GetIncludePath()
Get the list of include path.
TObject * UncheckedAt(Int_t i) const
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
void Print(std::ostream &os, const OptionType &opt)
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
TFile * fFile
TFile instance of the file being opened.
Int_t Sizeof() const
return number of bytes occupied by this TFree on permanent storage
virtual Int_t ReadKeys(Bool_t forceRead=kTRUE)
Read the linked list of keys.
virtual Long64_t GetSeekKey() const
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Describe directory structure in memory.
Wrapper around a TObject so it can be stored in a TList.
TFileCacheWrite * GetCacheWrite() const
Return a pointer to the current write cache.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
virtual void Clear(Option_t *option="")
delete the TObjArray pointing to referenced objects this function is called by TFile::Close("R") ...
virtual Int_t GetBufferSize() const
Int_t IndexOf(const TObject *obj) const
virtual Long64_t GetSize() const
Returns the current file size.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
The TTimeStamp encapsulates seconds and ns since EPOCH.
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
static TProcessID * GetSessionProcessID()
static function returning the pointer to the session TProcessID
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Float_t GetCompressionFactor()
Return the file compression factor.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Int_t GetCompress() const
virtual Bool_t SendFileReadProgress(TFile *)
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
virtual void AddAfter(const TObject *after, TObject *obj)
Insert object after object after in the list.
const TList * GetStreamerInfoCache()
Returns the cached list of StreamerInfos used in this file.
Mother of all ROOT objects.
TObjArray * GetElements() const
Bool_t FlushWriteCache()
Flush the write cache if active.
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Sets only staged flag.
virtual void Paint(Option_t *option="")
Paint all objects in the file.
virtual void SetCompressionSettings(Int_t settings=1)
Used to specify the compression level and algorithm.
TObject * GetObject() const
static TString fgCacheFileDir
Directory where to locally stage files.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Int_t GetClassVersion() const
virtual const TUrl * GetEndpointUrl() const
static TString UpdateAssociativeToVector(const char *name)
If we have a map, multimap, set or multiset, plus unordered partners, and the key is a class...
RooCmdArg Save(Bool_t flag=kTRUE)
void BuildCheck(TFile *file=0)
Check if built and consistent with the class dictionary.
virtual ~TFile()
File destructor.
Bool_t R_ISDIR(Int_t mode)
static TFileOpenHandle * AsyncOpen(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Submit an asynchronous open request.
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
virtual void Add(TObject *obj)
Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir)
Create BUILD.sh and SETUP.C under 'proofinf' for PAR package 'pack'.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
virtual void ShowOutput(RedirectHandle_t *h)
Display the content associated with the redirection described by the opaque handle 'h'...
virtual void Print(Option_t *option="") const
Print all objects in the file.
virtual UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pidd is already in the file, if not, add it and return the index number in the...
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
void SetOptions(const char *opt)
virtual Int_t Sizeof() const
Return the size in bytes of the file header.
static UInt_t SetOpenTimeout(UInt_t timeout)
Sets open timeout time (in ms). Returns previous timeout value.
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual void SetCompressionAlgorithm(Int_t algorithm=0)
See comments for function SetCompressionSettings.
Int_t Atoi() const
Return integer value of string.
TFileCacheRead * GetCacheRead(TObject *tree=0) const
Return a pointer to the current read cache.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
static void ResetErrno()
Static function resetting system error number.
const ROOT::Detail::TSchemaRuleSet * GetSchemaRules() const
Return the set of the schema rules if any.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
static Int_t fgReadaheadSize
Readahead buffer size.
virtual void WriteHeader()
Write File Header.
Bool_t IsWritable() const
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
virtual void Close(Option_t *option="")
Close out any threads or asynchronous fetches used by the underlying implementation.
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetSize() const
Abstract Interface class describing Streamer information for one class.
static void SetFileBytesRead(Long64_t bytes=0)
virtual void ls(Option_t *option="") const
List file contents.
static Long64_t GetFileCounter()
virtual void SetCacheWrite(TFileCacheWrite *cache)
Set a pointer to the write cache.
virtual const char * GetObjExt() const
Get the object file extension.
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
virtual TProcessID * ReadProcessID(UShort_t pidf)
The TProcessID with number pidf is read from this file.
A cache when writing files over the network.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
virtual const char * GetTitle() const
Returns title of object.
Int_t MakeProjectParMake(const char *packname, const char *filename)
Create makefile at 'filemake' for PAR package 'pack'.
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
virtual void Close(Option_t *option="")
Close a file.
virtual Bool_t Matches(const char *name)
Return kTRUE if 'url' matches the coordinates of this file.
const char * Data() const
Array of chars or bytes (8 bits per element).
ECacheAction
TTreeCache flushing semantics.
const char * GetClass() const
virtual EAsyncOpenStatus GetAsyncOpenStatus()