xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <cstdint>
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 )
114  XRD_WARN_UNUSED_RESULT;
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 )
139  XRD_WARN_UNUSED_RESULT;
140 
141  //------------------------------------------------------------------------
149  //------------------------------------------------------------------------
150  XRootDStatus Stat( bool force,
151  StatInfo *&response,
152  uint16_t timeout = 0 )
153  XRD_WARN_UNUSED_RESULT;
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 )
175  XRD_WARN_UNUSED_RESULT;
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 )
193  XRD_WARN_UNUSED_RESULT;
194 
195  //------------------------------------------------------------------------
207  //------------------------------------------------------------------------
208  XRootDStatus PgRead( uint64_t offset,
209  uint32_t size,
210  void *buffer,
211  ResponseHandler *handler,
212  uint16_t timeout = 0 )
213  XRD_WARN_UNUSED_RESULT;
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 )
233  XRD_WARN_UNUSED_RESULT;
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 )
254  XRD_WARN_UNUSED_RESULT;
255 
256  //------------------------------------------------------------------------
269  //------------------------------------------------------------------------
270  XRootDStatus Write( uint64_t offset,
271  uint32_t size,
272  const void *buffer,
273  uint16_t timeout = 0 )
274  XRD_WARN_UNUSED_RESULT;
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 )
364  XRD_WARN_UNUSED_RESULT;
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 )
382  XRD_WARN_UNUSED_RESULT;
383 
384  //------------------------------------------------------------------------
391  //------------------------------------------------------------------------
393  uint16_t timeout = 0 )
394  XRD_WARN_UNUSED_RESULT;
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 )
418  XRD_WARN_UNUSED_RESULT;
419 
420 
421  //------------------------------------------------------------------------
428  //------------------------------------------------------------------------
429  XRootDStatus Truncate( uint64_t size,
430  uint16_t timeout = 0 )
431  XRD_WARN_UNUSED_RESULT;
432 
433  //------------------------------------------------------------------------
449  //------------------------------------------------------------------------
450  XRootDStatus VectorRead( const ChunkList &chunks,
451  void *buffer,
452  ResponseHandler *handler,
453  uint16_t timeout = 0 )
454  XRD_WARN_UNUSED_RESULT;
455 
456  //------------------------------------------------------------------------
472  //------------------------------------------------------------------------
473  XRootDStatus VectorRead( const ChunkList &chunks,
474  void *buffer,
475  VectorReadInfo *&vReadInfo,
476  uint16_t timeout = 0 )
477  XRD_WARN_UNUSED_RESULT;
478 
479  //------------------------------------------------------------------------
487  //------------------------------------------------------------------------
488  XRootDStatus VectorWrite( const ChunkList &chunks,
489  ResponseHandler *handler,
490  uint16_t timeout = 0 )
491  XRD_WARN_UNUSED_RESULT;
492 
493  //------------------------------------------------------------------------
500  //------------------------------------------------------------------------
501  XRootDStatus VectorWrite( const ChunkList &chunks,
502  uint16_t timeout = 0 )
503  XRD_WARN_UNUSED_RESULT;
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 )
587  XRD_WARN_UNUSED_RESULT;
588 
589  //------------------------------------------------------------------------
598  //------------------------------------------------------------------------
599  XRootDStatus Fcntl( const Buffer &arg,
600  Buffer *&response,
601  uint16_t timeout = 0 )
602  XRD_WARN_UNUSED_RESULT;
603 
604  //------------------------------------------------------------------------
613  //------------------------------------------------------------------------
615  uint16_t timeout = 0 )
616  XRD_WARN_UNUSED_RESULT;
617 
618  //------------------------------------------------------------------------
625  //------------------------------------------------------------------------
626  XRootDStatus Visa( Buffer *&visa,
627  uint16_t timeout = 0 )
628  XRD_WARN_UNUSED_RESULT;
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  //------------------------------------------------------------------------
763  //------------------------------------------------------------------------
764  bool IsSecure() const;
765 
766  //------------------------------------------------------------------------
774  //------------------------------------------------------------------------
775  bool SetProperty( const std::string &name, const std::string &value );
776 
777  //------------------------------------------------------------------------
785  //------------------------------------------------------------------------
786  bool GetProperty( const std::string &name, std::string &value ) const;
787 
788  private:
789 
790  template<bool HasHndl>
791  friend class CheckpointImpl;
792 
793  template<bool HasHndl>
794  friend class ChkptWrtImpl;
795 
796  template <bool HasHndl>
797  friend class ChkptWrtVImpl;
798 
799  //------------------------------------------------------------------------
809  //------------------------------------------------------------------------
811  ResponseHandler *handler,
812  uint16_t timeout = 0 );
813 
814  //------------------------------------------------------------------------
824  //------------------------------------------------------------------------
825  XRootDStatus ChkptWrt( uint64_t offset,
826  uint32_t size,
827  const void *buffer,
828  ResponseHandler *handler,
829  uint16_t timeout = 0 );
830 
831  //------------------------------------------------------------------------
841  //------------------------------------------------------------------------
842  XRootDStatus ChkptWrtV( uint64_t offset,
843  const struct iovec *iov,
844  int iovcnt,
845  ResponseHandler *handler,
846  uint16_t timeout = 0 );
847 
851  };
852 }
853 
854 #endif // __XRD_CL_FILE_HH__
unsigned char kXR_char
Definition: XPtypes.hh:65
XRootDStatus VectorRead(const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus WriteV(uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus ChkptWrt(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0)
VirtRedirect
Definition: XrdClFile.hh:49
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:1046
Extended attribute operation status.
Definition: XrdClXRootDResponses.hh:294
XRootDStatus GetXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus SetXAttr(const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
Object stat info.
Definition: XrdClXRootDResponses.hh:399
bool IsSecure() const
Check if the file is using an encrypted connection.
XRootDStatus ListXAttr(ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Sync(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus TryOtherServer(uint16_t timeout=0)
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:312
XRootDStatus Checkpoint(kXR_char code, ResponseHandler *handler, uint16_t timeout=0)
Definition: XrdClOptional.hh:43
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:883
bool SetProperty(const std::string &name, const std::string &value)
Visa operation (.
Definition: XrdClFileOperations.hh:928
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:848
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
Definition: XrdOucIOVec.hh:65
bool pEnablePlugIns
Definition: XrdClFile.hh:850
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
XRootDStatus Close(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool IsOpen() const
Check if the file is open.
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
Request status.
Definition: XrdClXRootDResponses.hh:218
Checkpointed write operation (.
Definition: XrdClCheckpointOperation.hh:82
XRootDStatus Truncate(uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus VectorWrite(const ChunkList &chunks, 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:1051
Handle an async response.
Definition: XrdClXRootDResponses.hh:1116
Handle the stateful operations.
Definition: XrdClFileStateHandler.hh:79
XRootDStatus DelXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
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
Checkpointed WriteV operation (.
Definition: XrdClCheckpointOperation.hh:142
FilePlugIn * pPlugIn
Definition: XrdClFile.hh:849
XRootDStatus ChkptWrtV(uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0)
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
Checkpoint operation (.
Definition: XrdClCheckpointOperation.hh:27
Binary blob representation.
Definition: XrdClBuffer.hh:33