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