diff --git a/src/XrdCl/XrdClZipArchive.cc b/src/XrdCl/XrdClZipArchive.cc index 8aa01746888..04532007ebd 100644 --- a/src/XrdCl/XrdClZipArchive.cc +++ b/src/XrdCl/XrdClZipArchive.cc @@ -761,7 +761,7 @@ namespace XrdCl XRootDStatus ZipArchive::AppendFile( const std::string &fn, uint32_t crc32, uint32_t size, - void *buffer, + const void *buffer, ResponseHandler *handler, uint16_t timeout ) { diff --git a/src/XrdCl/XrdClZipArchive.hh b/src/XrdCl/XrdClZipArchive.hh index da708a95c66..7e04fc164d1 100644 --- a/src/XrdCl/XrdClZipArchive.hh +++ b/src/XrdCl/XrdClZipArchive.hh @@ -178,7 +178,7 @@ namespace XrdCl XRootDStatus AppendFile( const std::string &fn, uint32_t crc32, uint32_t size, - void *buffer, + const void *buffer, ResponseHandler *handler, uint16_t timeout = 0 ); diff --git a/src/XrdCl/XrdClZipOperations.hh b/src/XrdCl/XrdClZipOperations.hh index 5f665ab29c1..d8a35bca498 100644 --- a/src/XrdCl/XrdClZipOperations.hh +++ b/src/XrdCl/XrdClZipOperations.hh @@ -366,6 +366,67 @@ namespace XrdCl } + //---------------------------------------------------------------------------- + //! AppendFile operation (@see ZipOperation) + //---------------------------------------------------------------------------- + template + class AppendFileImpl: public ZipOperation, + Arg, Arg, Arg, Arg> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using ZipOperation, Arg, + Arg, Arg, Arg>::ZipOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { FnArg, CrcArg, SizeArg, BufferArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "AppendFile"; + } + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @param params : container with parameters forwarded from + //! previous operation + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + { + std::string fn = std::get( this->args ).Get(); + uint32_t crc32 = std::get( this->args ).Get(); + uint32_t size = std::get( this->args ).Get(); + const void *buffer = std::get( this->args ).Get(); + uint16_t timeout = pipelineTimeout < this->timeout ? + pipelineTimeout : this->timeout; + return this->zip->AppendFile( fn, crc32, size, buffer, handler, timeout ); + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating ArchiveReadImpl objects + //---------------------------------------------------------------------------- + inline AppendFileImpl AppendFile( Ctx zip, Arg fn, + Arg crc32, Arg size, + Arg buffer, uint16_t timeout = 0 ) + { + return AppendFileImpl( std::move( zip ), std::move( fn ), std::move( crc32 ), + std::move( size ), std::move( buffer ) ).Timeout( timeout ); + } + + //---------------------------------------------------------------------------- //! CloseFile operation (@see ZipOperation) //----------------------------------------------------------------------------