00001 #ifndef __XRDPOSIXPREPIO_HH__
00002 #define __XRDPOSIXPREPIO_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "Xrd/XrdJob.hh"
00034 #include "XrdPosix/XrdPosixFile.hh"
00035
00036 class XrdPosixPrepIO : public XrdOucCacheIO2
00037 {
00038 public:
00039
00040 XrdOucCacheIO *Base() {return this;}
00041
00042 XrdOucCacheIO *Detach() {return this;}
00043
00044 void Disable();
00045
00046 long long FSize() {return (Init() ? fileP->FSize() : openRC);}
00047
00048 int Fstat(struct stat &buf)
00049 {return (Init() ? fileP->Fstat(buf) : openRC);}
00050
00051 bool ioActive() { return false; }
00052
00053 int Open() {Init(); return openRC;}
00054
00055 const char *Path() {return fileP->Path();}
00056
00057 int Read (char *Buffer, long long Offset, int Length)
00058 {return (Init() ? fileP->Read(Buffer, Offset, Length) : openRC);}
00059
00060 void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
00061 {if (Init(&iocb)) fileP->Read(iocb, buff, offs, rlen);
00062 else iocb.Done(openRC);
00063 }
00064
00065 int ReadV(const XrdOucIOVec *readV, int n)
00066 {return (Init() ? fileP->ReadV(readV, n) : openRC);}
00067
00068 void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
00069 {if (Init(&iocb)) fileP->ReadV(iocb, readV, rnum);
00070 else iocb.Done(openRC);
00071 }
00072
00073 int Sync() {return (Init() ? fileP->Sync() : openRC);}
00074
00075 void Sync(XrdOucCacheIOCB &iocb)
00076 {if (Init(&iocb)) fileP->Sync(iocb);
00077 else iocb.Done(openRC);
00078 }
00079
00080 int Trunc(long long Offset)
00081 {return (Init() ? fileP->Trunc(Offset) : openRC);}
00082
00083 int Write(char *Buffer, long long Offset, int Length)
00084 {return (Init() ? fileP->Write(Buffer,Offset,Length) : openRC);}
00085
00086 void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
00087 {if (Init(&iocb)) fileP->Write(iocb, buff, offs, wlen);
00088 else iocb.Done(openRC);
00089 }
00090
00091 XrdPosixPrepIO(XrdPosixFile *fP, XrdCl::OpenFlags::Flags clflags,
00092 XrdCl::Access::Mode clmode)
00093 : fileP(fP), openRC(0), iCalls(0),
00094 clFlags(clflags), clMode(clmode) {}
00095 virtual ~XrdPosixPrepIO() {}
00096
00097 private:
00098 bool Init(XrdOucCacheIOCB *iocbP=0);
00099
00100 XrdPosixFile *fileP;
00101 int openRC;
00102 int iCalls;
00103
00104 XrdCl::OpenFlags::Flags clFlags;
00105 XrdCl::Access::Mode clMode;
00106 };
00107 #endif