47 #include <sys/types.h> 51 #if defined(R__SUN) || defined(R__HPUX) || \ 52 defined(R__AIX) || defined(R__LINUX) || defined(R__SOLARIS) || \ 53 defined(R__HIUX) || defined(R__FBSD) || defined(R__MACOSX) || \ 54 defined(R__HURD) || defined(R__OBSD) 86 :
TFile(url, "NET", ftitle, compress)
91 Int_t readopt = RFIO_READBUF;
92 ::rfiosetopt(RFIO_READOPT, &readopt, 4);
101 if (!create && !recreate && !update && !read) {
107 if (!strcmp(fUrl.GetProtocol(),
"castor"))
108 fUrl.SetProtocol(
"rfio");
111 TString opt = fUrl.GetOptions();
112 if (opt.
Contains(
"&filetype=raw")) {
114 fUrl.SetOptions(opt);
115 }
else if (opt.
Contains(
"filetype=raw")) {
117 fUrl.SetOptions(opt);
122 if ((strstr(url,
":/") && !strstr(url,
"://")) ||
123 (strstr(url,
":///") && !strstr(url,
":////")))
129 fname.
Form(
"%s://%s", fUrl.GetProtocol(), fUrl.GetFile());
131 fname.
Form(
"%s:///%s", fUrl.GetProtocol(), fUrl.GetFile());
132 if (strlen(fUrl.GetOptions()))
137 ::rfio_unlink((
char*)fname.
Data());
143 Error(
"TRFIOFile",
"file %s already exists", fname.
Data());
152 Error(
"TRFIOFile",
"no write permission, could not open file %s", fname.
Data());
160 if (create || update) {
162 fD = SysOpen(fname.
Data(), O_RDWR | O_CREAT, 0644);
164 fD = SysOpen(fname.
Data(), O_RDWR | O_CREAT |
O_BINARY, S_IREAD | S_IWRITE);
167 SysError(
"TRFIOFile",
"file %s can not be opened", fname.
Data());
173 fD = SysOpen(fname.
Data(), O_RDONLY, 0644);
175 fD = SysOpen(fname.
Data(), O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
178 SysError(
"TRFIOFile",
"file %s can not be opened for reading", fname.
Data());
208 TTHREAD_TLS(
struct iovec64 *) iov = 0;
209 TTHREAD_TLS(
Int_t) iovsize = 128;
213 Error(
"ReadBuffers",
"cannot read because object is in 'zombie' state");
218 Error(
"ReadBuffers",
"the remote file is not open");
230 iov = (
struct iovec64*)
malloc(
sizeof(
struct iovec64) * iovsize);
232 Info(
"TRFIOFile",
"allocating iovec64 with size %d", iovsize);
234 Error(
"TRFIOFile",
"error allocating preseek vector of size %ld",
235 (
Long_t)
sizeof(
struct iovec64) * iovsize);
239 if (nbuf > iovsize) {
241 iov = (
struct iovec64*)
realloc(iov,
sizeof(
struct iovec64) * iovsize);
243 Info(
"TRFIOFile",
"re-allocating iovec64 with size %d", iovsize);
245 Error(
"TRFIOFile",
"error reallocating preseek vector of size %ld",
246 (
Long_t)
sizeof(
struct iovec64) * iovsize);
252 for (n = 0; n < nbuf; n++) {
254 Info(
"TFIOFile",
"adding chunk %d, %lld %d", n, pos[n], len[n]);
256 iov[
n].iov_len = len[
n];
261 if (rfio_preseek64(
fD, iov, nbuf) < 0 && rfio_errno != SEOPNOTSUP) {
262 Error(
"TRFIOFile",
"error doing rfio_preseek64");
269 for (n = 0; n < nbuf; n++) {
270 if (rfio_lseek64(
fD, iov[n].iov_base, SEEK_SET) < 0) {
271 Error(
"TRFIOFile",
"error doing rfio_lseek64");
274 if (rfio_read(
fD, buf+k, iov[n].iov_len) < 0) {
275 Error(
"TRFIOFile",
"error doing rfio_read");
302 Int_t ret = ::rfio_open64((
char*)pathname, flags, (
Int_t) mode);
313 Int_t ret = ::rfio_close(fd);
324 Int_t ret = ::rfio_read(fd, (
char *)buf, len);
335 Int_t ret = ::rfio_write(fd, (
char *)buf, len);
348 Long64_t ret = ::rfio_lseek64(fd, offset, whence);
363 struct stat64 statbuf;
365 if (::rfio_fstat64(fd, &statbuf) >= 0) {
367 *
id = (statbuf.st_dev << 24) + statbuf.st_ino;
369 *size = statbuf.st_size;
371 *modtime = statbuf.st_mtime;
374 if (statbuf.st_mode & ((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6)))
376 if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
378 if ((statbuf.st_mode & S_IFMT) != S_IFREG &&
379 (statbuf.st_mode & S_IFMT) != S_IFDIR)
443 Error(
"OpenDirectory",
"invalid directory pointer (should never happen)");
453 if ((finfo.st_mode & S_IFMT) != S_IFDIR)
470 Error(
"FreeDirectory",
"invalid directory pointer (should never happen)");
475 ::rfio_closedir((DIR*)dirp);
486 Error(
"GetDirEntry",
"invalid directory pointer (should never happen)");
493 dp = (
struct dirent *) ::rfio_readdir((DIR*)dirp);
514 buf.
fDev = sbuf.st_dev;
515 buf.
fIno = sbuf.st_ino;
516 buf.
fMode = sbuf.st_mode;
517 buf.
fUid = sbuf.st_uid;
518 buf.
fGid = sbuf.st_gid;
519 buf.
fSize = sbuf.st_size;
520 buf.
fMtime = sbuf.st_mtime;
double read(const std::string &file_name)
reading
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write.
This class represents a WWW compatible URL.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetName(const char *name)
Set the name of the TNamed.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
static void SetFileReadCalls(Int_t readcalls=0)
void * OpenDirectory(const char *name)
Open a directory via rfiod.
void ResetErrno() const
Method resetting the rfio_errno, serrno and errno.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
void FreeDirectory(void *dirp)
Free directory via rfiod.
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
TRFIOSystem()
Create helper class that allows directory access via rfiod.
~TRFIOFile()
RFIO file dtor. Close and flush directory structure.
void SysError(const char *location, const char *msgfmt,...)
static Int_t GetErrno()
Static function returning system error number.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
void Error(const char *location, const char *msgfmt,...)
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close.
Directory handler for RFIO.
A ROOT file that reads/writes via a rfiod server.
R__EXTERN TSystem * gSystem
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.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Int_t Unlink(const char *path)
Unlink, i.e.
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
The TTimeStamp encapsulates seconds and ns since EPOCH.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Bool_t R_ISDIR(Int_t mode)
Int_t GetErrno() const
Method returning rfio_errno.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
Long64_t fArchiveOffset
!Offset at which file starts in archive
static void ResetErrno()
Static function resetting system error number.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read.
void SetErrorStr(const char *errstr)
Set the system error string.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open.
static void SetFileBytesRead(Long64_t bytes=0)
Abstract base class defining a generic interface to the underlying Operating System.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Interface to TSystem:GetPathInfo().
Long64_t fBytesRead
Number of bytes read from this file.
Int_t MakeDirectory(const char *name)
Make a directory via rfiod.
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read a list of buffers given in pos[] and len[] and return it in a single buffer. ...
virtual void Close(Option_t *option="")
Close a file.
const char * GetDirEntry(void *dirp)
Get directory entry via rfiod. Returns 0 in case no more entries.
const char * Data() const