54 #if defined(_GFAL2_API_) || defined(GFAL2_API_) || defined(_GFAL2_API) || defined(_GFAL2_API_H_) || defined(GFAL2_API_H_) || defined(_GFAL2_API_H) 55 #define gfal_lseek64 gfal_lseek 56 #define gfal_open64 gfal_open 57 #define gfal_readdir64 gfal_readdir 58 #define gfal_stat64 gfal_stat 59 #define dirent64 dirent 82 :
TFile(url, "NET", ftitle, compress)
96 if (!create && !recreate && !update && !read) {
106 fname = (
char *)stmp.
Data();
108 Error(
"TGFALFile",
"error expanding path %s", fUrl.GetFileAndOptions());
114 ::gfal_unlink(fname);
119 if (create && ::gfal_access(fname,
kFileExists) == 0) {
120 Error(
"TGFALFile",
"file %s already exists", fname);
129 Error(
"TGFALFile",
"no write permission, could not open file %s", fname);
134 #ifdef GFAL_ACCESS_FIXED 136 Error(
"TGFALFile",
"file %s does not exist", fname);
140 Error(
"TGFALFile",
"no read permission, could not open file %s", fname);
149 if (create || update) {
151 fD = SysOpen(fname, O_RDWR | O_CREAT, 0644);
153 fD = SysOpen(fname, O_RDWR | O_CREAT |
O_BINARY, S_IREAD | S_IWRITE);
156 SysError(
"TGFALFile",
"file %s can not be opened", fname);
162 fD = SysOpen(fname, O_RDONLY, 0644);
164 fD = SysOpen(fname, O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
167 SysError(
"TGFALFile",
"file %s can not be opened for reading", fname);
196 Int_t ret = ::gfal_open64(pathname, flags, (
Int_t) mode);
206 Int_t ret = ::gfal_close(fd);
216 Int_t ret = ::gfal_read(fd, buf, len);
226 Int_t ret = ::gfal_write(fd, buf, len);
238 Long64_t ret = ::gfal_lseek64(fd, offset, whence);
256 if (::gfal_stat64(
fRealName, &statbuf) >= 0)
262 *
id = (statbuf.st_dev << 24) + statbuf.st_ino;
264 *size = statbuf.st_size;
266 *modtime = statbuf.st_mtime;
269 if (statbuf.st_mode & ((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6)))
271 if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
273 if ((statbuf.st_mode & S_IFMT) != S_IFREG &&
274 (statbuf.st_mode & S_IFMT) != S_IFDIR)
371 Error(
"OpenDirectory",
"invalid directory pointer (should never happen)");
382 if ((finfo.st_mode & S_IFMT) != S_IFDIR)
396 Error(
"FreeDirectory",
"invalid directory pointer (should never happen)");
401 ::gfal_closedir((DIR*)dirp);
412 Error(
"GetDirEntry",
"invalid directory pointer (should never happen)");
419 dp = ::gfal_readdir64((DIR*)dirp);
441 buf.
fDev = sbuf.st_dev;
442 buf.
fIno = sbuf.st_ino;
443 buf.
fMode = sbuf.st_mode;
444 buf.
fUid = sbuf.st_uid;
445 buf.
fGid = sbuf.st_gid;
446 buf.
fSize = sbuf.st_size;
447 buf.
fMtime = sbuf.st_mtime;
double read(const std::string &file_name)
reading
struct stat64 fStatBuffer
! (transient) Cached file status buffer (for performance)
Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read.
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
This class represents a WWW compatible URL.
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...
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
TGFALSystem()
Create helper class that allows directory access via GFAL.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
Bool_t WriteBuffer(const char *buf, Int_t len)
Write specified byte range to remote file via GFAL.
void SysError(const char *location, const char *msgfmt,...)
const char * GetDirEntry(void *dirp)
Get directory entry via GFAL. Returns 0 in case no more entries.
TString fRealName
Effective real file name (not original url)
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Interface to TSystem:GetPathInfo().
Bool_t fStatCached
! (transient) is file status cached?
void Error(const char *location, const char *msgfmt,...)
Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via GFAL.
Read and write data via the underlying Grid access mechanism.
void FreeDirectory(void *dirp)
Free directory via GFAL.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
R__EXTERN TSystem * gSystem
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
~TGFALFile()
GFAL file dtor. Close and flush directory structure.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Int_t MakeDirectory(const char *name)
Make a directory via GFAL.
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Bool_t fWritable
True if directory is writable.
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
TString fOption
File options.
Directory handler for GFAL.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Abstract base class defining a generic interface to the underlying Operating System.
void * OpenDirectory(const char *name)
Open a directory via GFAL.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write.
virtual void Close(Option_t *option="")
Close a file.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
const char * Data() const