Skip to content

Commit

Permalink
[XrdCl] Add ZipArchive::AppendFile declarative operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jan 15, 2021
1 parent 036b4b8 commit 7b53cba
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/XrdCl/XrdClZipArchive.cc
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/XrdCl/XrdClZipArchive.hh
Expand Up @@ -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 );

Expand Down
61 changes: 61 additions & 0 deletions src/XrdCl/XrdClZipOperations.hh
Expand Up @@ -366,6 +366,67 @@ namespace XrdCl
}


//----------------------------------------------------------------------------
//! AppendFile operation (@see ZipOperation)
//----------------------------------------------------------------------------
template<bool HasHndl>
class AppendFileImpl: public ZipOperation<AppendFileImpl, HasHndl, Resp<void>,
Arg<std::string>, Arg<uint32_t>, Arg<uint32_t>, Arg<const void*>>
{
public:

//------------------------------------------------------------------------
//! Inherit constructors from FileOperation (@see FileOperation)
//------------------------------------------------------------------------
using ZipOperation<AppendFileImpl, HasHndl, Resp<void>, Arg<std::string>,
Arg<uint32_t>, Arg<uint32_t>, Arg<const void*>>::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<FnArg>( this->args ).Get();
uint32_t crc32 = std::get<CrcArg>( this->args ).Get();
uint32_t size = std::get<SizeArg>( this->args ).Get();
const void *buffer = std::get<BufferArg>( 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<false> AppendFile( Ctx<ZipArchive> zip, Arg<std::string> fn,
Arg<uint32_t> crc32, Arg<uint32_t> size,
Arg<const void*> buffer, uint16_t timeout = 0 )
{
return AppendFileImpl<false>( std::move( zip ), std::move( fn ), std::move( crc32 ),
std::move( size ), std::move( buffer ) ).Timeout( timeout );
}


//----------------------------------------------------------------------------
//! CloseFile operation (@see ZipOperation)
//----------------------------------------------------------------------------
Expand Down

0 comments on commit 7b53cba

Please sign in to comment.