00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__
00027 #define __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__
00028
00029 #include "XrdCl/XrdClFileSystem.hh"
00030 #include "XrdCl/XrdClOperations.hh"
00031 #include "XrdCl/XrdClOperationHandlers.hh"
00032
00033 namespace XrdCl
00034 {
00035
00036
00042
00043 template<template<bool> class Derived, bool HasHndl, typename Response, typename ... Args>
00044 class FileSystemOperation: public ConcreteOperation<Derived, HasHndl, Response, Args...>
00045 {
00046
00047 template<template<bool> class, bool, typename, typename ...> friend class FileSystemOperation;
00048
00049 public:
00050
00055
00056 FileSystemOperation( FileSystem *fs, Args... args): ConcreteOperation<Derived,
00057 false, Response, Args...>( std::move( args )... ), filesystem(fs)
00058 {
00059 }
00060
00061
00066
00067 FileSystemOperation( FileSystem &fs, Args... args): FileSystemOperation( &fs, std::move( args )... )
00068 {
00069 }
00070
00071
00077
00078 template<bool from>
00079 FileSystemOperation( FileSystemOperation<Derived, from, Response, Args...> && op ):
00080 ConcreteOperation<Derived, HasHndl, Response, Args...>( std::move( op ) ), filesystem( op.filesystem )
00081 {
00082 }
00083
00084
00086
00087 virtual ~FileSystemOperation()
00088 {
00089 }
00090
00091 protected:
00092
00093
00095
00096 FileSystem *filesystem;
00097 };
00098
00099
00101
00102 template<bool HasHndl>
00103 class LocateImpl: public FileSystemOperation<LocateImpl, HasHndl, Resp<LocationInfo>,
00104 Arg<std::string>, Arg<OpenFlags::Flags>>
00105 {
00106 public:
00107
00108
00110
00111 using FileSystemOperation<LocateImpl, HasHndl, Resp<LocationInfo>, Arg<std::string>,
00112 Arg<OpenFlags::Flags>>::FileSystemOperation;
00113
00114
00116
00117 enum { PathArg, FlagsArg };
00118
00119
00121
00122 std::string ToString()
00123 {
00124 return "Locate";
00125 }
00126
00127 protected:
00128
00129
00135
00136 XRootDStatus RunImpl()
00137 {
00138 try
00139 {
00140 std::string path = std::get<PathArg>( this->args ).Get();
00141 OpenFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
00142 return this->filesystem->Locate( path, flags, this->handler.get() );
00143 }
00144 catch( const PipelineException& ex )
00145 {
00146 return ex.GetError();
00147 }
00148 catch( const std::exception& ex )
00149 {
00150 return XRootDStatus( stError, ex.what() );
00151 }
00152 }
00153 };
00154 typedef LocateImpl<false> Locate;
00155
00156
00158
00159 template<bool HasHndl>
00160 class DeepLocateImpl: public FileSystemOperation<DeepLocateImpl, HasHndl,
00161 Resp<LocationInfo>, Arg<std::string>, Arg<OpenFlags::Flags>>
00162 {
00163 public:
00164
00165
00167
00168 using FileSystemOperation<DeepLocateImpl, HasHndl, Resp<LocationInfo>, Arg<std::string>,
00169 Arg<OpenFlags::Flags>>::FileSystemOperation;
00170
00171
00173
00174 enum { PathArg, FlagsArg };
00175
00176
00178
00179 std::string ToString()
00180 {
00181 return "DeepLocate";
00182 }
00183
00184 protected:
00185
00186
00192
00193 XRootDStatus RunImpl()
00194 {
00195 try
00196 {
00197 std::string path = std::get<PathArg>( this->args ).Get();
00198 OpenFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
00199 return this->filesystem->DeepLocate( path, flags, this->handler.get() );
00200 }
00201 catch( const PipelineException& ex )
00202 {
00203 return ex.GetError();
00204 }
00205 catch( const std::exception& ex )
00206 {
00207 return XRootDStatus( stError, ex.what() );
00208 }
00209 }
00210 };
00211 typedef DeepLocateImpl<false> DeepLocate;
00212
00213
00215
00216 template<bool HasHndl>
00217 class MvImpl: public FileSystemOperation<MvImpl, HasHndl, Resp<void>, Arg<std::string>,
00218 Arg<std::string>>
00219 {
00220 public:
00221
00222
00224
00225 using FileSystemOperation<MvImpl, HasHndl, Resp<void>, Arg<std::string>,
00226 Arg<std::string>>::FileSystemOperation;
00227
00228
00230
00231 enum { SourceArg, DestArg };
00232
00233
00235
00236 std::string ToString()
00237 {
00238 return "Mv";
00239 }
00240
00241 protected:
00242
00243
00249
00250 XRootDStatus RunImpl()
00251 {
00252 try
00253 {
00254 std::string source = std::get<SourceArg>( this->args ).Get();
00255 std::string dest = std::get<DestArg>( this->args ).Get();
00256 return this->filesystem->Mv( source, dest, this->handler.get() );
00257 }
00258 catch( const PipelineException& ex )
00259 {
00260 return ex.GetError();
00261 }
00262 catch( const std::exception& ex )
00263 {
00264 return XRootDStatus( stError, ex.what() );
00265 }
00266 }
00267 };
00268 typedef MvImpl<false> Mv;
00269
00270
00272
00273 template<bool HasHndl>
00274 class QueryImpl: public FileSystemOperation<QueryImpl, HasHndl, Resp<Buffer>,
00275 Arg<QueryCode::Code>, Arg<Buffer>>
00276 {
00277 public:
00278
00279
00281
00282 using FileSystemOperation<QueryImpl, HasHndl, Resp<Buffer>, Arg<QueryCode::Code>,
00283 Arg<Buffer>>::FileSystemOperation;
00284
00285
00287
00288 enum { QueryCodeArg, BufferArg };
00289
00290
00292
00293 std::string ToString()
00294 {
00295 return "Query";
00296 }
00297
00298 protected:
00299
00300
00306
00307 XRootDStatus RunImpl()
00308 {
00309 try
00310 {
00311 QueryCode::Code queryCode = std::get<QueryCodeArg>( this->args ).Get();
00312 const Buffer buffer( std::get<BufferArg>( this->args ).Get() );
00313 return this->filesystem->Query( queryCode, buffer, this->handler.get() );
00314 }
00315 catch( const PipelineException& ex )
00316 {
00317 return ex.GetError();
00318 }
00319 catch( const std::exception& ex )
00320 {
00321 return XRootDStatus( stError, ex.what() );
00322 }
00323 }
00324 };
00325 typedef QueryImpl<false> Query;
00326
00327
00329
00330 template<bool HasHndl>
00331 class TruncateFsImpl: public FileSystemOperation<TruncateFsImpl, HasHndl, Resp<void>,
00332 Arg<std::string>, Arg<uint64_t>>
00333 {
00334 public:
00335
00336
00338
00339 using FileSystemOperation<TruncateFsImpl, HasHndl, Resp<void>, Arg<std::string>,
00340 Arg<uint64_t>>::FileSystemOperation;
00341
00342
00344
00345 enum { PathArg, SizeArg };
00346
00347
00349
00350 std::string ToString()
00351 {
00352 return "Truncate";
00353 }
00354
00355 protected:
00356
00357
00363
00364 XRootDStatus RunImpl()
00365 {
00366 try
00367 {
00368 std::string path = std::get<PathArg>( this->args ).Get();
00369 uint64_t size = std::get<SizeArg>( this->args ).Get();
00370 return this->filesystem->Truncate( path, size, this->handler.get() );
00371 }
00372 catch( const PipelineException& ex )
00373 {
00374 return ex.GetError();
00375 }
00376 catch( const std::exception& ex )
00377 {
00378 return XRootDStatus( stError, ex.what() );
00379 }
00380 }
00381 };
00382
00383 inline TruncateFsImpl<false> Truncate( FileSystem *fs, Arg<std::string> path, Arg<uint64_t> size )
00384 {
00385 return TruncateFsImpl<false>( fs, std::move( path ), std::move( size ) );
00386 }
00387
00388 inline TruncateFsImpl<false> Truncate( FileSystem &fs, Arg<std::string> path, Arg<uint64_t> size )
00389 {
00390 return TruncateFsImpl<false>( fs, std::move( path ), std::move( size ) );
00391 }
00392
00393
00395
00396 template<bool HasHndl>
00397 class RmImpl: public FileSystemOperation<RmImpl, HasHndl, Resp<void>, Arg<std::string>>
00398 {
00399 public:
00400
00401
00403
00404 using FileSystemOperation<RmImpl, HasHndl, Resp<void>, Arg<std::string>>::FileSystemOperation;
00405
00406
00408
00409 enum { PathArg };
00410
00411
00413
00414 std::string ToString()
00415 {
00416 return "Rm";
00417 }
00418
00419 protected:
00420
00421
00427
00428 XRootDStatus RunImpl()
00429 {
00430 try
00431 {
00432 std::string path = std::get<PathArg>( this->args ).Get();
00433 return this->filesystem->Rm( path, this->handler.get() );
00434 }
00435 catch( const PipelineException& ex )
00436 {
00437 return ex.GetError();
00438 }
00439 catch( const std::exception& ex )
00440 {
00441 return XRootDStatus( stError, ex.what() );
00442 }
00443 }
00444 };
00445 typedef RmImpl<false> Rm;
00446
00447
00449
00450 template<bool HasHndl>
00451 class MkDirImpl: public FileSystemOperation<MkDirImpl, HasHndl, Resp<void>,
00452 Arg<std::string>, Arg<MkDirFlags::Flags>, Arg<Access::Mode>>
00453 {
00454 public:
00455
00456
00458
00459 using FileSystemOperation<MkDirImpl, HasHndl, Resp<void>, Arg<std::string>,
00460 Arg<MkDirFlags::Flags>, Arg<Access::Mode>>::FileSystemOperation;
00461
00462
00464
00465 enum { PathArg, FlagsArg, ModeArg };
00466
00467
00469
00470 std::string ToString()
00471 {
00472 return "MkDir";
00473 }
00474
00475 protected:
00476
00477
00483
00484 XRootDStatus RunImpl()
00485 {
00486 try
00487 {
00488 std::string path = std::get<PathArg>( this->args ).Get();
00489 MkDirFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
00490 Access::Mode mode = std::get<ModeArg>( this->args ).Get();
00491 return this->filesystem->MkDir( path, flags, mode, this->handler.get() );
00492 }
00493 catch( const PipelineException& ex )
00494 {
00495 return ex.GetError();
00496 }
00497 catch( const std::exception& ex )
00498 {
00499 return XRootDStatus( stError, ex.what() );
00500 }
00501 }
00502 };
00503 typedef MkDirImpl<false> MkDir;
00504
00505
00507
00508 template<bool HasHndl>
00509 class RmDirImpl: public FileSystemOperation<RmDirImpl, HasHndl, Resp<void>,
00510 Arg<std::string>>
00511 {
00512 public:
00513
00514
00516
00517 using FileSystemOperation<RmDirImpl, HasHndl, Resp<void>, Arg<std::string>>::FileSystemOperation;
00518
00519
00521
00522 enum { PathArg };
00523
00524
00526
00527 std::string ToString()
00528 {
00529 return "RmDir";
00530 }
00531
00532 protected:
00533
00534
00540
00541 XRootDStatus RunImpl()
00542 {
00543 try
00544 {
00545 std::string path = std::get<PathArg>( this->args ).Get();
00546 return this->filesystem->RmDir( path, this->handler.get() );
00547 }
00548 catch( const PipelineException& ex )
00549 {
00550 return ex.GetError();
00551 }
00552 catch( const std::exception& ex )
00553 {
00554 return XRootDStatus( stError, ex.what() );
00555 }
00556 }
00557 };
00558 typedef RmDirImpl<false> RmDir;
00559
00560
00562
00563 template<bool HasHndl>
00564 class ChModImpl: public FileSystemOperation<ChModImpl, HasHndl, Resp<void>,
00565 Arg<std::string>, Arg<Access::Mode>>
00566 {
00567 public:
00568
00569
00571
00572 using FileSystemOperation<ChModImpl, HasHndl, Resp<void>, Arg<std::string>,
00573 Arg<Access::Mode>>::FileSystemOperation;
00574
00575
00577
00578 enum { PathArg, ModeArg };
00579
00580
00582
00583 std::string ToString()
00584 {
00585 return "ChMod";
00586 }
00587
00588 protected:
00589
00590
00596
00597 XRootDStatus RunImpl()
00598 {
00599 try
00600 {
00601 std::string path = std::get<PathArg>( this->args ).Get();
00602 Access::Mode mode = std::get<ModeArg>( this->args ).Get();
00603 return this->filesystem->ChMod( path, mode, this->handler.get() );
00604 }
00605 catch( const PipelineException& ex )
00606 {
00607 return ex.GetError();
00608 }
00609 catch( const std::exception& ex )
00610 {
00611 return XRootDStatus( stError, ex.what() );
00612 }
00613 }
00614 };
00615 typedef ChModImpl<false> ChMod;
00616
00617
00619
00620 template<bool HasHndl>
00621 class PingImpl: public FileSystemOperation<PingImpl, HasHndl, Resp<void>>
00622 {
00623 public:
00624
00625
00627
00628 using FileSystemOperation<PingImpl, HasHndl, Resp<void>>::FileSystemOperation;
00629
00630
00632
00633 std::string ToString()
00634 {
00635 return "Ping";
00636 }
00637
00638 protected:
00639
00640
00646
00647 XRootDStatus RunImpl()
00648 {
00649 return this->filesystem->Ping( this->handler.get() );
00650 }
00651 };
00652 typedef PingImpl<false> Ping;
00653
00654
00656
00657 template<bool HasHndl>
00658 class StatFsImpl: public FileSystemOperation<StatFsImpl, HasHndl, Resp<StatInfo>,
00659 Arg<std::string>>
00660 {
00661 public:
00662
00663
00665
00666 using FileSystemOperation<StatFsImpl, HasHndl, Resp<StatInfo>,
00667 Arg<std::string>>::FileSystemOperation;
00668
00669
00671
00672 enum { PathArg };
00673
00674
00676
00677 std::string ToString()
00678 {
00679 return "Stat";
00680 }
00681
00682 protected:
00683
00684
00690
00691 XRootDStatus RunImpl()
00692 {
00693 try
00694 {
00695 std::string path = std::get<PathArg>( this->args ).Get();
00696 return this->filesystem->Stat( path, this->handler.get() );
00697 }
00698 catch( const PipelineException& ex )
00699 {
00700 return ex.GetError();
00701 }
00702 catch( const std::exception& ex )
00703 {
00704 return XRootDStatus( stError, ex.what() );
00705 }
00706 }
00707 };
00708
00709 inline StatFsImpl<false> Stat( FileSystem *fs, Arg<std::string> path )
00710 {
00711 return StatFsImpl<false>( fs, std::move( path ) );
00712 }
00713
00714 inline StatFsImpl<false> Stat( FileSystem &fs, Arg<std::string> path )
00715 {
00716 return StatFsImpl<false>( fs, std::move( path ) );
00717 }
00718
00719
00721
00722 template<bool HasHndl>
00723 class StatVFSImpl: public FileSystemOperation<StatVFSImpl, HasHndl,
00724 Resp<StatInfoVFS>, Arg<std::string>>
00725 {
00726 public:
00727
00728
00730
00731 using FileSystemOperation<StatVFSImpl, HasHndl, Resp<StatInfoVFS>,
00732 Arg<std::string>>::FileSystemOperation;
00733
00734
00736
00737 enum { PathArg };
00738
00739
00741
00742 std::string ToString()
00743 {
00744 return "StatVFS";
00745 }
00746
00747 protected:
00748
00749
00755
00756 XRootDStatus RunImpl()
00757 {
00758 try
00759 {
00760 std::string path = std::get<PathArg>( this->args ).Get();
00761 return this->filesystem->StatVFS( path, this->handler.get() );
00762 }
00763 catch( const PipelineException& ex )
00764 {
00765 return ex.GetError();
00766 }
00767 catch( const std::exception& ex )
00768 {
00769 return XRootDStatus( stError, ex.what() );
00770 }
00771 }
00772 };
00773 typedef StatVFSImpl<false> StatVFS;
00774
00775
00777
00778 template<bool HasHndl>
00779 class ProtocolImpl: public FileSystemOperation<ProtocolImpl, HasHndl,
00780 Resp<ProtocolInfo>>
00781 {
00782 public:
00783
00784
00786
00787 using FileSystemOperation<ProtocolImpl, HasHndl, Resp<ProtocolInfo>>::FileSystemOperation;
00788
00789
00791
00792 std::string ToString()
00793 {
00794 return "Protocol";
00795 }
00796
00797 protected:
00798
00799
00805
00806 XRootDStatus RunImpl()
00807 {
00808 return this->filesystem->Protocol( this->handler.get() );
00809 }
00810 };
00811 typedef ProtocolImpl<false> Protocol;
00812
00813
00815
00816 template<bool HasHndl>
00817 class DirListImpl: public FileSystemOperation<DirListImpl, HasHndl, Resp<DirectoryList>,
00818 Arg<std::string>, Arg<DirListFlags::Flags>>
00819 {
00820 public:
00821
00822
00824
00825 using FileSystemOperation<DirListImpl, HasHndl, Resp<DirectoryList>, Arg<std::string>,
00826 Arg<DirListFlags::Flags>>::FileSystemOperation;
00827
00828
00830
00831 enum { PathArg, FlagsArg };
00832
00833
00835
00836 std::string ToString()
00837 {
00838 return "DirList";
00839 }
00840
00841 protected:
00842
00843
00849
00850 XRootDStatus RunImpl()
00851 {
00852 try
00853 {
00854 std::string path = std::get<PathArg>( this->args ).Get();
00855 DirListFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
00856 return this->filesystem->DirList( path, flags, this->handler.get() );
00857 }
00858 catch( const PipelineException& ex )
00859 {
00860 return ex.GetError();
00861 }
00862 catch( const std::exception& ex )
00863 {
00864 return XRootDStatus( stError, ex.what() );
00865 }
00866 }
00867 };
00868 typedef DirListImpl<false> DirList;
00869
00870
00872
00873 template<bool HasHndl>
00874 class SendInfoImpl: public FileSystemOperation<SendInfoImpl, HasHndl, Resp<Buffer>,
00875 Arg<std::string>>
00876 {
00877 public:
00878
00879
00881
00882 using FileSystemOperation<SendInfoImpl, HasHndl, Resp<Buffer>,
00883 Arg<std::string>>::FileSystemOperation;
00884
00885
00887
00888 enum { InfoArg };
00889
00890
00892
00893 std::string ToString()
00894 {
00895 return "SendInfo";
00896 }
00897
00898 protected:
00899
00900
00906
00907 XRootDStatus RunImpl()
00908 {
00909 try
00910 {
00911 std::string info = std::get<InfoArg>( this->args ).Get();
00912 return this->filesystem->SendInfo( info, this->handler.get() );
00913 }
00914 catch( const PipelineException& ex )
00915 {
00916 return ex.GetError();
00917 }
00918 catch( const std::exception& ex )
00919 {
00920 return XRootDStatus( stError, ex.what() );
00921 }
00922 }
00923 };
00924 typedef SendInfoImpl<false> SendInfo;
00925
00926
00928
00929 template<bool HasHndl>
00930 class PrepareImpl: public FileSystemOperation<PrepareImpl, HasHndl, Resp<Buffer>,
00931 Arg<std::vector<std::string>>, Arg<PrepareFlags::Flags>, Arg<uint8_t>>
00932 {
00933 public:
00934
00935
00937
00938 using FileSystemOperation<PrepareImpl, HasHndl, Resp<Buffer>, Arg<std::vector<std::string>>,
00939 Arg<PrepareFlags::Flags>, Arg<uint8_t>>::FileSystemOperation;
00940
00941
00943
00944 enum { FileListArg, FlagsArg, PriorityArg };
00945
00946
00948
00949 std::string ToString()
00950 {
00951 return "Prepare";
00952 }
00953
00954 protected:
00955
00956
00962
00963 XRootDStatus RunImpl()
00964 {
00965 try
00966 {
00967 std::vector<std::string> fileList = std::get<FileListArg>( this->args ).Get();
00968 PrepareFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
00969 uint8_t priority = std::get<PriorityArg>( this->args ).Get();
00970 return this->filesystem->Prepare( fileList, flags, priority,
00971 this->handler.get() );
00972 }
00973 catch( const PipelineException& ex )
00974 {
00975 return ex.GetError();
00976 }
00977 catch( const std::exception& ex )
00978 {
00979 return XRootDStatus( stError, ex.what() );
00980 }
00981 }
00982 };
00983 typedef PrepareImpl<false> Prepare;
00984
00985
00987
00988 template<bool HasHndl>
00989 class SetXAttrFsImpl: public FileSystemOperation<SetXAttrFsImpl, HasHndl, Resp<void>,
00990 Arg<std::string>, Arg<std::string>, Arg<std::string>>
00991 {
00992 public:
00993
00994
00996
00997 using FileSystemOperation<SetXAttrFsImpl, HasHndl, Resp<void>, Arg<std::string>,
00998 Arg<std::string>, Arg<std::string>>::FileSystemOperation;
00999
01000
01002
01003 enum { PathArg, NameArg, ValueArg };
01004
01005
01007
01008 std::string ToString()
01009 {
01010 return "SetXAttrFsImpl";
01011 }
01012
01013 protected:
01014
01015
01021
01022 XRootDStatus RunImpl()
01023 {
01024 try
01025 {
01026 std::string path = std::get<PathArg>( this->args ).Get();
01027 std::string name = std::get<NameArg>( this->args ).Get();
01028 std::string value = std::get<ValueArg>( this->args ).Get();
01029
01030 std::vector<xattr_t> attrs;
01031 attrs.push_back( xattr_t( std::move( name ), std::move( value ) ) );
01032
01033 UnpackXAttrStatus *handler = new UnpackXAttrStatus( this->handler.get() );
01034 XRootDStatus st = this->filesystem->SetXAttr( path, attrs, handler );
01035 if( !st.IsOK() ) delete handler;
01036 return st;
01037 }
01038 catch( const PipelineException& ex )
01039 {
01040 return ex.GetError();
01041 }
01042 catch( const std::exception& ex )
01043 {
01044 return XRootDStatus( stError, ex.what() );
01045 }
01046 }
01047 };
01048
01049
01052
01053 inline SetXAttrFsImpl<false> SetXAttr( FileSystem *fs, Arg<std::string> path,
01054 Arg<std::string> name, Arg<std::string> value )
01055 {
01056 return SetXAttrFsImpl<false>( fs, std::move( path ), std::move( name ),
01057 std::move( value ) );
01058 }
01059
01060
01063
01064 inline SetXAttrFsImpl<false> SetXAttr( FileSystem &fs, Arg<std::string> path,
01065 Arg<std::string> name, Arg<std::string> value )
01066 {
01067 return SetXAttrFsImpl<false>( fs, std::move( path ), std::move( name ),
01068 std::move( value ) );
01069 }
01070
01071
01073
01074 template<bool HasHndl>
01075 class SetXAttrFsBulkImpl: public FileSystemOperation<SetXAttrFsBulkImpl, HasHndl,
01076 Resp<std::vector<XAttrStatus>>, Arg<std::string>, Arg<std::vector<xattr_t>>>
01077 {
01078 public:
01079
01080
01082
01083 using FileSystemOperation<SetXAttrFsBulkImpl, HasHndl, Resp<std::vector<XAttrStatus>>,
01084 Arg<std::string>, Arg<std::vector<xattr_t>>>::FileSystemOperation;
01085
01086
01088
01089 enum { PathArg, AttrsArg };
01090
01091
01093
01094 std::string ToString()
01095 {
01096 return "SetXAttrBulkImpl";
01097 }
01098
01099
01100 protected:
01101
01102
01106
01107 XRootDStatus RunImpl()
01108 {
01109 try
01110 {
01111 std::string path = std::get<PathArg>( this->args ).Get();
01112 std::vector<xattr_t> attrs = std::get<AttrsArg>( this->args ).Get();
01113 return this->filesystem->SetXAttr( path, attrs, this->handler.get() );
01114 }
01115 catch( const PipelineException& ex )
01116 {
01117 return ex.GetError();
01118 }
01119 catch( const std::exception& ex )
01120 {
01121 return XRootDStatus( stError, ex.what() );
01122 }
01123 }
01124 };
01125
01126
01129
01130 inline SetXAttrFsBulkImpl<false> SetXAttr( FileSystem *fs, Arg<std::string> path,
01131 Arg<std::vector<xattr_t>> attrs )
01132 {
01133 return SetXAttrFsBulkImpl<false>( fs, std::move( path ), std::move( attrs ) );
01134 }
01135
01136
01139
01140 inline SetXAttrFsBulkImpl<false> SetXAttr( FileSystem &fs, Arg<std::string> path,
01141 Arg<std::vector<xattr_t>> attrs )
01142 {
01143 return SetXAttrFsBulkImpl<false>( fs, std::move( path ), std::move( attrs ) );
01144 }
01145
01146
01148
01149 template<bool HasHndl>
01150 class GetXAttrFsImpl: public FileSystemOperation<GetXAttrFsImpl, HasHndl, Resp<std::string>,
01151 Arg<std::string>, Arg<std::string>>
01152 {
01153 public:
01154
01155
01157
01158 using FileSystemOperation<GetXAttrFsImpl, HasHndl, Resp<std::string>,
01159 Arg<std::string>, Arg<std::string>>::FileSystemOperation;
01160
01161
01163
01164 enum { PathArg, NameArg };
01165
01166
01168
01169 std::string ToString()
01170 {
01171 return "GetXAttrFsImpl";
01172 }
01173
01174 protected:
01175
01176
01180
01181 XRootDStatus RunImpl()
01182 {
01183 try
01184 {
01185 std::string path = std::get<PathArg>( this->args ).Get();
01186 std::string name = std::get<NameArg>( this->args ).Get();
01187
01188 std::vector<std::string> attrs;
01189 attrs.push_back( std::move( name ) );
01190
01191 UnpackXAttr *handler = new UnpackXAttr( this->handler.get() );
01192 XRootDStatus st = this->filesystem->GetXAttr( path, attrs, handler );
01193 if( !st.IsOK() ) delete handler;
01194 return st;
01195 }
01196 catch( const PipelineException& ex )
01197 {
01198 return ex.GetError();
01199 }
01200 catch( const std::exception& ex )
01201 {
01202 return XRootDStatus( stError, ex.what() );
01203 }
01204 }
01205 };
01206
01207
01210
01211 inline GetXAttrFsImpl<false> GetXAttr( FileSystem *fs, Arg<std::string> path,
01212 Arg<std::string> name )
01213 {
01214 return GetXAttrFsImpl<false>( fs, std::move( path ), std::move( name ) );
01215 }
01216
01217
01220
01221 inline GetXAttrFsImpl<false> GetXAttr( FileSystem &fs, Arg<std::string> path,
01222 Arg<std::string> name )
01223 {
01224 return GetXAttrFsImpl<false>( fs, std::move( path ), std::move( name ) );
01225 }
01226
01227
01229
01230 template<bool HasHndl>
01231 class GetXAttrFsBulkImpl: public FileSystemOperation<GetXAttrFsBulkImpl, HasHndl,
01232 Resp<std::vector<XAttr>>, Arg<std::string>, Arg<std::vector<std::string>>>
01233 {
01234 public:
01235
01236
01238
01239 using FileSystemOperation<GetXAttrFsBulkImpl, HasHndl, Resp<std::vector<XAttr>>,
01240 Arg<std::string>, Arg<std::vector<std::string>>>::FileSystemOperation;
01241
01242
01244
01245 enum { PathArg, NamesArg };
01246
01247
01249
01250 std::string ToString()
01251 {
01252 return "GetXAttrFsBulkImpl";
01253 }
01254
01255
01256 protected:
01257
01258
01262
01263 XRootDStatus RunImpl()
01264 {
01265 try
01266 {
01267 std::string path = std::get<PathArg>( this->args ).Get();
01268 std::vector<std::string> attrs = std::get<NamesArg>( this->args ).Get();
01269 return this->filesystem->GetXAttr( path, attrs, this->handler.get() );
01270 }
01271 catch( const PipelineException& ex )
01272 {
01273 return ex.GetError();
01274 }
01275 catch( const std::exception& ex )
01276 {
01277 return XRootDStatus( stError, ex.what() );
01278 }
01279 }
01280 };
01281
01282
01285
01286 inline GetXAttrFsBulkImpl<false> GetXAttr( FileSystem *fs, Arg<std::string> path,
01287 Arg<std::vector<std::string>> attrs )
01288 {
01289 return GetXAttrFsBulkImpl<false>( fs, std::move( path ), std::move( attrs ) );
01290 }
01291
01292
01295
01296 inline GetXAttrFsBulkImpl<false> GetXAttr( FileSystem &fs, Arg<std::string> path,
01297 Arg<std::vector<std::string>> attrs )
01298 {
01299 return GetXAttrFsBulkImpl<false>( fs, std::move( path ), std::move( attrs ) );
01300 }
01301
01302
01304
01305 template<bool HasHndl>
01306 class DelXAttrFsImpl: public FileSystemOperation<DelXAttrFsImpl, HasHndl, Resp<void>,
01307 Arg<std::string>, Arg<std::string>>
01308 {
01309 public:
01310
01311
01313
01314 using FileSystemOperation<DelXAttrFsImpl, HasHndl, Resp<void>, Arg<std::string>,
01315 Arg<std::string>>::FileSystemOperation;
01316
01317
01319
01320 enum { PathArg, NameArg };
01321
01322
01324
01325 std::string ToString()
01326 {
01327 return "DelXAttrFsImpl";
01328 }
01329
01330 protected:
01331
01332
01338
01339 XRootDStatus RunImpl()
01340 {
01341 try
01342 {
01343 std::string path = std::get<PathArg>( this->args ).Get();
01344 std::string name = std::get<NameArg>( this->args ).Get();
01345
01346 std::vector<std::string> attrs;
01347 attrs.push_back( std::move( name ) );
01348
01349 UnpackXAttrStatus *handler = new UnpackXAttrStatus( this->handler.get() );
01350 XRootDStatus st = this->filesystem->DelXAttr( path, attrs, handler );
01351 if( !st.IsOK() ) delete handler;
01352 return st;
01353 }
01354 catch( const PipelineException& ex )
01355 {
01356 return ex.GetError();
01357 }
01358 catch( const std::exception& ex )
01359 {
01360 return XRootDStatus( stError, ex.what() );
01361 }
01362 }
01363 };
01364
01365
01368
01369 inline DelXAttrFsImpl<false> DelXAttr( FileSystem *fs, Arg<std::string> path,
01370 Arg<std::string> name )
01371 {
01372 return DelXAttrFsImpl<false>( fs, std::move( path ), std::move( name ) );
01373 }
01374
01375
01378
01379 inline DelXAttrFsImpl<false> DelXAttr( FileSystem &fs, Arg<std::string> path,
01380 Arg<std::string> name )
01381 {
01382 return DelXAttrFsImpl<false>( fs, std::move( path ), std::move( name ) );
01383 }
01384
01385
01387
01388 template<bool HasHndl>
01389 class DelXAttrFsBulkImpl: public FileSystemOperation<DelXAttrFsBulkImpl, HasHndl,
01390 Resp<std::vector<XAttrStatus>>, Arg<std::string>, Arg<std::vector<std::string>>>
01391 {
01392 public:
01393
01394
01396
01397 using FileSystemOperation<DelXAttrFsBulkImpl, HasHndl, Resp<std::vector<XAttrStatus>>,
01398 Arg<std::string>, Arg<std::vector<std::string>>>::FileSystemOperation;
01399
01400
01402
01403 enum { PathArg, NamesArg };
01404
01405
01407
01408 std::string ToString()
01409 {
01410 return "DelXAttrBulkImpl";
01411 }
01412
01413
01414 protected:
01415
01416
01422
01423 XRootDStatus RunImpl()
01424 {
01425 try
01426 {
01427 std::string path = std::get<PathArg>( this->args ).Get();
01428 std::vector<std::string> attrs = std::get<NamesArg>( this->args ).Get();
01429 return this->filesystem->DelXAttr( path, attrs, this->handler.get() );
01430 }
01431 catch( const PipelineException& ex )
01432 {
01433 return ex.GetError();
01434 }
01435 catch( const std::exception& ex )
01436 {
01437 return XRootDStatus( stError, ex.what() );
01438 }
01439 }
01440 };
01441
01442
01445
01446 inline DelXAttrFsBulkImpl<false> DelXAttr( FileSystem *fs, Arg<std::string> path,
01447 Arg<std::vector<std::string>> attrs )
01448 {
01449 return DelXAttrFsBulkImpl<false>( fs, std::move( path ), std::move( attrs ) );
01450 }
01451
01452
01455
01456 inline DelXAttrFsBulkImpl<false> DelXAttr( FileSystem &fs, Arg<std::string> path,
01457 Arg<std::vector<std::string>> attrs )
01458 {
01459 return DelXAttrFsBulkImpl<false>( fs, std::move( path ), std::move( attrs ) );
01460 }
01461
01462
01464
01465 template<bool HasHndl>
01466 class ListXAttrFsImpl: public FileSystemOperation<ListXAttrFsImpl, HasHndl,
01467 Resp<std::vector<XAttr>>, Arg<std::string>>
01468 {
01469 public:
01470
01471
01473
01474 using FileSystemOperation<ListXAttrFsImpl, HasHndl, Resp<std::vector<XAttr>>,
01475 Arg<std::string>>::FileSystemOperation;
01476
01477
01479
01480 enum { PathArg };
01481
01482
01484
01485 std::string ToString()
01486 {
01487 return "ListXAttrFsImpl";
01488 }
01489
01490 protected:
01491
01492
01498
01499 XRootDStatus RunImpl()
01500 {
01501 try
01502 {
01503 std::string path = std::get<PathArg>( this->args ).Get();
01504 return this->filesystem->ListXAttr( path, this->handler.get() );
01505 }
01506 catch( const PipelineException& ex )
01507 {
01508 return ex.GetError();
01509 }
01510 catch( const std::exception& ex )
01511 {
01512 return XRootDStatus( stError, ex.what() );
01513 }
01514 }
01515 };
01516
01517
01520
01521 inline ListXAttrFsImpl<false> ListXAttr( FileSystem *fs, Arg<std::string> path )
01522 {
01523 return ListXAttrFsImpl<false>( fs, std::move( path ) );
01524 }
01525
01526
01529
01530 inline ListXAttrFsImpl<false> ListXAttr( FileSystem &fs, Arg<std::string> path )
01531 {
01532 return ListXAttrFsImpl<false>( fs, std::move( path ) );
01533 }
01534 }
01535
01536 #endif // __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__