Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TDCacheFile.cxx
Go to the documentation of this file.
1// @(#)root/dcache:$Id$
2// Author: Grzegorz Mazur 20/01/2002
3// Modified: William Tanenbaum 01/12/2003
4// Modified: Tigran Mkrtchyan 29/06/2004
5// Modified: Tigran Mkrtchyan 06/07/2007
6
7/*************************************************************************
8 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15/**
16\class TDCacheFile
17\ingroup IO
18A TDCacheFile is like a normal TFile except that it may read and
19write its data via a dCache server (for more on the dCache daemon
20see http://www-dcache.desy.de/. Given a path which doesn't belong
21to the dCache managed filesystem, it falls back to the ordinary
22TFile behaviour.
23*/
24
25#include "TDCacheFile.h"
26#include "TError.h"
27#include "TSystem.h"
28#include "TROOT.h"
29
30#include <cstdlib>
31#include <errno.h>
32#include <sys/stat.h>
33#include <sys/types.h>
34
35#include <dcap.h>
36#ifndef R__WIN32
37#include <unistd.h>
38#if defined(R__SUN) || defined(R__HPUX) || \
39 defined(R__AIX) || defined(R__LINUX) || defined(R__SOLARIS) || \
40 defined(R__HIUX) || defined(R__FBSD) || defined(R__MACOSX) || \
41 defined(R__HURD) || defined(R__OBSD)
42#define HAS_DIRENT
43#endif
44#endif
45
46#ifdef HAS_DIRENT
47#include <dirent.h>
48#endif
49
50static const char* const DCACHE_PREFIX = "dcache:";
51static const size_t DCACHE_PREFIX_LEN = strlen(DCACHE_PREFIX);
52static const char* const DCAP_PREFIX = "dcap:";
53static const size_t DCAP_PREFIX_LEN = strlen(DCAP_PREFIX);
54
55
57
58////////////////////////////////////////////////////////////////////////////////
59/// Create a dCache file object.
60///
61/// A dCache file is the same as a TFile
62/// except that it is being accessed via a dCache server. The url
63/// argument must be of the form: `dcache:/pnfs/<path>/<file>.root` or
64/// `dcap://<nodename.org>/<path>/<file>.root`. If the file specified in the
65/// URL does not exist, is not accessable or can not be created the kZombie
66/// bit will be set in the TDCacheFile object. Use IsZombie() to see if the
67/// file is accessable. For a description of the option and other arguments
68/// see the TFile ctor. The preferred interface to this constructor is
69/// via TFile::Open().
70
72 const char *ftitle, Int_t compress):
73 TFile(path, "NET", ftitle, compress)
74{
75 TString pathString = GetDcapPath(path);
76 path = pathString.Data();
77
81
82 if (fOption == "NEW")
83 fOption = "CREATE";
84
85 Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
86 Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
87 Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
88 Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
89 if (!create && !recreate && !update && !read) {
90 read = kTRUE;
91 fOption = "READ";
92 }
93
94 TString stmp;
95 TString stmp2;
96 const char *fname;
97 const char *fnameWithPrefix;
98
99 if (!strncmp(path, DCAP_PREFIX, DCAP_PREFIX_LEN)) {
100 fnameWithPrefix = fname = path;
101 } else {
102 // Metadata provided by PNFS
103 char *tname;
104 if ((tname = gSystem->ExpandPathName(path))) {
105 stmp = tname;
106 stmp2 = DCACHE_PREFIX;
107 stmp2 += tname;
108 delete [] tname;
109 fname = stmp;
110 fnameWithPrefix = stmp2;
111 } else {
112 Error("TDCacheFile", "error expanding path %s", path);
113 goto zombie;
114 }
115 }
116
117 if (recreate) {
118 if (!gSystem->AccessPathName(fnameWithPrefix, kFileExists))
119 dc_unlink(fname);
120 recreate = kFALSE;
121 create = kTRUE;
122 fOption = "CREATE";
123 }
124 if (create && !gSystem->AccessPathName(fnameWithPrefix, kFileExists)) {
125 Error("TDCacheFile", "file %s already exists", fname);
126 goto zombie;
127 }
128 if (update) {
129 if (gSystem->AccessPathName(fnameWithPrefix, kFileExists)) {
130 update = kFALSE;
131 create = kTRUE;
132 }
133 if (update && gSystem->AccessPathName(fnameWithPrefix, kWritePermission)) {
134 Error("TDCacheFile", "no write permission, could not open file %s", fname);
135 goto zombie;
136 }
137 }
138
139 // Connect to file system stream
140 fRealName = fname;
141
142 if (create || update) {
143#ifndef WIN32
144 fD = SysOpen(fname, O_RDWR | O_CREAT, 0644);
145#else
146 fD = SysOpen(fname, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
147#endif
148 if (fD == -1) {
149 SysError("TDCacheFile", "file %s can not be opened", fname);
150 goto zombie;
151 }
153 } else {
154#ifndef WIN32
155 fD = SysOpen(fname, O_RDONLY, 0644);
156#else
157 fD = SysOpen(fname, O_RDONLY | O_BINARY, S_IREAD | S_IWRITE);
158#endif
159 if (fD == -1) {
160 if (gSystem->AccessPathName(fnameWithPrefix, kFileExists)) {
161 Error("TDCacheFile", "file %s does not exist", fname);
162 goto zombie;
163 }
164 if (gSystem->AccessPathName(fnameWithPrefix, kReadPermission)) {
165 Error("TDCacheFile", "no read permission, could not open file %s", fname);
166 goto zombie;
167 }
168 SysError("TDCacheFile", "file %s can not be opened for reading", fname);
169 goto zombie;
170 }
172 }
173
174 // use 128K ( default ) read-ahead buffer to get file header,
175 // the buffer size can be overriden by env var "DCACHE_RA_BUFFER",
176 // vector read are not affected by read-ahead buffer
177 if (read) {
178 int dcache_RAHEAD_SIZE = RAHEAD_BUFFER_SIZE;
179 const char *DCACHE_RA_BUFFER = gSystem->Getenv("DCACHE_RA_BUFFER");
180 if (DCACHE_RA_BUFFER) {
181 int ra_buffer = atoi(DCACHE_RA_BUFFER);
182 dcache_RAHEAD_SIZE = ra_buffer<=0 ? dcache_RAHEAD_SIZE : ra_buffer;
183 }
184 dc_setBufferSize(fD, dcache_RAHEAD_SIZE);
185 } else {
186 dc_noBuffering(fD);
187 }
188
189 Init(create);
190
191 return;
192
193zombie:
194 // error in file opening occured, make this object a zombie
195 MakeZombie();
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Close and cleanup dCache file.
201
203{
204 Close();
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Read specified byte range from remote file via dCache daemon.
209/// Returns kTRUE in case of error.
210
212{
213 Int_t st;
214 if ((st = ReadBufferViaCache(buf, len))) {
215 if (st == 2)
216 return kTRUE;
217 return kFALSE;
218 }
219
220 return TFile::ReadBuffer(buf, len);
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Read specified byte range from remote file via dCache daemon.
225/// Returns kTRUE in case of error.
226
228{
229 SetOffset(pos);
230 Int_t st;
231 if ((st = ReadBufferViaCache(buf, len))) {
232 if (st == 2)
233 return kTRUE;
234 return kFALSE;
235 }
236
237 return TFile::ReadBuffer(buf, pos, len);
238}
239
240////////////////////////////////////////////////////////////////////////////////
241/// Read the nbuf blocks described in arrays pos and len,
242/// where pos[i] is the seek position of block i of length len[i].
243/// Note that for nbuf=1, this call is equivalent to TFile::ReafBuffer.
244/// This function is overloaded by TNetFile, TWebFile, etc.
245/// Returns kTRUE in case of failure.
246
248{
249#ifdef _IOVEC2_
250
251 iovec2 *vector;
252
253 vector = (iovec2 *)malloc(sizeof(iovec2)*nbuf);
254
255 Int_t total_len = 0;
256 for (Int_t i = 0; i < nbuf; i++) {
257 vector[i].buf = &buf[total_len];
258 vector[i].offset = pos[i] + fArchiveOffset;
259 vector[i].len = len[i];
260 total_len += len[i];
261 }
262
263 Int_t rc = dc_readv2(fD, vector, nbuf);
264 free(vector);
265
266 if (rc == 0) {
267 fBytesRead += total_len;
268 SetFileBytesRead(GetFileBytesRead() + total_len);
269 return kFALSE;
270 }
271
272#endif
273
274 // if we failed to get with dc_readv2 (old server), try to loop over
275
276 Int_t k = 0;
279 fCacheRead = 0;
280
281 Long64_t low = pos[0];
282 Long64_t high = pos[nbuf-1] + len[nbuf-1] - pos[0];
283
284 Long64_t total = 0;
285 for(Int_t j=0; j < nbuf; j++) {
286 total += len[j];
287 }
288
289 if ( total && high / total < 10 ) {
290
291 char *temp = new char[high];
292 Seek(low);
293 result = ReadBuffer(temp,high);
294
295 if (result==0) {
296 for (Int_t i = 0; i < nbuf; i++) {
297 memcpy(&buf[k], &(temp[pos[i]-pos[0]]), len[i]);
298 k += len[i];
299 }
300 }
301
302 delete [] temp;
303
304 } else {
305
306 for (Int_t i = 0; i < nbuf; i++) {
307 Seek(pos[i]);
308 result = ReadBuffer(&buf[k], len[i]);
309 if (result) break;
310 k += len[i];
311 }
312
313 }
314
315 fCacheRead = old;
316 return result;
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Write specified byte range to remote file via dCache daemon.
321/// Returns kTRUE in case of error.
322
324{
325 if (!IsOpen() || !fWritable) return kTRUE;
326
327 Int_t st;
328 if ((st = WriteBufferViaCache(buf, len))) {
329 if (st == 2)
330 return kTRUE;
331 return kFALSE;
332 }
333
334 return TFile::WriteBuffer(buf, len);
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Stage() returns kTRUE on success and kFALSE on failure.
339
340Bool_t TDCacheFile::Stage(const char *path, UInt_t after, const char *location)
341{
342 TString pathString = GetDcapPath(path);
343 path = pathString.Data();
344
345 dc_errno = 0;
346
347 if (dc_stage(path, after, location) == 0)
348 return kTRUE;
349
350 if (dc_errno != 0)
351 gSystem->SetErrorStr(dc_strerror(dc_errno));
352
353 return kFALSE;
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// CheckFile() returns kTRUE on success and kFALSE on failure. In
358/// case the file exists but is not cached, CheckFile() returns
359/// kFALSE and errno is set to EAGAIN.
360
361Bool_t TDCacheFile::CheckFile(const char *path, const char *location)
362{
363 TString pathString = GetDcapPath(path);
364 path = pathString.Data();
365
366 dc_errno = 0;
367
368 if (dc_check(path, location) == 0)
369 return kTRUE;
370
371 if (dc_errno != 0)
372 gSystem->SetErrorStr(dc_strerror(dc_errno));
373
374 return kFALSE;
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Set file open timeout.
379
381{
382 dc_setOpenTimeout(n);
383}
384
385////////////////////////////////////////////////////////////////////////////////
386/// Set on error handler.
387
389{
390 dc_setOnError(a);
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Set reply host name.
395
396void TDCacheFile::SetReplyHostName(const char *host_name)
397{
398 dc_setReplyHostName((char*)host_name);
399}
400
401////////////////////////////////////////////////////////////////////////////////
402/// Return dCache version string.
403
405{
406 return getDcapVersion();
407}
408
409////////////////////////////////////////////////////////////////////////////////
410/// Interface to system open. All arguments like in POSIX open.
411
412Int_t TDCacheFile::SysOpen(const char *pathname, Int_t flags, UInt_t mode)
413{
414 // often there is a filewall on front of storage system.
415 // let clients connect to the data servers
416 // if it's an old dCache version, pool will try to connect to the client
417 // (if it's fine with firewall)
418
419 dc_setClientActive();
420
421 dc_errno = 0;
422
423 Int_t rc = dc_open(pathname, flags, (Int_t) mode);
424
425 if (rc < 0) {
426 if (dc_errno != 0)
427 gSystem->SetErrorStr(dc_strerror(dc_errno));
428 }
429
430 return rc;
431}
432
433////////////////////////////////////////////////////////////////////////////////
434/// Interface to system close. All arguments like in POSIX close.
435
437{
438 dc_errno = 0;
439
440 Int_t rc = dc_close(fd);
441
442 if (rc < 0) {
443 if (dc_errno != 0)
444 gSystem->SetErrorStr(dc_strerror(dc_errno));
445 }
446
447 return rc;
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Interface to system read. All arguments like in POSIX read.
452
454{
455 dc_errno = 0;
456
457 Int_t rc = dc_read(fd, buf, len);
458
459 if (rc < 0) {
460 if (dc_errno != 0)
461 gSystem->SetErrorStr(dc_strerror(dc_errno));
462 }
463
464 return rc;
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Interface to system write. All arguments like in POSIX write.
469
471{
472 dc_errno = 0;
473
474 Int_t rc = dc_write(fd, (char *)buf, len);
475
476 if (rc < 0) {
477 if (dc_errno != 0)
478 gSystem->SetErrorStr(dc_strerror(dc_errno));
479 }
480
481 return rc;
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Interface to system seek. All arguments like in POSIX lseek.
486
488{
489 dc_errno = 0;
490
491 Long64_t rc = dc_lseek64(fd, offset, whence);
492
493 if (rc < 0) {
494 if (dc_errno != 0)
495 gSystem->SetErrorStr(dc_strerror(dc_errno));
496 }
497
498 return rc;
499}
500
501////////////////////////////////////////////////////////////////////////////////
502/// Interface to system sync. All arguments like in POSIX fsync.
503/// dCache always keep it's files sync'ed, so there's no need to
504/// sync() them manually.
505
507{
508 Int_t rc;
509 dc_errno = 0;
510
511 rc = dc_fsync(fd);
512 if (rc < 0) {
513 if (dc_errno != 0)
514 gSystem->SetErrorStr(dc_strerror(dc_errno));
515 }
516
517 return rc;
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Get info about a file: id, size, flags, modification time.
522///
523/// \param[in] fd ignored
524/// \param[in] id (statbuf.st_dev << 24) + statbuf.st_ino
525/// \param[in] size The file size
526/// \param[in] flags File type: 0 is regular file, bit 0 set executable, bit 1 set directory, bit 2 set special file (socket, fifo, pipe, etc.)
527/// \param[in] modtime Modification time.
528/// The function returns 0 in case of success and 1 if the file could
529/// not be stat'ed.
530
532 Long_t *flags, Long_t *modtime)
533{
534 // If in read mode, uses the cached file status, if available, to avoid
535 // costly dc_stat() call.
536
537 struct stat64 & statbuf = fStatBuffer; // reference the cache
538
539 if (fOption != "READ" || !fStatCached) {
540 // We are not in read mode, or the file status information is not yet
541 // in the cache. Update or read the status information with dc_stat().
542
543 const char *path = GetName();
544 TString pathString = GetDcapPath(path);
545 path = pathString.Data();
546
547 if (path && (dc_stat64(path, &statbuf) >= 0)) {
549 }
550 }
551
552 if (fStatCached) {
553 if (id)
554 *id = (statbuf.st_dev << 24) + statbuf.st_ino;
555 if (size)
556 *size = statbuf.st_size;
557 if (modtime)
558 *modtime = statbuf.st_mtime;
559 if (flags) {
560 *flags = 0;
561 if (statbuf.st_mode & ((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6)))
562 *flags |= 1;
563 if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
564 *flags |= 2;
565 if ((statbuf.st_mode & S_IFMT) != S_IFREG &&
566 (statbuf.st_mode & S_IFMT) != S_IFDIR)
567 *flags |= 4;
568 }
569 return 0;
570 }
571 return 1;
572}
573
574////////////////////////////////////////////////////////////////////////////////
575/// Method resetting the dc_errno and errno.
576
578{
579 dc_errno = 0;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Transform the input path into a path usuable by the dcap C library,
585/// i.e either \a dcap://nodename.org/where/filename.root or
586/// \a /pnfs/where/filename.root
587
589{
590 // eat all 'dcache:' prefixes
591 while (!strncmp(path, DCACHE_PREFIX, DCACHE_PREFIX_LEN)) {
592 path += DCACHE_PREFIX_LEN;
593 }
594
595 TUrl url(path);
596 TString pathString(url.GetUrl());
597
598 // convert file://path url and dcap:///path to /path
599 if(!strncmp(url.GetProtocol(), "file", 4) || !strcmp(url.GetHost(),"")){
600 pathString = url.GetFile();
601 }
602
603 return pathString;
604}
605
606
607////////////////////////////////////////////////////////////////////////////////
608/// Create helper class that allows directory access via dCache.
609
610TDCacheSystem::TDCacheSystem() : TSystem("-DCache", "DCache Helper System")
611{
612 // name must start with '-' to bypass the TSystem singleton check
613 SetName("DCache");
614
615 fDirp = 0;
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Create a directory.
620
621int TDCacheSystem::MakeDirectory(const char *path)
622{
623 Int_t rc;
624 dc_errno = 0;
625 TString pathString = TDCacheFile::GetDcapPath(path);
626 path = pathString.Data();
627
628 rc = dc_mkdir(path, 0755);
629 if (rc < 0) {
630 if (dc_errno != 0)
631 gSystem->SetErrorStr(dc_strerror(dc_errno));
632 }
633
634 return rc;
635}
636
637////////////////////////////////////////////////////////////////////////////////
638/// Open a directory.
639
640void *TDCacheSystem::OpenDirectory(const char *path)
641{
642 dc_errno = 0;
643 TString pathString = TDCacheFile::GetDcapPath(path);
644 path = pathString.Data();
645
646 fDirp = dc_opendir(path);
647 if (fDirp == 0) {
648 if (dc_errno != 0)
649 gSystem->SetErrorStr(dc_strerror(dc_errno));
650 }
651
652 return fDirp;
653}
654
655////////////////////////////////////////////////////////////////////////////////
656/// Close a directory.
657
659{
660 Int_t rc;
661 dc_errno = 0;
662
663 rc = dc_closedir((DIR *)dirp);
664 if (rc < 0) {
665 if (dc_errno != 0)
666 gSystem->SetErrorStr(dc_strerror(dc_errno));
667 }
668
669 fDirp = 0;
670 return;
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Get a directory entry.
675
676const char *TDCacheSystem::GetDirEntry(void * dirp)
677{
678 struct dirent *ent;
679 dc_errno = 0;
680
681 ent = dc_readdir((DIR *)dirp);
682 if (ent == 0) {
683 if (dc_errno != 0)
684 gSystem->SetErrorStr(dc_strerror(dc_errno));
685 }
686
687 return !ent ? 0 : ent->d_name;
688}
689
690////////////////////////////////////////////////////////////////////////////////
691/// Returns FALSE if one can access a file using the specified access mode.
692/// Mode is the same as for the Unix access(2) function.
693/// Attention, bizarre convention of return value!!
694
696{
697 TString pathString = TDCacheFile::GetDcapPath(path);
698 path = pathString.Data();
699
700 return dc_access(path, mode);
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Get info about a file. Info is returned in the form of a FileStat_t
705/// structure (see TSystem.h).
706/// The function returns 0 in case of success and 1 if the file could
707/// not be stat'ed.
708
709int TDCacheSystem::GetPathInfo(const char *path, FileStat_t &buf)
710{
711 TString pathString = TDCacheFile::GetDcapPath(path);
712 path = pathString.Data();
713
714 struct stat64 sbuf;
715
716 if (path && (dc_stat64(path, &sbuf) >= 0)) {
717
718 buf.fDev = sbuf.st_dev;
719 buf.fIno = sbuf.st_ino;
720 buf.fMode = sbuf.st_mode;
721 buf.fUid = sbuf.st_uid;
722 buf.fGid = sbuf.st_gid;
723 buf.fSize = sbuf.st_size;
724 buf.fMtime = sbuf.st_mtime;
725 buf.fIsLink = kFALSE;
726
727 return 0;
728 }
729 return 1;
730}
#define a(i)
Definition RSha256.hxx:99
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
static const char *const DCACHE_PREFIX
static const size_t DCAP_PREFIX_LEN
static const size_t DCACHE_PREFIX_LEN
static const char *const DCAP_PREFIX
#define RAHEAD_BUFFER_SIZE
Definition TDCacheFile.h:23
#define gDirectory
Definition TDirectory.h:384
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
void SysError(const char *location, const char *msgfmt,...)
Use this function in case a system (OS or GUI) related error occurred.
Definition TError.cxx:196
static unsigned int total
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
#define gROOT
Definition TROOT.h:406
EAccessMode
Definition TSystem.h:41
@ kFileExists
Definition TSystem.h:42
@ kReadPermission
Definition TSystem.h:45
@ kWritePermission
Definition TSystem.h:44
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
#define free
Definition civetweb.c:1539
#define O_BINARY
Definition civetweb.c:912
#define malloc
Definition civetweb.c:1536
A TDCacheFile is like a normal TFile except that it may read and write its data via a dCache server (...
Definition TDCacheFile.h:25
void ResetErrno() const override
Method resetting the dc_errno and errno.
Bool_t fStatCached
! (transient) is file status cached?
Definition TDCacheFile.h:28
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
Read the nbuf blocks described in arrays pos and len, where pos[i] is the seek position of block i of...
static Bool_t CheckFile(const char *path, const char *location=0)
CheckFile() returns kTRUE on success and kFALSE on failure.
Int_t SysSync(Int_t fd) override
Interface to system sync.
static void SetOnError(EOnErrorAction=kOnErrorDefault)
Set on error handler.
static void SetOpenTimeout(UInt_t secs)
Set file open timeout.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence) override
Interface to system seek. All arguments like in POSIX lseek.
EOnErrorAction
Note: This must be kept in sync with values #defined in dcap.h.
Definition TDCacheFile.h:61
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Get info about a file: id, size, flags, modification time.
static Bool_t Stage(const char *path, UInt_t secs, const char *location=0)
Stage() returns kTRUE on success and kFALSE on failure.
~TDCacheFile() override
Close and cleanup dCache file.
struct stat64 fStatBuffer
! (transient) Cached file status buffer (for performance)
Definition TDCacheFile.h:29
static const char * GetDcapVersion()
Return dCache version string.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len) override
Interface to system write. All arguments like in POSIX write.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Interface to system open. All arguments like in POSIX open.
Int_t SysRead(Int_t fd, void *buf, Int_t len) override
Interface to system read. All arguments like in POSIX read.
Int_t SysClose(Int_t fd) override
Interface to system close. All arguments like in POSIX close.
static TString GetDcapPath(const char *path)
Transform the input path into a path usuable by the dcap C library, i.e either dcap://nodename....
Bool_t ReadBuffer(char *buf, Int_t len) override
Read specified byte range from remote file via dCache daemon.
Bool_t WriteBuffer(const char *buf, Int_t len) override
Write specified byte range to remote file via dCache daemon.
static void SetReplyHostName(const char *host_name)
Set reply host name.
void * fDirp
directory handler
Definition TDCacheFile.h:82
Int_t MakeDirectory(const char *name) override
Create a directory.
Int_t GetPathInfo(const char *path, FileStat_t &buf) override
Get info about a file.
void * OpenDirectory(const char *name) override
Open a directory.
Bool_t AccessPathName(const char *path, EAccessMode mode) override
Returns FALSE if one can access a file using the specified access mode.
void FreeDirectory(void *dirp) override
Close a directory.
TDCacheSystem()
Create helper class that allows directory access via dCache.
const char * GetDirEntry(void *dirp) override
Get a directory entry.
Bool_t fWritable
True if directory is writable.
A cache when reading files over the network.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
Long64_t fBytesRead
Number of bytes read from this file.
Definition TFile.h:76
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
Definition TFile.cxx:2271
static void SetFileBytesRead(Long64_t bytes=0)
Definition TFile.cxx:4605
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition TFile.cxx:2516
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition TFile.cxx:4571
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition TFile.cxx:1886
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition TFile.h:101
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
Definition TFile.cxx:1466
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition TFile.cxx:610
TString fOption
File options.
Definition TFile.h:91
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
Definition TFile.cxx:2473
Int_t fD
File descriptor.
Definition TFile.h:82
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition TFile.h:98
TString fRealName
Effective real file name (not original url)
Definition TFile.h:90
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition TFile.cxx:2250
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:947
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition TFile.cxx:1767
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
void MakeZombie()
Definition TObject.h:53
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
void ToUpper()
Change string to upper case.
Definition TString.cxx:1195
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:266
static void ResetErrno()
Static function resetting system error number.
Definition TSystem.cxx:284
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1274
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1665
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1296
void SetErrorStr(const char *errstr)
Set the system error string.
Definition TSystem.cxx:245
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition TUrl.cxx:390
const char * GetFile() const
Definition TUrl.h:69
const char * GetHost() const
Definition TUrl.h:67
const char * GetProtocol() const
Definition TUrl.h:64
const Int_t n
Definition legend1.C:16
Int_t fMode
Definition TSystem.h:125
Long64_t fSize
Definition TSystem.h:128
Long_t fDev
Definition TSystem.h:123
Int_t fGid
Definition TSystem.h:127
Long_t fMtime
Definition TSystem.h:129
Long_t fIno
Definition TSystem.h:124
Bool_t fIsLink
Definition TSystem.h:130
Int_t fUid
Definition TSystem.h:126