//------------------------------------------------------------------------------ // Copyright (c) 2011-2017 by European Organization for Nuclear Research (CERN) // Author: Krzysztof Jamrog , // Michal Simon //------------------------------------------------------------------------------ // This file is part of the XRootD software suite. // // XRootD is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XRootD is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with XRootD. If not, see . // // In applying this licence, CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. //------------------------------------------------------------------------------ #ifndef __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__ #define __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__ #include "XrdCl/XrdClFileSystem.hh" #include "XrdCl/XrdClOperations.hh" #include "XrdCl/XrdClOperationHandlers.hh" #include "XrdCl/XrdClCtx.hh" namespace XrdCl { //---------------------------------------------------------------------------- //! Base class for all file system releated operations //! //! @arg Derived : the class that derives from this template (CRTP) //! @arg HasHndl : true if operation has a handler, false otherwise //! @arg Args : operation arguments //---------------------------------------------------------------------------- template class Derived, bool HasHndl, typename Response, typename ... Args> class FileSystemOperation: public ConcreteOperation { template class, bool, typename, typename ...> friend class FileSystemOperation; public: //------------------------------------------------------------------------ //! Constructor //! //! @param fs : file system on which the operation will be performed //! @param args : file operation arguments //------------------------------------------------------------------------ FileSystemOperation( Ctx fs, Args... args): ConcreteOperation( std::move( args )... ), filesystem( std::move( fs ) ) { } //------------------------------------------------------------------------ //! Move constructor from other states //! //! @arg from : state from which the object is being converted //! //! @param op : the object that is being converted //------------------------------------------------------------------------ template FileSystemOperation( FileSystemOperation && op ): ConcreteOperation( std::move( op ) ), filesystem( op.filesystem ) { } //------------------------------------------------------------------------ //! Destructor //------------------------------------------------------------------------ virtual ~FileSystemOperation() { } protected: //------------------------------------------------------------------------ //! The file system object itself. //------------------------------------------------------------------------ Ctx filesystem; }; //---------------------------------------------------------------------------- //! Locate operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class LocateImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, FlagsArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Locate"; } 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 &path = std::get( this->args ).Get(); OpenFlags::Flags flags = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Locate( path, flags, handler, timeout ); } }; typedef LocateImpl Locate; //---------------------------------------------------------------------------- //! DeepLocate operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class DeepLocateImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, FlagsArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "DeepLocate"; } 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 &path = std::get( this->args ).Get(); OpenFlags::Flags flags = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->DeepLocate( path, flags, handler, timeout ); } }; typedef DeepLocateImpl DeepLocate; //---------------------------------------------------------------------------- //! Mv operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class MvImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { SourceArg, DestArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Mv"; } 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 &source = std::get( this->args ).Get(); std::string &dest = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Mv( source, dest, handler, timeout ); } }; typedef MvImpl Mv; //---------------------------------------------------------------------------- //! Query operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class QueryImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { QueryCodeArg, BufferArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Query"; } 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 ) { QueryCode::Code queryCode = std::get( this->args ).Get(); const Buffer &buffer( std::get( this->args ).Get() ); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Query( queryCode, buffer, handler, timeout ); } }; typedef QueryImpl Query; //---------------------------------------------------------------------------- //! Truncate operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class TruncateFsImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, SizeArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Truncate"; } 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 &path = std::get( this->args ).Get(); uint64_t size = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Truncate( path, size, handler, timeout ); } }; inline TruncateFsImpl Truncate( Ctx fs, Arg path, Arg size ) { return TruncateFsImpl( std::move( fs ), std::move( path ), std::move( size ) ); } //---------------------------------------------------------------------------- //! Rm operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class RmImpl: public FileSystemOperation, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Rm"; } 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 &path = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Rm( path, handler, timeout ); } }; typedef RmImpl Rm; //---------------------------------------------------------------------------- //! MkDir operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class MkDirImpl: public FileSystemOperation, Arg, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, FlagsArg, ModeArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "MkDir"; } 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 &path = std::get( this->args ).Get(); MkDirFlags::Flags flags = std::get( this->args ).Get(); Access::Mode mode = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->MkDir( path, flags, mode, handler, timeout ); } }; typedef MkDirImpl MkDir; //---------------------------------------------------------------------------- //! RmDir operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class RmDirImpl: public FileSystemOperation, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "RmDir"; } 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 &path = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->RmDir( path, handler, timeout ); } }; typedef RmDirImpl RmDir; //---------------------------------------------------------------------------- //! ChMod operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class ChModImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, ModeArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "ChMod"; } 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 &path = std::get( this->args ).Get(); Access::Mode mode = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->ChMod( path, mode, handler, timeout ); } }; typedef ChModImpl ChMod; //---------------------------------------------------------------------------- //! Ping operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class PingImpl: public FileSystemOperation> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation>::FileSystemOperation; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Ping"; } 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 ) { uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Ping( handler, timeout ); } }; typedef PingImpl Ping; //---------------------------------------------------------------------------- //! Stat operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class StatFsImpl: public FileSystemOperation, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Stat"; } 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 &path = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Stat( path, handler, timeout ); } }; inline StatFsImpl Stat( Ctx fs, Arg path ) { return StatFsImpl( std::move( fs ), std::move( path ) ); } //---------------------------------------------------------------------------- //! StatVS operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class StatVFSImpl: public FileSystemOperation, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "StatVFS"; } 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 &path = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->StatVFS( path, handler, timeout ); } }; typedef StatVFSImpl StatVFS; //---------------------------------------------------------------------------- //! Protocol operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class ProtocolImpl: public FileSystemOperation> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation>::FileSystemOperation; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Protocol"; } 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 ) { uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Protocol( handler, timeout ); } }; typedef ProtocolImpl Protocol; //---------------------------------------------------------------------------- //! DirList operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class DirListImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, FlagsArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "DirList"; } 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 &path = std::get( this->args ).Get(); DirListFlags::Flags flags = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->DirList( path, flags, handler, timeout ); } }; typedef DirListImpl DirList; //---------------------------------------------------------------------------- //! SendInfo operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class SendInfoImpl: public FileSystemOperation, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { InfoArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "SendInfo"; } 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 &info = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->SendInfo( info, handler, timeout ); } }; typedef SendInfoImpl SendInfo; //---------------------------------------------------------------------------- //! Prepare operation (@see FileSystemOperation) //---------------------------------------------------------------------------- template class PrepareImpl: public FileSystemOperation, Arg>, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileSystemOperation (@see FileSystemOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg>, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { FileListArg, FlagsArg, PriorityArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "Prepare"; } 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::vector &fileList = std::get( this->args ).Get(); PrepareFlags::Flags flags = std::get( this->args ).Get(); uint8_t priority = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Prepare( fileList, flags, priority, handler, timeout ); } }; typedef PrepareImpl Prepare; //---------------------------------------------------------------------------- //! SetXAttr operation (@see FileOperation) //---------------------------------------------------------------------------- template class SetXAttrFsImpl: public FileSystemOperation, Arg, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, NameArg, ValueArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "SetXAttrFsImpl"; } 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 &path = std::get( this->args ).Get(); std::string &name = std::get( this->args ).Get(); std::string &value = std::get( this->args ).Get(); // wrap the arguments with a vector std::vector attrs; attrs.push_back( xattr_t( name, value ) ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttrStatus *h = new UnpackXAttrStatus( handler ); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->filesystem->SetXAttr( path, attrs, h, timeout ); if( !st.IsOK() ) delete h; return st; } }; //---------------------------------------------------------------------------- //! Factory for creating SetXAttrFsImpl objects (as there is another SetXAttr //! in File there would be a clash of typenames). //---------------------------------------------------------------------------- inline SetXAttrFsImpl SetXAttr( Ctx fs, Arg path, Arg name, Arg value ) { return SetXAttrFsImpl( std::move( fs ), std::move( path ), std::move( name ), std::move( value ) ); } //---------------------------------------------------------------------------- //! SetXAttr bulk operation (@see FileOperation) //---------------------------------------------------------------------------- template class SetXAttrFsBulkImpl: public FileSystemOperation>, Arg, Arg>> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation>, Arg, Arg>>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, AttrsArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "SetXAttrBulkImpl"; } protected: //------------------------------------------------------------------------ //! RunImpl operation (@see Operation) //! //! @return : status of the operation //------------------------------------------------------------------------ XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::vector &attrs = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->SetXAttr( path, attrs, handler, timeout ); } }; //---------------------------------------------------------------------------- //! Factory for creating SetXAttrFsBulkImpl objects (as there is another SetXAttr //! in FileSystem there would be a clash of typenames). //---------------------------------------------------------------------------- inline SetXAttrFsBulkImpl SetXAttr( Ctx fs, Arg path, Arg> attrs ) { return SetXAttrFsBulkImpl( std::move( fs ), std::move( path ), std::move( attrs ) ); } //---------------------------------------------------------------------------- //! GetXAttr operation (@see FileOperation) //---------------------------------------------------------------------------- template class GetXAttrFsImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, NameArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "GetXAttrFsImpl"; } protected: //------------------------------------------------------------------------ //! RunImpl operation (@see Operation) //! //! @return : status of the operation //------------------------------------------------------------------------ XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::string &name = std::get( this->args ).Get(); // wrap the argument with a vector std::vector attrs; attrs.push_back( name ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttr *h = new UnpackXAttr( handler ); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->filesystem->GetXAttr( path, attrs, h, timeout ); if( !st.IsOK() ) delete h; return st; } }; //---------------------------------------------------------------------------- //! Factory for creating GetXAttrFsImpl objects (as there is another GetXAttr //! in File there would be a clash of typenames). //---------------------------------------------------------------------------- inline GetXAttrFsImpl GetXAttr( Ctx fs, Arg path, Arg name ) { return GetXAttrFsImpl( std::move( fs ), std::move( path ), std::move( name ) ); } //---------------------------------------------------------------------------- //! GetXAttr bulk operation (@see FileOperation) //---------------------------------------------------------------------------- template class GetXAttrFsBulkImpl: public FileSystemOperation>, Arg, Arg>> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation>, Arg, Arg>>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, NamesArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "GetXAttrFsBulkImpl"; } protected: //------------------------------------------------------------------------ //! RunImpl operation (@see Operation) //! //! @return : status of the operation //------------------------------------------------------------------------ XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::vector &attrs = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->GetXAttr( path, attrs, handler, timeout ); } }; //---------------------------------------------------------------------------- //! Factory for creating GetXAttrFsBulkImpl objects (as there is another GetXAttr in //! FileSystem there would be a clash of typenames). //---------------------------------------------------------------------------- inline GetXAttrFsBulkImpl GetXAttr( Ctx fs, Arg path, Arg> attrs ) { return GetXAttrFsBulkImpl( std::move( fs ), std::move( path ), std::move( attrs ) ); } //---------------------------------------------------------------------------- //! DelXAttr operation (@see FileOperation) //---------------------------------------------------------------------------- template class DelXAttrFsImpl: public FileSystemOperation, Arg, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation, Arg, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, NameArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "DelXAttrFsImpl"; } 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 &path = std::get( this->args ).Get(); std::string &name = std::get( this->args ).Get(); // wrap the argument with a vector std::vector attrs; attrs.push_back( name ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttrStatus *h = new UnpackXAttrStatus( handler ); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->filesystem->DelXAttr( path, attrs, h, timeout ); if( !st.IsOK() ) delete h; return st; } }; //---------------------------------------------------------------------------- //! Factory for creating DelXAttrFsImpl objects (as there is another DelXAttr //! in File there would be a clash of typenames). //---------------------------------------------------------------------------- inline DelXAttrFsImpl DelXAttr( Ctx fs, Arg path, Arg name ) { return DelXAttrFsImpl( std::move( fs ), std::move( path ), std::move( name ) ); } //---------------------------------------------------------------------------- //! DelXAttr bulk operation (@see FileOperation) //---------------------------------------------------------------------------- template class DelXAttrFsBulkImpl: public FileSystemOperation>, Arg, Arg>> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation>, Arg, Arg>>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg, NamesArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "DelXAttrBulkImpl"; } 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 &path = std::get( this->args ).Get(); std::vector &attrs = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->DelXAttr( path, attrs, handler, timeout ); } }; //---------------------------------------------------------------------------- //! Factory for creating DelXAttrFsBulkImpl objects (as there is another DelXAttr //! in FileSystem there would be a clash of typenames). //---------------------------------------------------------------------------- inline DelXAttrFsBulkImpl DelXAttr( Ctx fs, Arg path, Arg> attrs ) { return DelXAttrFsBulkImpl( std::move( fs ), std::move( path ), std::move( attrs ) ); } //---------------------------------------------------------------------------- //! ListXAttr bulk operation (@see FileOperation) //---------------------------------------------------------------------------- template class ListXAttrFsImpl: public FileSystemOperation>, Arg> { public: //------------------------------------------------------------------------ //! Inherit constructors from FileOperation (@see FileOperation) //------------------------------------------------------------------------ using FileSystemOperation>, Arg>::FileSystemOperation; //------------------------------------------------------------------------ //! Argument indexes in the args tuple //------------------------------------------------------------------------ enum { PathArg }; //------------------------------------------------------------------------ //! @return : name of the operation (@see Operation) //------------------------------------------------------------------------ std::string ToString() { return "ListXAttrFsImpl"; } 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 &path = std::get( this->args ).Get(); uint16_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->ListXAttr( path, handler, timeout ); } }; //---------------------------------------------------------------------------- //! Factory for creating ListXAttrFsImpl objects (as there is another ListXAttr //! in FileSystem there would be a clash of typenames). //---------------------------------------------------------------------------- inline ListXAttrFsImpl ListXAttr( Ctx fs, Arg path ) { return ListXAttrFsImpl( std::move( fs ), std::move( path ) ); } } #endif // __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__