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 //------------------------------------------------------------------------ 00207 //------------------------------------------------------------------------ 00208 XRootDStatus Write( uint64_t offset, 00209 uint32_t size, 00210 const void *buffer, 00211 ResponseHandler *handler, 00212 uint16_t timeout = 0 ) 00213 XRD_WARN_UNUSED_RESULT; 00214 00215 //------------------------------------------------------------------------ 00228 //------------------------------------------------------------------------ 00229 XRootDStatus Write( uint64_t offset, 00230 uint32_t size, 00231 const void *buffer, 00232 uint16_t timeout = 0 ) 00233 XRD_WARN_UNUSED_RESULT; 00234 00235 //------------------------------------------------------------------------ 00242 //------------------------------------------------------------------------ 00243 XRootDStatus Sync( ResponseHandler *handler, 00244 uint16_t timeout = 0 ) 00245 XRD_WARN_UNUSED_RESULT; 00246 00247 00248 //------------------------------------------------------------------------ 00254 //------------------------------------------------------------------------ 00255 XRootDStatus Sync( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; 00256 00257 //------------------------------------------------------------------------ 00265 //------------------------------------------------------------------------ 00266 XRootDStatus Truncate( uint64_t size, 00267 ResponseHandler *handler, 00268 uint16_t timeout = 0 ) 00269 XRD_WARN_UNUSED_RESULT; 00270 00271 00272 //------------------------------------------------------------------------ 00279 //------------------------------------------------------------------------ 00280 XRootDStatus Truncate( uint64_t size, 00281 uint16_t timeout = 0 ) 00282 XRD_WARN_UNUSED_RESULT; 00283 00284 //------------------------------------------------------------------------ 00300 //------------------------------------------------------------------------ 00301 XRootDStatus VectorRead( const ChunkList &chunks, 00302 void *buffer, 00303 ResponseHandler *handler, 00304 uint16_t timeout = 0 ) 00305 XRD_WARN_UNUSED_RESULT; 00306 00307 //------------------------------------------------------------------------ 00323 //------------------------------------------------------------------------ 00324 XRootDStatus VectorRead( const ChunkList &chunks, 00325 void *buffer, 00326 VectorReadInfo *&vReadInfo, 00327 uint16_t timeout = 0 ) 00328 XRD_WARN_UNUSED_RESULT; 00329 00330 //------------------------------------------------------------------------ 00340 //------------------------------------------------------------------------ 00341 XRootDStatus WriteV( uint64_t offset, 00342 const struct iovec *iov, 00343 int iovcnt, 00344 ResponseHandler *handler, 00345 uint16_t timeout = 0 ); 00346 00347 //------------------------------------------------------------------------ 00357 //------------------------------------------------------------------------ 00358 XRootDStatus WriteV( uint64_t offset, 00359 const struct iovec *iov, 00360 int iovcnt, 00361 uint16_t timeout = 0 ); 00362 00363 //------------------------------------------------------------------------ 00374 //------------------------------------------------------------------------ 00375 XRootDStatus Fcntl( const Buffer &arg, 00376 ResponseHandler *handler, 00377 uint16_t timeout = 0 ) 00378 XRD_WARN_UNUSED_RESULT; 00379 00380 //------------------------------------------------------------------------ 00389 //------------------------------------------------------------------------ 00390 XRootDStatus Fcntl( const Buffer &arg, 00391 Buffer *&response, 00392 uint16_t timeout = 0 ) 00393 XRD_WARN_UNUSED_RESULT; 00394 00395 //------------------------------------------------------------------------ 00404 //------------------------------------------------------------------------ 00405 XRootDStatus Visa( ResponseHandler *handler, 00406 uint16_t timeout = 0 ) 00407 XRD_WARN_UNUSED_RESULT; 00408 00409 //------------------------------------------------------------------------ 00416 //------------------------------------------------------------------------ 00417 XRootDStatus Visa( Buffer *&visa, 00418 uint16_t timeout = 0 ) 00419 XRD_WARN_UNUSED_RESULT; 00420 00421 //------------------------------------------------------------------------ 00423 //------------------------------------------------------------------------ 00424 bool IsOpen() const; 00425 00426 //------------------------------------------------------------------------ 00433 //------------------------------------------------------------------------ 00434 bool SetProperty( const std::string &name, const std::string &value ); 00435 00436 //------------------------------------------------------------------------ 00444 //------------------------------------------------------------------------ 00445 bool GetProperty( const std::string &name, std::string &value ) const; 00446 00447 private: 00448 FileStateHandler *pStateHandler; 00449 FilePlugIn *pPlugIn; 00450 bool pEnablePlugIns; 00451 }; 00452 } 00453 00454 #endif // __XRD_CL_FILE_HH__