XRootD
XrdPosixPrepIO.hh
Go to the documentation of this file.
1 #ifndef __XRDPOSIXPREPIO_HH__
2 #define __XRDPOSIXPREPIO_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d P o s i x P r e p I O . h h */
6 /* */
7 /* (c) 2016 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include "Xrd/XrdJob.hh"
34 #include "XrdPosix/XrdPosixFile.hh"
35 
36 class XrdOucCacheIOCD;
37 
39 {
40 public:
41 
42 bool Detach(XrdOucCacheIOCD &cdP) {(void)cdP; return true;}
43 
44 void Disable();
45 
46 int Fcntl(XrdOucCacheOp::Code opc, const std::string& args,
47  std::string& resp)
48  {return (Init() ? fileP->Fcntl(opc, args, resp) : openRC);}
49 
50 long long FSize() {return (Init() ? fileP->FSize() : openRC);}
51 
52 int Fstat(struct stat &buf)
53  {return (Init() ? fileP->Fstat(buf) : openRC);}
54 
55 int Open() {Init(); return openRC;}
56 
57 const char *Path() {return fileP->Path();}
58 
59 int Read (char *Buffer, long long Offset, int Length)
60  {return (Init() ? fileP->Read(Buffer, Offset, Length) : openRC);}
61 
62 void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
63  {if (Init(&iocb)) fileP->Read(iocb, buff, offs, rlen);
64  else iocb.Done(openRC);
65  }
66 
67 int ReadV(const XrdOucIOVec *readV, int n)
68  {return (Init() ? fileP->ReadV(readV, n) : openRC);}
69 
70 void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
71  {if (Init(&iocb)) fileP->ReadV(iocb, readV, rnum);
72  else iocb.Done(openRC);
73  }
74 
75 int Sync() {return (Init() ? fileP->Sync() : openRC);}
76 
77 void Sync(XrdOucCacheIOCB &iocb)
78  {if (Init(&iocb)) fileP->Sync(iocb);
79  else iocb.Done(openRC);
80  }
81 
82 int Trunc(long long Offset)
83  {return (Init() ? fileP->Trunc(Offset) : openRC);}
84 
85 int Write(char *Buffer, long long Offset, int Length)
86  {return (Init() ? fileP->Write(Buffer,Offset,Length) : openRC);}
87 
88 void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
89  {if (Init(&iocb)) fileP->Write(iocb, buff, offs, wlen);
90  else iocb.Done(openRC);
91  }
92 
94  XrdCl::Access::Mode clmode)
95  : fileP(fP), openRC(0), iCalls(0),
96  clFlags(clflags), clMode(clmode) {}
97 virtual ~XrdPosixPrepIO() {}
98 
99 private:
100 bool Init(XrdOucCacheIOCB *iocbP=0);
101 
102 XrdPosixFile *fileP;
103 int openRC;
104 int iCalls;
105 
107 XrdCl::Access::Mode clMode;
108 };
109 #endif
#define stat(a, b)
Definition: XrdPosix.hh:105
virtual void Done(int result)=0
const char * Path() override
int Write(char *Buff, long long Offs, int Len) override
int Fcntl(XrdOucCacheOp::Code opc, const std::string &args, std::string &resp) override
int Sync() override
long long FSize() override
Definition: XrdPosixFile.hh:97
int Read(char *Buff, long long Offs, int Len) override
int Fstat(struct stat &buf) override
int Trunc(long long Offset) override
int ReadV(const XrdOucIOVec *readV, int n) override
int ReadV(const XrdOucIOVec *readV, int n)
int Read(char *Buffer, long long Offset, int Length)
const char * Path()
long long FSize()
int Write(char *Buffer, long long Offset, int Length)
bool Detach(XrdOucCacheIOCD &cdP)
void Sync(XrdOucCacheIOCB &iocb)
int Fcntl(XrdOucCacheOp::Code opc, const std::string &args, std::string &resp)
void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
void Read(XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
int Trunc(long long Offset)
XrdPosixPrepIO(XrdPosixFile *fP, XrdCl::OpenFlags::Flags clflags, XrdCl::Access::Mode clmode)
virtual ~XrdPosixPrepIO()
void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
int Fstat(struct stat &buf)
Mode
Access mode.
Flags
Open flags, may be or'd when appropriate.