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 
37 {
38 public:
39 
40 XrdOucCacheIO *Base() {return this;} // Already defined
41 
42 XrdOucCacheIO *Detach() {return this;} // Already defined
43 
44 void Disable();
45 
46 long long FSize() {return (Init() ? fileP->FSize() : openRC);}
47 
48 int Fstat(struct stat &buf)
49  {return (Init() ? fileP->Fstat(buf) : openRC);}
50 
51 bool ioActive() { return false; } // Already defined
52 
53 int Open() {Init(); return openRC;}
54 
55 const char *Path() {return fileP->Path();}
56 
57 int Read (char *Buffer, long long Offset, int Length)
58  {return (Init() ? fileP->Read(Buffer, Offset, Length) : openRC);}
59 
60 void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
61  {if (Init(&iocb)) fileP->Read(iocb, buff, offs, rlen);
62  else iocb.Done(openRC);
63  }
64 
65 int ReadV(const XrdOucIOVec *readV, int n)
66  {return (Init() ? fileP->ReadV(readV, n) : openRC);}
67 
68 void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
69  {if (Init(&iocb)) fileP->ReadV(iocb, readV, rnum);
70  else iocb.Done(openRC);
71  }
72 
73 int Sync() {return (Init() ? fileP->Sync() : openRC);}
74 
75 void Sync(XrdOucCacheIOCB &iocb)
76  {if (Init(&iocb)) fileP->Sync(iocb);
77  else iocb.Done(openRC);
78  }
79 
80 int Trunc(long long Offset)
81  {return (Init() ? fileP->Trunc(Offset) : openRC);}
82 
83 int Write(char *Buffer, long long Offset, int Length)
84  {return (Init() ? fileP->Write(Buffer,Offset,Length) : openRC);}
85 
86 void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
87  {if (Init(&iocb)) fileP->Write(iocb, buff, offs, wlen);
88  else iocb.Done(openRC);
89  }
90 
92  XrdCl::Access::Mode clmode)
93  : fileP(fP), openRC(0), iCalls(0),
94  clFlags(clflags), clMode(clmode) {}
95 virtual ~XrdPosixPrepIO() {}
96 
97 private:
98 bool Init(XrdOucCacheIOCB *iocbP=0);
99 
101 int openRC;
102 int iCalls;
103 
106 };
107 #endif
XrdPosixPrepIO::ReadV
void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
Definition: XrdPosixPrepIO.hh:68
XrdPosixPrepIO::Write
void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
Definition: XrdPosixPrepIO.hh:86
XrdPosixPrepIO::Sync
void Sync(XrdOucCacheIOCB &iocb)
Definition: XrdPosixPrepIO.hh:75
XrdPosixPrepIO::Read
int Read(char *Buffer, long long Offset, int Length)
Definition: XrdPosixPrepIO.hh:57
XrdOucCacheIO
Definition: XrdOucCache.hh:128
XrdOucCacheIO2
Definition: XrdOucCache2.hh:63
XrdPosixPrepIO::Path
const char * Path()
Definition: XrdPosixPrepIO.hh:55
XrdPosixPrepIO::Disable
void Disable()
XrdPosixFile.hh
XrdPosixPrepIO::clMode
XrdCl::Access::Mode clMode
Definition: XrdPosixPrepIO.hh:105
XrdPosixPrepIO::Sync
int Sync()
Definition: XrdPosixPrepIO.hh:73
XrdPosixPrepIO::Detach
XrdOucCacheIO * Detach()
Definition: XrdPosixPrepIO.hh:42
XrdPosixFile::Sync
int Sync()
XrdPosixPrepIO
Definition: XrdPosixPrepIO.hh:37
XrdPosixPrepIO::ioActive
bool ioActive()
Definition: XrdPosixPrepIO.hh:51
XrdPosixPrepIO::XrdPosixPrepIO
XrdPosixPrepIO(XrdPosixFile *fP, XrdCl::OpenFlags::Flags clflags, XrdCl::Access::Mode clmode)
Definition: XrdPosixPrepIO.hh:91
XrdPosixFile::ReadV
int ReadV(const XrdOucIOVec *readV, int n)
XrdOucIOVec
Definition: XrdOucIOVec.hh:41
XrdCl::Access::Mode
Mode
Access mode.
Definition: XrdClFileSystem.hh:123
XrdPosixFile::Trunc
int Trunc(long long Offset)
XrdPosixFile::FSize
long long FSize()
Definition: XrdPosixFile.hh:87
XrdPosixPrepIO::Fstat
int Fstat(struct stat &buf)
Definition: XrdPosixPrepIO.hh:48
XrdPosixPrepIO::Init
bool Init(XrdOucCacheIOCB *iocbP=0)
XrdPosixPrepIO::iCalls
int iCalls
Definition: XrdPosixPrepIO.hh:102
XrdPosixPrepIO::Trunc
int Trunc(long long Offset)
Definition: XrdPosixPrepIO.hh:80
XrdPosixPrepIO::Write
int Write(char *Buffer, long long Offset, int Length)
Definition: XrdPosixPrepIO.hh:83
XrdPosixPrepIO::Open
int Open()
Definition: XrdPosixPrepIO.hh:53
XrdPosixFile::Fstat
int Fstat(struct stat &buf)
XrdOucCacheIOCB::Done
virtual void Done(int result)=0
XrdPosixPrepIO::FSize
long long FSize()
Definition: XrdPosixPrepIO.hh:46
XrdPosixPrepIO::fileP
XrdPosixFile * fileP
Definition: XrdPosixPrepIO.hh:100
XrdOucCacheIOCB
Definition: XrdOucCache.hh:94
XrdPosixPrepIO::~XrdPosixPrepIO
virtual ~XrdPosixPrepIO()
Definition: XrdPosixPrepIO.hh:95
XrdPosixPrepIO::Base
XrdOucCacheIO * Base()
Definition: XrdPosixPrepIO.hh:40
stat
#define stat(a, b)
Definition: XrdPosix.hh:96
XrdPosixPrepIO::ReadV
int ReadV(const XrdOucIOVec *readV, int n)
Definition: XrdPosixPrepIO.hh:65
XrdJob.hh
XrdPosixFile::Read
int Read(char *Buff, long long Offs, int Len)
XrdPosixPrepIO::openRC
int openRC
Definition: XrdPosixPrepIO.hh:101
XrdPosixFile
Definition: XrdPosixFile.hh:60
XrdPosixFile::Write
int Write(char *Buff, long long Offs, int Len)
XrdCl::OpenFlags::Flags
Flags
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:77
XrdPosixFile::Path
const char * Path()
Definition: XrdPosixFile.hh:110
XrdPosixPrepIO::Read
void Read(XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
Definition: XrdPosixPrepIO.hh:60
XrdPosixPrepIO::clFlags
XrdCl::OpenFlags::Flags clFlags
Definition: XrdPosixPrepIO.hh:104