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 XrdOucCacheIOCD;
00037
00038 class XrdPosixPrepIO : public XrdOucCacheIO
00039 {
00040 public:
00041
00042 bool Detach(XrdOucCacheIOCD &cdP) {(void)cdP; return true;}
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 int Open() {Init(); return openRC;}
00052
00053 const char *Path() {return fileP->Path();}
00054
00055 int Read (char *Buffer, long long Offset, int Length)
00056 {return (Init() ? fileP->Read(Buffer, Offset, Length) : openRC);}
00057
00058 void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
00059 {if (Init(&iocb)) fileP->Read(iocb, buff, offs, rlen);
00060 else iocb.Done(openRC);
00061 }
00062
00063 int ReadV(const XrdOucIOVec *readV, int n)
00064 {return (Init() ? fileP->ReadV(readV, n) : openRC);}
00065
00066 void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
00067 {if (Init(&iocb)) fileP->ReadV(iocb, readV, rnum);
00068 else iocb.Done(openRC);
00069 }
00070
00071 int Sync() {return (Init() ? fileP->Sync() : openRC);}
00072
00073 void Sync(XrdOucCacheIOCB &iocb)
00074 {if (Init(&iocb)) fileP->Sync(iocb);
00075 else iocb.Done(openRC);
00076 }
00077
00078 int Trunc(long long Offset)
00079 {return (Init() ? fileP->Trunc(Offset) : openRC);}
00080
00081 int Write(char *Buffer, long long Offset, int Length)
00082 {return (Init() ? fileP->Write(Buffer,Offset,Length) : openRC);}
00083
00084 void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
00085 {if (Init(&iocb)) fileP->Write(iocb, buff, offs, wlen);
00086 else iocb.Done(openRC);
00087 }
00088
00089 XrdPosixPrepIO(XrdPosixFile *fP, XrdCl::OpenFlags::Flags clflags,
00090 XrdCl::Access::Mode clmode)
00091 : fileP(fP), openRC(0), iCalls(0),
00092 clFlags(clflags), clMode(clmode) {}
00093 virtual ~XrdPosixPrepIO() {}
00094
00095 private:
00096 bool Init(XrdOucCacheIOCB *iocbP=0);
00097
00098 XrdPosixFile *fileP;
00099 int openRC;
00100 int iCalls;
00101
00102 XrdCl::OpenFlags::Flags clFlags;
00103 XrdCl::Access::Mode clMode;
00104 };
00105 #endif