xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XrdClFile.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // This file is part of the XRootD software suite.
6 //
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // In applying this licence, CERN does not waive the privileges and immunities
21 // granted to it by virtue of its status as an Intergovernmental Organization
22 // or submit itself to any jurisdiction.
23 //------------------------------------------------------------------------------
24 
25 #ifndef __XRD_CL_FILE_HH__
26 #define __XRD_CL_FILE_HH__
27 
28 #include "XrdCl/XrdClFileSystem.hh"
30 #include "XrdOuc/XrdOucCompiler.hh"
31 #include <stdint.h>
32 #include <string>
33 #include <vector>
34 #include <sys/uio.h>
35 
36 namespace XrdCl
37 {
38  class FileStateHandler;
39  class FilePlugIn;
40 
41  //----------------------------------------------------------------------------
43  //----------------------------------------------------------------------------
44  class File
45  {
46  public:
47 
49  {
52  };
53 
54  //------------------------------------------------------------------------
56  //------------------------------------------------------------------------
57  File( bool enablePlugIns = true );
58 
59  //------------------------------------------------------------------------
61  //------------------------------------------------------------------------
62  File( VirtRedirect virtRedirect, bool enablePlugIns = true );
63 
64  //------------------------------------------------------------------------
66  //------------------------------------------------------------------------
67  virtual ~File();
68 
69  //------------------------------------------------------------------------
79  //------------------------------------------------------------------------
80  XRootDStatus Open( const std::string &url,
81  OpenFlags::Flags flags,
82  Access::Mode mode,
83  ResponseHandler *handler,
84  uint16_t timeout = 0 )
86 
87  //------------------------------------------------------------------------
96  //------------------------------------------------------------------------
97  XRootDStatus Open( const std::string &url,
98  OpenFlags::Flags flags,
99  Access::Mode mode = Access::None,
100  uint16_t timeout = 0 )
102 
103  //------------------------------------------------------------------------
110  //------------------------------------------------------------------------
112  uint16_t timeout = 0 )
113  XRD_WARN_UNUSED_RESULT;
114 
115  //------------------------------------------------------------------------
121  //------------------------------------------------------------------------
122  XRootDStatus Close( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
123 
124  //------------------------------------------------------------------------
134  //------------------------------------------------------------------------
135  XRootDStatus Stat( bool force,
136  ResponseHandler *handler,
137  uint16_t timeout = 0 )
138  XRD_WARN_UNUSED_RESULT;
139 
140  //------------------------------------------------------------------------
148  //------------------------------------------------------------------------
149  XRootDStatus Stat( bool force,
150  StatInfo *&response,
151  uint16_t timeout = 0 )
152  XRD_WARN_UNUSED_RESULT;
153 
154 
155  //------------------------------------------------------------------------
168  //------------------------------------------------------------------------
169  XRootDStatus Read( uint64_t offset,
170  uint32_t size,
171  void *buffer,
172  ResponseHandler *handler,
173  uint16_t timeout = 0 )
174  XRD_WARN_UNUSED_RESULT;
175 
176  //------------------------------------------------------------------------
186  //------------------------------------------------------------------------
187  XRootDStatus Read( uint64_t offset,
188  uint32_t size,
189  void *buffer,
190  uint32_t &bytesRead,
191  uint16_t timeout = 0 )
192  XRD_WARN_UNUSED_RESULT;
193 
194  //------------------------------------------------------------------------
206  //------------------------------------------------------------------------
207  XRootDStatus PgRead( uint64_t offset,
208  uint32_t size,
209  void *buffer,
210  ResponseHandler *handler,
211  uint16_t timeout = 0 )
212  XRD_WARN_UNUSED_RESULT;
213 
214  //------------------------------------------------------------------------
225  //------------------------------------------------------------------------
226  XRootDStatus PgRead( uint64_t offset,
227  uint32_t size,
228  void *buffer,
229  uint32_t &bytesRead,
230  std::vector<uint32_t> &cksums,
231  uint16_t timeout = 0 )
232  XRD_WARN_UNUSED_RESULT;
233 
234  //------------------------------------------------------------------------
247  //------------------------------------------------------------------------
248  XRootDStatus Write( uint64_t offset,
249  uint32_t size,
250  const void *buffer,
251  ResponseHandler *handler,
252  uint16_t timeout = 0 )
253  XRD_WARN_UNUSED_RESULT;
254 
255  //------------------------------------------------------------------------
268  //------------------------------------------------------------------------
269  XRootDStatus Write( uint64_t offset,
270  uint32_t size,
271  const void *buffer,
272  uint16_t timeout = 0 )
273  XRD_WARN_UNUSED_RESULT;
274 
275  //------------------------------------------------------------------------
286  //------------------------------------------------------------------------
287  XRootDStatus PgWrite( uint64_t offset,
288  uint32_t size,
289  const void *buffer,
290  std::vector<uint32_t> &cksums,
291  ResponseHandler *handler,
292  uint16_t timeout = 0 )
293  XRD_WARN_UNUSED_RESULT;
294 
295  //------------------------------------------------------------------------
305  //------------------------------------------------------------------------
306  XRootDStatus PgWrite( uint64_t offset,
307  uint32_t size,
308  const void *buffer,
309  std::vector<uint32_t> &cksums,
310  uint16_t timeout = 0 )
311  XRD_WARN_UNUSED_RESULT;
312 
313  //------------------------------------------------------------------------
320  //------------------------------------------------------------------------
322  uint16_t timeout = 0 )
323  XRD_WARN_UNUSED_RESULT;
324 
325 
326  //------------------------------------------------------------------------
332  //------------------------------------------------------------------------
333  XRootDStatus Sync( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
334 
335  //------------------------------------------------------------------------
343  //------------------------------------------------------------------------
344  XRootDStatus Truncate( uint64_t size,
345  ResponseHandler *handler,
346  uint16_t timeout = 0 )
347  XRD_WARN_UNUSED_RESULT;
348 
349 
350  //------------------------------------------------------------------------
357  //------------------------------------------------------------------------
358  XRootDStatus Truncate( uint64_t size,
359  uint16_t timeout = 0 )
360  XRD_WARN_UNUSED_RESULT;
361 
362  //------------------------------------------------------------------------
378  //------------------------------------------------------------------------
379  XRootDStatus VectorRead( const ChunkList &chunks,
380  void *buffer,
381  ResponseHandler *handler,
382  uint16_t timeout = 0 )
383  XRD_WARN_UNUSED_RESULT;
384 
385  //------------------------------------------------------------------------
401  //------------------------------------------------------------------------
402  XRootDStatus VectorRead( const ChunkList &chunks,
403  void *buffer,
404  VectorReadInfo *&vReadInfo,
405  uint16_t timeout = 0 )
406  XRD_WARN_UNUSED_RESULT;
407 
408  //------------------------------------------------------------------------
416  //------------------------------------------------------------------------
417  XRootDStatus VectorWrite( const ChunkList &chunks,
418  ResponseHandler *handler,
419  uint16_t timeout = 0 )
420  XRD_WARN_UNUSED_RESULT;
421 
422  //------------------------------------------------------------------------
429  //------------------------------------------------------------------------
430  XRootDStatus VectorWrite( const ChunkList &chunks,
431  uint16_t timeout = 0 )
432  XRD_WARN_UNUSED_RESULT;
433 
434  //------------------------------------------------------------------------
444  //------------------------------------------------------------------------
445  XRootDStatus WriteV( uint64_t offset,
446  const struct iovec *iov,
447  int iovcnt,
448  ResponseHandler *handler,
449  uint16_t timeout = 0 );
450 
451  //------------------------------------------------------------------------
461  //------------------------------------------------------------------------
462  XRootDStatus WriteV( uint64_t offset,
463  const struct iovec *iov,
464  int iovcnt,
465  uint16_t timeout = 0 );
466 
467  //------------------------------------------------------------------------
478  //------------------------------------------------------------------------
479  XRootDStatus Fcntl( const Buffer &arg,
480  ResponseHandler *handler,
481  uint16_t timeout = 0 )
482  XRD_WARN_UNUSED_RESULT;
483 
484  //------------------------------------------------------------------------
493  //------------------------------------------------------------------------
494  XRootDStatus Fcntl( const Buffer &arg,
495  Buffer *&response,
496  uint16_t timeout = 0 )
497  XRD_WARN_UNUSED_RESULT;
498 
499  //------------------------------------------------------------------------
508  //------------------------------------------------------------------------
510  uint16_t timeout = 0 )
511  XRD_WARN_UNUSED_RESULT;
512 
513  //------------------------------------------------------------------------
520  //------------------------------------------------------------------------
521  XRootDStatus Visa( Buffer *&visa,
522  uint16_t timeout = 0 )
523  XRD_WARN_UNUSED_RESULT;
524 
525  //------------------------------------------------------------------------
536  //------------------------------------------------------------------------
537  XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs,
538  ResponseHandler *handler,
539  uint16_t timeout = 0 );
540 
541  //------------------------------------------------------------------------
550  //------------------------------------------------------------------------
551  XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs,
552  std::vector<XAttrStatus> &result,
553  uint16_t timeout = 0 );
554 
555  //------------------------------------------------------------------------
566  //------------------------------------------------------------------------
567  XRootDStatus GetXAttr( const std::vector<std::string> &attrs,
568  ResponseHandler *handler,
569  uint16_t timeout = 0 );
570 
571  //------------------------------------------------------------------------
580  //------------------------------------------------------------------------
581  XRootDStatus GetXAttr( const std::vector<std::string> &attrs,
582  std::vector<XAttr> &result,
583  uint16_t timeout = 0 );
584 
585  //------------------------------------------------------------------------
596  //------------------------------------------------------------------------
597  XRootDStatus DelXAttr( const std::vector<std::string> &attrs,
598  ResponseHandler *handler,
599  uint16_t timeout = 0 );
600 
601  //------------------------------------------------------------------------
610  //------------------------------------------------------------------------
611  XRootDStatus DelXAttr( const std::vector<std::string> &attrs,
612  std::vector<XAttrStatus> &result,
613  uint16_t timeout = 0 );
614 
615  //------------------------------------------------------------------------
625  //------------------------------------------------------------------------
627  uint16_t timeout = 0 );
628 
629  //------------------------------------------------------------------------
637  //------------------------------------------------------------------------
638  XRootDStatus ListXAttr( std::vector<XAttr> &result,
639  uint16_t timeout = 0 );
640 
641  //------------------------------------------------------------------------
643  //------------------------------------------------------------------------
644  bool IsOpen() const;
645 
646  //------------------------------------------------------------------------
653  //------------------------------------------------------------------------
654  bool SetProperty( const std::string &name, const std::string &value );
655 
656  //------------------------------------------------------------------------
664  //------------------------------------------------------------------------
665  bool GetProperty( const std::string &name, std::string &value ) const;
666 
667  private:
671  };
672 }
673 
674 #endif // __XRD_CL_FILE_HH__
Close operation (.
Definition: XrdClFileOperations.hh:303
VirtRedirect
Definition: XrdClFile.hh:48
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:904
Extended attribute operation status.
Definition: XrdClXRootDResponses.hh:290
XRootDStatus GetXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
VectorRead operation (.
Definition: XrdClFileOperations.hh:577
XRootDStatus SetXAttr(const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
Object stat info.
Definition: XrdClXRootDResponses.hh:395
XRootDStatus ListXAttr(ResponseHandler *handler, uint16_t timeout=0)
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:308
VectorWrite operation (.
Definition: XrdClFileOperations.hh:634
Fcntl operation (.
Definition: XrdClFileOperations.hh:747
bool SetProperty(const std::string &name, const std::string &value)
Visa operation (.
Definition: XrdClFileOperations.hh:801
virtual ~File()
Destructor.
Access mode.
Definition: XrdClFileSystem.hh:116
Read operation (.
Definition: XrdClFileOperations.hh:245
XRootDStatus Open(const std::string &url, OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
File(bool enablePlugIns=true)
Constructor.
FileStateHandler * pStateHandler
Definition: XrdClFile.hh:668
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
WriteV operation (.
Definition: XrdClFileOperations.hh:689
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
bool pEnablePlugIns
Definition: XrdClFile.hh:670
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:38
A file.
Definition: XrdClFile.hh:44
bool IsOpen() const
Check if the file is open.
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
Request status.
Definition: XrdClXRootDResponses.hh:214
Sync operation (.
Definition: XrdClFileOperations.hh:469
XRootDStatus Truncate(uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus PgWrite(uint64_t offset, uint32_t size, const void *buffer, std::vector< uint32_t > &cksums, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Vector read info.
Definition: XrdClXRootDResponses.hh:909
Handle an async response.
Definition: XrdClXRootDResponses.hh:974
Handle the stateful operations.
Definition: XrdClFileStateHandler.hh:49
XRootDStatus DelXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
Open operation (.
Definition: XrdClFileOperations.hh:104
XRootDStatus Stat(bool force, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool GetProperty(const std::string &name, std::string &value) const
Mode
Access mode.
Definition: XrdClFileSystem.hh:121
FilePlugIn * pPlugIn
Definition: XrdClFile.hh:669
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:75
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
Definition: XrdClXRootDResponses.hh:285
Definition: XrdClFile.hh:50
Definition: XrdClFile.hh:51
Write operation (.
Definition: XrdClFileOperations.hh:411
XRootDStatus PgRead(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Binary blob representation.
Definition: XrdClBuffer.hh:33