00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // This file is part of the XRootD software suite. 00006 // 00007 // XRootD is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // XRootD is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // In applying this licence, CERN does not waive the privileges and immunities 00021 // granted to it by virtue of its status as an Intergovernmental Organization 00022 // or submit itself to any jurisdiction. 00023 //------------------------------------------------------------------------------ 00024 00025 #ifndef __XRD_CL_FILE_HH__ 00026 #define __XRD_CL_FILE_HH__ 00027 00028 #include "XrdCl/XrdClFileSystem.hh" 00029 #include "XrdCl/XrdClXRootDResponses.hh" 00030 #include "XrdOuc/XrdOucCompiler.hh" 00031 #include <stdint.h> 00032 #include <string> 00033 #include <vector> 00034 #include <sys/uio.h> 00035 00036 namespace XrdCl 00037 { 00038 class FileStateHandler; 00039 class FilePlugIn; 00040 00041 //---------------------------------------------------------------------------- 00043 //---------------------------------------------------------------------------- 00044 class File 00045 { 00046 public: 00047 00048 enum VirtRedirect 00049 { 00050 EnableVirtRedirect, 00051 DisableVirtRedirect 00052 }; 00053 00054 //------------------------------------------------------------------------ 00056 //------------------------------------------------------------------------ 00057 File( bool enablePlugIns = true ); 00058 00059 //------------------------------------------------------------------------ 00061 //------------------------------------------------------------------------ 00062 File( VirtRedirect virtRedirect, bool enablePlugIns = true ); 00063 00064 //------------------------------------------------------------------------ 00066 //------------------------------------------------------------------------ 00067 virtual ~File(); 00068 00069 //------------------------------------------------------------------------ 00079 //------------------------------------------------------------------------ 00080 XRootDStatus Open( const std::string &url, 00081 OpenFlags::Flags flags, 00082 Access::Mode mode, 00083 ResponseHandler *handler, 00084 uint16_t timeout = 0 ) 00085 XRD_WARN_UNUSED_RESULT; 00086 00087 //------------------------------------------------------------------------ 00096 //------------------------------------------------------------------------ 00097 XRootDStatus Open( const std::string &url, 00098 OpenFlags::Flags flags, 00099 Access::Mode mode = Access::None, 00100 uint16_t timeout = 0 ) 00101 XRD_WARN_UNUSED_RESULT; 00102 00103 //------------------------------------------------------------------------ 00110 //------------------------------------------------------------------------ 00111 XRootDStatus Close( ResponseHandler *handler, 00112 uint16_t timeout = 0 ) 00113 XRD_WARN_UNUSED_RESULT; 00114 00115 //------------------------------------------------------------------------ 00121 //------------------------------------------------------------------------ 00122 XRootDStatus Close( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; 00123 00124 //------------------------------------------------------------------------ 00134 //------------------------------------------------------------------------ 00135 XRootDStatus Stat( bool force, 00136 ResponseHandler *handler, 00137 uint16_t timeout = 0 ) 00138 XRD_WARN_UNUSED_RESULT; 00139 00140 //------------------------------------------------------------------------ 00148 //------------------------------------------------------------------------ 00149 XRootDStatus Stat( bool force, 00150 StatInfo *&response, 00151 uint16_t timeout = 0 ) 00152 XRD_WARN_UNUSED_RESULT; 00153 00154 00155 //------------------------------------------------------------------------ 00168 //------------------------------------------------------------------------ 00169 XRootDStatus Read( uint64_t offset, 00170 uint32_t size, 00171 void *buffer, 00172 ResponseHandler *handler, 00173 uint16_t timeout = 0 ) 00174 XRD_WARN_UNUSED_RESULT; 00175 00176 //------------------------------------------------------------------------ 00186 //------------------------------------------------------------------------ 00187 XRootDStatus Read( uint64_t offset, 00188 uint32_t size, 00189 void *buffer, 00190 uint32_t &bytesRead, 00191 uint16_t timeout = 0 ) 00192 XRD_WARN_UNUSED_RESULT; 00193 00194 //------------------------------------------------------------------------ 00206 //------------------------------------------------------------------------ 00207 XRootDStatus PgRead( uint64_t offset, 00208 uint32_t size, 00209 void *buffer, 00210 ResponseHandler *handler, 00211 uint16_t timeout = 0 ) 00212 XRD_WARN_UNUSED_RESULT; 00213 00214 //------------------------------------------------------------------------ 00225 //------------------------------------------------------------------------ 00226 XRootDStatus PgRead( uint64_t offset, 00227 uint32_t size, 00228 void *buffer, 00229 uint32_t &bytesRead, 00230 std::vector<uint32_t> &cksums, 00231 uint16_t timeout = 0 ) 00232 XRD_WARN_UNUSED_RESULT; 00233 00234 //------------------------------------------------------------------------ 00247 //------------------------------------------------------------------------ 00248 XRootDStatus Write( uint64_t offset, 00249 uint32_t size, 00250 const void *buffer, 00251 ResponseHandler *handler, 00252 uint16_t timeout = 0 ) 00253 XRD_WARN_UNUSED_RESULT; 00254 00255 //------------------------------------------------------------------------ 00268 //------------------------------------------------------------------------ 00269 XRootDStatus Write( uint64_t offset, 00270 uint32_t size, 00271 const void *buffer, 00272 uint16_t timeout = 0 ) 00273 XRD_WARN_UNUSED_RESULT; 00274 00275 //------------------------------------------------------------------------ 00286 //------------------------------------------------------------------------ 00287 XRootDStatus PgWrite( uint64_t offset, 00288 uint32_t size, 00289 const void *buffer, 00290 std::vector<uint32_t> &cksums, 00291 ResponseHandler *handler, 00292 uint16_t timeout = 0 ) 00293 XRD_WARN_UNUSED_RESULT; 00294 00295 //------------------------------------------------------------------------ 00305 //------------------------------------------------------------------------ 00306 XRootDStatus PgWrite( uint64_t offset, 00307 uint32_t size, 00308 const void *buffer, 00309 std::vector<uint32_t> &cksums, 00310 uint16_t timeout = 0 ) 00311 XRD_WARN_UNUSED_RESULT; 00312 00313 //------------------------------------------------------------------------ 00320 //------------------------------------------------------------------------ 00321 XRootDStatus Sync( ResponseHandler *handler, 00322 uint16_t timeout = 0 ) 00323 XRD_WARN_UNUSED_RESULT; 00324 00325 00326 //------------------------------------------------------------------------ 00332 //------------------------------------------------------------------------ 00333 XRootDStatus Sync( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; 00334 00335 //------------------------------------------------------------------------ 00343 //------------------------------------------------------------------------ 00344 XRootDStatus Truncate( uint64_t size, 00345 ResponseHandler *handler, 00346 uint16_t timeout = 0 ) 00347 XRD_WARN_UNUSED_RESULT; 00348 00349 00350 //------------------------------------------------------------------------ 00357 //------------------------------------------------------------------------ 00358 XRootDStatus Truncate( uint64_t size, 00359 uint16_t timeout = 0 ) 00360 XRD_WARN_UNUSED_RESULT; 00361 00362 //------------------------------------------------------------------------ 00378 //------------------------------------------------------------------------ 00379 XRootDStatus VectorRead( const ChunkList &chunks, 00380 void *buffer, 00381 ResponseHandler *handler, 00382 uint16_t timeout = 0 ) 00383 XRD_WARN_UNUSED_RESULT; 00384 00385 //------------------------------------------------------------------------ 00401 //------------------------------------------------------------------------ 00402 XRootDStatus VectorRead( const ChunkList &chunks, 00403 void *buffer, 00404 VectorReadInfo *&vReadInfo, 00405 uint16_t timeout = 0 ) 00406 XRD_WARN_UNUSED_RESULT; 00407 00408 //------------------------------------------------------------------------ 00416 //------------------------------------------------------------------------ 00417 XRootDStatus VectorWrite( const ChunkList &chunks, 00418 ResponseHandler *handler, 00419 uint16_t timeout = 0 ) 00420 XRD_WARN_UNUSED_RESULT; 00421 00422 //------------------------------------------------------------------------ 00429 //------------------------------------------------------------------------ 00430 XRootDStatus VectorWrite( const ChunkList &chunks, 00431 uint16_t timeout = 0 ) 00432 XRD_WARN_UNUSED_RESULT; 00433 00434 //------------------------------------------------------------------------ 00444 //------------------------------------------------------------------------ 00445 XRootDStatus WriteV( uint64_t offset, 00446 const struct iovec *iov, 00447 int iovcnt, 00448 ResponseHandler *handler, 00449 uint16_t timeout = 0 ); 00450 00451 //------------------------------------------------------------------------ 00461 //------------------------------------------------------------------------ 00462 XRootDStatus WriteV( uint64_t offset, 00463 const struct iovec *iov, 00464 int iovcnt, 00465 uint16_t timeout = 0 ); 00466 00467 //------------------------------------------------------------------------ 00478 //------------------------------------------------------------------------ 00479 XRootDStatus Fcntl( const Buffer &arg, 00480 ResponseHandler *handler, 00481 uint16_t timeout = 0 ) 00482 XRD_WARN_UNUSED_RESULT; 00483 00484 //------------------------------------------------------------------------ 00493 //------------------------------------------------------------------------ 00494 XRootDStatus Fcntl( const Buffer &arg, 00495 Buffer *&response, 00496 uint16_t timeout = 0 ) 00497 XRD_WARN_UNUSED_RESULT; 00498 00499 //------------------------------------------------------------------------ 00508 //------------------------------------------------------------------------ 00509 XRootDStatus Visa( ResponseHandler *handler, 00510 uint16_t timeout = 0 ) 00511 XRD_WARN_UNUSED_RESULT; 00512 00513 //------------------------------------------------------------------------ 00520 //------------------------------------------------------------------------ 00521 XRootDStatus Visa( Buffer *&visa, 00522 uint16_t timeout = 0 ) 00523 XRD_WARN_UNUSED_RESULT; 00524 00525 //------------------------------------------------------------------------ 00536 //------------------------------------------------------------------------ 00537 XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs, 00538 ResponseHandler *handler, 00539 uint16_t timeout = 0 ); 00540 00541 //------------------------------------------------------------------------ 00550 //------------------------------------------------------------------------ 00551 XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs, 00552 std::vector<XAttrStatus> &result, 00553 uint16_t timeout = 0 ); 00554 00555 //------------------------------------------------------------------------ 00566 //------------------------------------------------------------------------ 00567 XRootDStatus GetXAttr( const std::vector<std::string> &attrs, 00568 ResponseHandler *handler, 00569 uint16_t timeout = 0 ); 00570 00571 //------------------------------------------------------------------------ 00580 //------------------------------------------------------------------------ 00581 XRootDStatus GetXAttr( const std::vector<std::string> &attrs, 00582 std::vector<XAttr> &result, 00583 uint16_t timeout = 0 ); 00584 00585 //------------------------------------------------------------------------ 00596 //------------------------------------------------------------------------ 00597 XRootDStatus DelXAttr( const std::vector<std::string> &attrs, 00598 ResponseHandler *handler, 00599 uint16_t timeout = 0 ); 00600 00601 //------------------------------------------------------------------------ 00610 //------------------------------------------------------------------------ 00611 XRootDStatus DelXAttr( const std::vector<std::string> &attrs, 00612 std::vector<XAttrStatus> &result, 00613 uint16_t timeout = 0 ); 00614 00615 //------------------------------------------------------------------------ 00625 //------------------------------------------------------------------------ 00626 XRootDStatus ListXAttr( ResponseHandler *handler, 00627 uint16_t timeout = 0 ); 00628 00629 //------------------------------------------------------------------------ 00637 //------------------------------------------------------------------------ 00638 XRootDStatus ListXAttr( std::vector<XAttr> &result, 00639 uint16_t timeout = 0 ); 00640 00641 //------------------------------------------------------------------------ 00643 //------------------------------------------------------------------------ 00644 bool IsOpen() const; 00645 00646 //------------------------------------------------------------------------ 00653 //------------------------------------------------------------------------ 00654 bool SetProperty( const std::string &name, const std::string &value ); 00655 00656 //------------------------------------------------------------------------ 00664 //------------------------------------------------------------------------ 00665 bool GetProperty( const std::string &name, std::string &value ) const; 00666 00667 private: 00668 FileStateHandler *pStateHandler; 00669 FilePlugIn *pPlugIn; 00670 bool pEnablePlugIns; 00671 }; 00672 } 00673 00674 #endif // __XRD_CL_FILE_HH__