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)
72 const char *ftitle,
Int_t compress):
73 TFile(path,
"NET", ftitle, compress)
76 path = pathString.
Data();
89 if (!create && !recreate && !
update && !read) {
97 const char *fnameWithPrefix;
100 fnameWithPrefix = fname = path;
110 fnameWithPrefix = stmp2;
112 Error(
"TDCacheFile",
"error expanding path %s", path);
125 Error(
"TDCacheFile",
"file %s already exists", fname);
134 Error(
"TDCacheFile",
"no write permission, could not open file %s", fname);
144 fD =
SysOpen(fname, O_RDWR | O_CREAT, 0644);
149 SysError(
"TDCacheFile",
"file %s can not be opened", fname);
161 Error(
"TDCacheFile",
"file %s does not exist", fname);
165 Error(
"TDCacheFile",
"no read permission, could not open file %s", fname);
168 SysError(
"TDCacheFile",
"file %s can not be opened for reading", fname);
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;
184 dc_setBufferSize(
fD, dcache_RAHEAD_SIZE);
253 vector = (iovec2 *)
malloc(
sizeof(iovec2)*nbuf);
256 for (
Int_t i = 0; i < nbuf; i++) {
257 vector[i].buf = &buf[total_len];
259 vector[i].len = len[i];
263 Int_t rc = dc_readv2(
fD, vector, nbuf);
282 Long64_t high = pos[nbuf-1] + len[nbuf-1] - pos[0];
285 for(
Int_t j=0; j < nbuf; j++) {
291 char *temp =
new char[high];
296 for (
Int_t i = 0; i < nbuf; i++) {
297 memcpy(&buf[k], &(temp[pos[i]-pos[0]]), len[i]);
306 for (
Int_t i = 0; i < nbuf; i++) {
343 path = pathString.
Data();
347 if (dc_stage(path, after, location) == 0)
364 path = pathString.
Data();
368 if (dc_check(path, location) == 0)
382 dc_setOpenTimeout(
n);
398 dc_setReplyHostName((
char*)host_name);
406 return getDcapVersion();
419 dc_setClientActive();
423 Int_t rc = dc_open(pathname, flags, (
Int_t) mode);
440 Int_t rc = dc_close(fd);
457 Int_t rc = dc_read(fd, buf, len);
474 Int_t rc = dc_write(fd, (
char *)buf, len);
491 Long64_t rc = dc_lseek64(fd, offset, whence);
544 path = pathString.
Data();
546 if (path && (dc_stat64(path, &statbuf) >= 0)) {
553 *
id = (statbuf.st_dev << 24) + statbuf.st_ino;
555 *size = statbuf.st_size;
557 *modtime = statbuf.st_mtime;
560 if (statbuf.st_mode & ((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6)))
562 if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
564 if ((statbuf.st_mode & S_IFMT) != S_IFREG &&
565 (statbuf.st_mode & S_IFMT) != S_IFDIR)
625 path = pathString.
Data();
627 rc = dc_mkdir(path, 0755);
643 path = pathString.
Data();
645 fDirp = dc_opendir(path);
662 rc = dc_closedir((DIR *)dirp);
680 ent = dc_readdir((DIR *)dirp);
686 return !ent ? 0 : ent->d_name;
697 path = pathString.
Data();
699 return dc_access(path, mode);
711 path = pathString.
Data();
715 if (path && (dc_stat64(path, &sbuf) >= 0)) {
717 buf.
fDev = sbuf.st_dev;
718 buf.
fIno = sbuf.st_ino;
719 buf.
fMode = sbuf.st_mode;
720 buf.
fUid = sbuf.st_uid;
721 buf.
fGid = sbuf.st_gid;
722 buf.
fSize = sbuf.st_size;
723 buf.
fMtime = sbuf.st_mtime;
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
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
static unsigned int total
R__EXTERN TSystem * gSystem
A TDCacheFile is like a normal TFile except that it may read and write its data via a dCache server (...
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close.
Bool_t fStatCached
! (transient) is file status cached?
~TDCacheFile()
Close and cleanup dCache file.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system seek. All arguments like in POSIX lseek.
static Bool_t CheckFile(const char *path, const char *location=0)
CheckFile() returns kTRUE on success and kFALSE on failure.
static void SetOnError(EOnErrorAction=kOnErrorDefault)
Set on error handler.
static void SetOpenTimeout(UInt_t secs)
Set file open timeout.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read.
Bool_t WriteBuffer(const char *buf, Int_t len)
Write specified byte range to remote file via dCache daemon.
EOnErrorAction
Note: This must be kept in sync with values #defined in dcap.h.
static Bool_t Stage(const char *path, UInt_t secs, const char *location=0)
Stage() returns kTRUE on success and kFALSE on failure.
Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via dCache daemon.
Int_t SysSync(Int_t fd)
Interface to system sync.
struct stat64 fStatBuffer
! (transient) Cached file status buffer (for performance)
static const char * GetDcapVersion()
Return dCache version string.
static TString GetDcapPath(const char *path)
Transform the input path into a path usuable by the dcap C library, i.e either dcap://nodename....
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open.
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len, where pos[i] is the seek position of block i of...
static void SetReplyHostName(const char *host_name)
Set reply host name.
void ResetErrno() const
Method resetting the dc_errno and errno.
void * fDirp
directory handler
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
const char * GetDirEntry(void *dirp)
Get a directory entry.
void FreeDirectory(void *dirp)
Close a directory.
void * OpenDirectory(const char *name)
Open a directory.
Int_t MakeDirectory(const char *name)
Create a directory.
TDCacheSystem()
Create helper class that allows directory access via dCache.
Bool_t fWritable
True if directory is writable.
A cache when reading files over the network.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Long64_t fBytesRead
Number of bytes read from this file.
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
static void SetFileBytesRead(Long64_t bytes=0)
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Long64_t fArchiveOffset
!Offset at which file starts in archive
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
virtual void Init(Bool_t create)
Initialize a TFile object.
TString fOption
File options.
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
TString fRealName
Effective real file name (not original url)
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
void Close(Option_t *option="") override
Close a file.
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetName() const
Returns name of object.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * Data() const
void ToUpper()
Change string to upper case.
Abstract base class defining a generic interface to the underlying Operating System.
static void ResetErrno()
Static function resetting system error number.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
void SetErrorStr(const char *errstr)
Set the system error string.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
const char * GetFile() const
const char * GetHost() const
const char * GetProtocol() const