xrootd
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 "XrdCl/XrdClOptional.hh"
31 #include "XrdOuc/XrdOucCompiler.hh"
32 #include <stdint.h>
33 #include <string>
34 #include <vector>
35 #include <sys/uio.h>
36 
37 namespace XrdCl
38 {
39  class FileStateHandler;
40  class FilePlugIn;
41 
42  //----------------------------------------------------------------------------
44  //----------------------------------------------------------------------------
45  class File
46  {
47  public:
48 
50  {
53  };
54 
55  //------------------------------------------------------------------------
57  //------------------------------------------------------------------------
58  File( bool enablePlugIns = true );
59 
60  //------------------------------------------------------------------------
62  //------------------------------------------------------------------------
63  File( VirtRedirect virtRedirect, bool enablePlugIns = true );
64 
65  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  virtual ~File();
69 
70  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  XRootDStatus Open( const std::string &url,
82  OpenFlags::Flags flags,
83  Access::Mode mode,
84  ResponseHandler *handler,
85  uint16_t timeout = 0 )
87 
88  //------------------------------------------------------------------------
97  //------------------------------------------------------------------------
98  XRootDStatus Open( const std::string &url,
99  OpenFlags::Flags flags,
100  Access::Mode mode = Access::None,
101  uint16_t timeout = 0 )
103 
104  //------------------------------------------------------------------------
111  //------------------------------------------------------------------------
113  uint16_t timeout = 0 )
115 
116  //------------------------------------------------------------------------
122  //------------------------------------------------------------------------
123  XRootDStatus Close( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
124 
125  //------------------------------------------------------------------------
135  //------------------------------------------------------------------------
136  XRootDStatus Stat( bool force,
137  ResponseHandler *handler,
138  uint16_t timeout = 0 )
140 
141  //------------------------------------------------------------------------
149  //------------------------------------------------------------------------
150  XRootDStatus Stat( bool force,
151  StatInfo *&response,
152  uint16_t timeout = 0 )
154 
155 
156  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  XRootDStatus Read( uint64_t offset,
171  uint32_t size,
172  void *buffer,
173  ResponseHandler *handler,
174  uint16_t timeout = 0 )
176 
177  //------------------------------------------------------------------------
187  //------------------------------------------------------------------------
188  XRootDStatus Read( uint64_t offset,
189  uint32_t size,
190  void *buffer,
191  uint32_t &bytesRead,
192  uint16_t timeout = 0 )
194 
195  //------------------------------------------------------------------------
207  //------------------------------------------------------------------------
208  XRootDStatus PgRead( uint64_t offset,
209  uint32_t size,
210  void *buffer,
211  ResponseHandler *handler,
212  uint16_t timeout = 0 )
214 
215  //------------------------------------------------------------------------
226  //------------------------------------------------------------------------
227  XRootDStatus PgRead( uint64_t offset,
228  uint32_t size,
229  void *buffer,
230  std::vector<uint32_t> &cksums,
231  uint32_t &bytesRead,
232  uint16_t timeout = 0 )
234 
235  //------------------------------------------------------------------------
248  //------------------------------------------------------------------------
249  XRootDStatus Write( uint64_t offset,
250  uint32_t size,
251  const void *buffer,
252  ResponseHandler *handler,
253  uint16_t timeout = 0 )
255 
256  //------------------------------------------------------------------------
269  //------------------------------------------------------------------------
270  XRootDStatus Write( uint64_t offset,
271  uint32_t size,
272  const void *buffer,
273  uint16_t timeout = 0 )
275 
276  //------------------------------------------------------------------------
286  //------------------------------------------------------------------------
287  XRootDStatus Write( uint64_t offset,
288  Buffer &&buffer,
289  ResponseHandler *handler,
290  uint16_t timeout = 0 );
291 
292  //------------------------------------------------------------------------
301  //------------------------------------------------------------------------
302  XRootDStatus Write( uint64_t offset,
303  Buffer &&buffer,
304  uint16_t timeout = 0 );
305 
306  //------------------------------------------------------------------------
319  //------------------------------------------------------------------------
320  XRootDStatus Write( uint64_t offset,
321  uint32_t size,
322  Optional<uint64_t> fdoff,
323  int fd,
324  ResponseHandler *handler,
325  uint16_t timeout = 0 );
326 
327  //------------------------------------------------------------------------
339  //------------------------------------------------------------------------
340  XRootDStatus Write( uint64_t offset,
341  uint32_t size,
342  Optional<uint64_t> fdoff,
343  int fd,
344  uint16_t timeout = 0 );
345 
346  //------------------------------------------------------------------------
357  //------------------------------------------------------------------------
358  XRootDStatus PgWrite( uint64_t offset,
359  uint32_t size,
360  const void *buffer,
361  std::vector<uint32_t> &cksums,
362  ResponseHandler *handler,
363  uint16_t timeout = 0 )
365 
366  //------------------------------------------------------------------------
376  //------------------------------------------------------------------------
377  XRootDStatus PgWrite( uint64_t offset,
378  uint32_t size,
379  const void *buffer,
380  std::vector<uint32_t> &cksums,
381  uint16_t timeout = 0 )
383 
384  //------------------------------------------------------------------------
391  //------------------------------------------------------------------------
393  uint16_t timeout = 0 )
395 
396 
397  //------------------------------------------------------------------------
403  //------------------------------------------------------------------------
404  XRootDStatus Sync( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
405 
406  //------------------------------------------------------------------------
414  //------------------------------------------------------------------------
415  XRootDStatus Truncate( uint64_t size,
416  ResponseHandler *handler,
417  uint16_t timeout = 0 )
419 
420 
421  //------------------------------------------------------------------------
428  //------------------------------------------------------------------------
429  XRootDStatus Truncate( uint64_t size,
430  uint16_t timeout = 0 )
432 
433  //------------------------------------------------------------------------
449  //------------------------------------------------------------------------
450  XRootDStatus VectorRead( const ChunkList &chunks,
451  void *buffer,
452  ResponseHandler *handler,
453  uint16_t timeout = 0 )
455 
456  //------------------------------------------------------------------------
472  //------------------------------------------------------------------------
473  XRootDStatus VectorRead( const ChunkList &chunks,
474  void *buffer,
475  VectorReadInfo *&vReadInfo,
476  uint16_t timeout = 0 )
478 
479  //------------------------------------------------------------------------
487  //------------------------------------------------------------------------
488  XRootDStatus VectorWrite( const ChunkList &chunks,
489  ResponseHandler *handler,
490  uint16_t timeout = 0 )
492 
493  //------------------------------------------------------------------------
500  //------------------------------------------------------------------------
501  XRootDStatus VectorWrite( const ChunkList &chunks,
502  uint16_t timeout = 0 )
504 
505  //------------------------------------------------------------------------
515  //------------------------------------------------------------------------
516  XRootDStatus WriteV( uint64_t offset,
517  const struct iovec *iov,
518  int iovcnt,
519  ResponseHandler *handler,
520  uint16_t timeout = 0 );
521 
522  //------------------------------------------------------------------------
532  //------------------------------------------------------------------------
533  XRootDStatus WriteV( uint64_t offset,
534  const struct iovec *iov,
535  int iovcnt,
536  uint16_t timeout = 0 );
537 
538  //------------------------------------------------------------------------
548  //------------------------------------------------------------------------
549  XRootDStatus ReadV( uint64_t offset,
550  struct iovec *iov,
551  int iovcnt,
552  ResponseHandler *handler,
553  uint16_t timeout = 0 );
554 
555  //------------------------------------------------------------------------
565  //------------------------------------------------------------------------
566  XRootDStatus ReadV( uint64_t offset,
567  struct iovec *iov,
568  int iovcnt,
569  uint32_t &bytesRead,
570  uint16_t timeout = 0 );
571 
572  //------------------------------------------------------------------------
583  //------------------------------------------------------------------------
584  XRootDStatus Fcntl( const Buffer &arg,
585  ResponseHandler *handler,
586  uint16_t timeout = 0 )
588 
589  //------------------------------------------------------------------------
598  //------------------------------------------------------------------------
599  XRootDStatus Fcntl( const Buffer &arg,
600  Buffer *&response,
601  uint16_t timeout = 0 )
603 
604  //------------------------------------------------------------------------
613  //------------------------------------------------------------------------
615  uint16_t timeout = 0 )
617 
618  //------------------------------------------------------------------------
625  //------------------------------------------------------------------------
626  XRootDStatus Visa( Buffer *&visa,
627  uint16_t timeout = 0 )
629 
630  //------------------------------------------------------------------------
641  //------------------------------------------------------------------------
642  XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs,
643  ResponseHandler *handler,
644  uint16_t timeout = 0 );
645 
646  //------------------------------------------------------------------------
655  //------------------------------------------------------------------------
656  XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs,
657  std::vector<XAttrStatus> &result,
658  uint16_t timeout = 0 );
659 
660  //------------------------------------------------------------------------
671  //------------------------------------------------------------------------
672  XRootDStatus GetXAttr( const std::vector<std::string> &attrs,
673  ResponseHandler *handler,
674  uint16_t timeout = 0 );
675 
676  //------------------------------------------------------------------------
685  //------------------------------------------------------------------------
686  XRootDStatus GetXAttr( const std::vector<std::string> &attrs,
687  std::vector<XAttr> &result,
688  uint16_t timeout = 0 );
689 
690  //------------------------------------------------------------------------
701  //------------------------------------------------------------------------
702  XRootDStatus DelXAttr( const std::vector<std::string> &attrs,
703  ResponseHandler *handler,
704  uint16_t timeout = 0 );
705 
706  //------------------------------------------------------------------------
715  //------------------------------------------------------------------------
716  XRootDStatus DelXAttr( const std::vector<std::string> &attrs,
717  std::vector<XAttrStatus> &result,
718  uint16_t timeout = 0 );
719 
720  //------------------------------------------------------------------------
730  //------------------------------------------------------------------------
732  uint16_t timeout = 0 );
733 
734  //------------------------------------------------------------------------
742  //------------------------------------------------------------------------
743  XRootDStatus ListXAttr( std::vector<XAttr> &result,
744  uint16_t timeout = 0 );
745 
746  //------------------------------------------------------------------------
753  //------------------------------------------------------------------------
754  XRootDStatus TryOtherServer( uint16_t timeout = 0 );
755 
756  //------------------------------------------------------------------------
758  //------------------------------------------------------------------------
759  bool IsOpen() const;
760 
761  //------------------------------------------------------------------------
769  //------------------------------------------------------------------------
770  bool SetProperty( const std::string &name, const std::string &value );
771 
772  //------------------------------------------------------------------------
780  //------------------------------------------------------------------------
781  bool GetProperty( const std::string &name, std::string &value ) const;
782 
783  private:
787  };
788 }
789 
790 #endif // __XRD_CL_FILE_HH__
Close operation (.
Definition: XrdClFileOperations.hh:275
VirtRedirect
Definition: XrdClFile.hh:49
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:970
Extended attribute operation status.
Definition: XrdClXRootDResponses.hh:294
XRootDStatus GetXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
VectorRead operation (.
Definition: XrdClFileOperations.hh:517
XRootDStatus SetXAttr(const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
bool GetProperty(const std::string &name, std::string &value) const
Object stat info.
Definition: XrdClXRootDResponses.hh:399
XRootDStatus ListXAttr(ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus TryOtherServer(uint16_t timeout=0)
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:312
Definition: XrdClOptional.hh:43
bool IsOpen() const
Check if the file is open.
VectorWrite operation (.
Definition: XrdClFileOperations.hh:565
XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Fcntl operation (.
Definition: XrdClFileOperations.hh:660
bool SetProperty(const std::string &name, const std::string &value)
Visa operation (.
Definition: XrdClFileOperations.hh:705
virtual ~File()
Destructor.
Access mode.
Definition: XrdClFileSystem.hh:116
XRootDStatus ReadV(uint64_t offset, struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0)
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:784
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
WriteV operation (.
Definition: XrdClFileOperations.hh:611
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
Definition: XrdOucIOVec.hh:65
bool pEnablePlugIns
Definition: XrdClFile.hh:786
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:38
XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
A file.
Definition: XrdClFile.hh:45
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
Request status.
Definition: XrdClXRootDResponses.hh:218
Definition: XrdClAnyObject.hh:25
Sync operation (.
Definition: XrdClFileOperations.hh:425
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:975
Handle an async response.
Definition: XrdClXRootDResponses.hh:1040
Handle the stateful operations.
Definition: XrdClFileStateHandler.hh:79
XRootDStatus DelXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
Open operation (.
Definition: XrdClFileOperations.hh:95
XRootDStatus Stat(bool force, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Mode
Access mode.
Definition: XrdClFileSystem.hh:121
FilePlugIn * pPlugIn
Definition: XrdClFile.hh:785
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:289
Definition: XrdClFile.hh:51
Definition: XrdClFile.hh:52
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