55 #if defined(_GFAL2_API_) || defined(GFAL2_API_) || defined(_GFAL2_API) || defined(_GFAL2_API_H_) || defined(GFAL2_API_H_) || defined(_GFAL2_API_H)
56 #define gfal_lseek64 gfal_lseek
57 #define gfal_open64 gfal_open
58 #define gfal_readdir64 gfal_readdir
59 #define gfal_stat64 gfal_stat
60 #define dirent64 dirent
83 :
TFile(url, "NET", ftitle, compress)
97 if (!create && !recreate && !update && !read) {
107 fname = (
char *)stmp.
Data();
109 Error(
"TGFALFile",
"error expanding path %s", fUrl.GetFileAndOptions());
115 ::gfal_unlink(fname);
120 if (create && ::gfal_access(fname,
kFileExists) == 0) {
121 Error(
"TGFALFile",
"file %s already exists", fname);
130 Error(
"TGFALFile",
"no write permission, could not open file %s", fname);
135 #ifdef GFAL_ACCESS_FIXED
137 Error(
"TGFALFile",
"file %s does not exist", fname);
141 Error(
"TGFALFile",
"no read permission, could not open file %s", fname);
150 if (create || update) {
152 fD = SysOpen(fname, O_RDWR | O_CREAT, 0644);
154 fD = SysOpen(fname, O_RDWR | O_CREAT |
O_BINARY, S_IREAD | S_IWRITE);
157 SysError(
"TGFALFile",
"file %s can not be opened", fname);
163 fD = SysOpen(fname, O_RDONLY, 0644);
165 fD = SysOpen(fname, O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
168 SysError(
"TGFALFile",
"file %s can not be opened for reading", fname);
197 Int_t ret = ::gfal_open64(pathname, flags, (
Int_t) mode);
207 Int_t ret = ::gfal_close(fd);
217 Int_t ret = ::gfal_read(fd, buf, len);
227 Int_t ret = ::gfal_write(fd, buf, len);
239 Long64_t ret = ::gfal_lseek64(fd, offset, whence);
257 if (::gfal_stat64(
fRealName, &statbuf) >= 0)
263 *
id = (statbuf.st_dev << 24) + statbuf.st_ino;
265 *size = statbuf.st_size;
267 *modtime = statbuf.st_mtime;
270 if (statbuf.st_mode & ((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6)))
272 if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
274 if ((statbuf.st_mode & S_IFMT) != S_IFREG &&
275 (statbuf.st_mode & S_IFMT) != S_IFDIR)
372 Error(
"OpenDirectory",
"invalid directory pointer (should never happen)");
383 if ((finfo.st_mode & S_IFMT) != S_IFDIR)
397 Error(
"FreeDirectory",
"invalid directory pointer (should never happen)");
402 ::gfal_closedir((DIR*)dirp);
413 Error(
"GetDirEntry",
"invalid directory pointer (should never happen)");
420 dp = ::gfal_readdir64((DIR*)dirp);
442 buf.
fDev = sbuf.st_dev;
443 buf.
fIno = sbuf.st_ino;
444 buf.
fMode = sbuf.st_mode;
445 buf.
fUid = sbuf.st_uid;
446 buf.
fGid = sbuf.st_gid;
447 buf.
fSize = sbuf.st_size;
448 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.
ClassImp(TGFALFile) ClassImp(TGFALSystem) TGFALFile
Create a GFAL file object.
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)
Change (i.e.
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.
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 * Data() const
const char * GetDirEntry(void *dirp)
Get directory entry via GFAL. Returns 0 in case no more entries.
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
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().
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Bool_t fStatCached
! (transient) is file status cached?
if(pyself &&pyself!=Py_None)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
Int_t MakeDirectory(const char *name)
Make a directory via GFAL.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Bool_t fWritable
True if directory is writable.
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.