XRootD
XrdCl::ZipListHandler Class Reference

#include <XrdClZipListHandler.hh>

+ Inheritance diagram for XrdCl::ZipListHandler:
+ Collaboration diagram for XrdCl::ZipListHandler:

Public Member Functions

 ZipListHandler (const URL &url, const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, uint16_t timeout=0)
 
 ~ZipListHandler ()
 Destructor. More...
 
virtual void HandleResponse (XrdCl::XRootDStatus *statusptr, XrdCl::AnyObject *responseptr)
 Handle the server response. More...
 
- Public Member Functions inherited from XrdCl::ResponseHandler
virtual ~ResponseHandler ()
 
virtual void HandleResponseWithHosts (XRootDStatus *status, AnyObject *response, HostList *hostList)
 

Additional Inherited Members

- Static Public Member Functions inherited from XrdCl::ResponseHandler
static ResponseHandlerWrap (std::function< void(XRootDStatus &, AnyObject &)> func)
 
static ResponseHandlerWrap (std::function< void(XRootDStatus *, AnyObject *)> func)
 

Detailed Description

Definition at line 44 of file XrdClZipListHandler.hh.

Constructor & Destructor Documentation

◆ ZipListHandler()

XrdCl::ZipListHandler::ZipListHandler ( const URL url,
const std::string &  path,
DirListFlags::Flags  flags,
ResponseHandler handler,
uint16_t  timeout = 0 
)
inline

Constructor

Parameters
url: endpoint URL
path: path to the ZIP
flags: listing flags
handler: the original response handler
timeout: operation timeout

Definition at line 73 of file XrdClZipListHandler.hh.

77  :
78  pUrl( url ), pFlags( flags ), pHandler( handler ),
79  pTimeout( timeout ), pStartTime( time( 0 ) ), pStep( STAT )
80  {
81  if( !pTimeout )
82  {
83  int val = DefaultRequestTimeout;
84  DefaultEnv::GetEnv()->GetInt( "RequestTimeout", val );
85  pTimeout = val;
86  }
87 
88  pUrl.SetPath( path );
89  }
static Env * GetEnv()
Get default client environment.
bool GetInt(const std::string &key, int &value)
Definition: XrdClEnv.cc:89
void SetPath(const std::string &path)
Set the path.
Definition: XrdClURL.hh:225
const int DefaultRequestTimeout

References XrdCl::DefaultRequestTimeout, XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), and XrdCl::URL::SetPath().

+ Here is the call graph for this function:

◆ ~ZipListHandler()

XrdCl::ZipListHandler::~ZipListHandler ( )
inline

Destructor.

Definition at line 94 of file XrdClZipListHandler.hh.

95  {
96 
97  }

Member Function Documentation

◆ HandleResponse()

void XrdCl::ZipListHandler::HandleResponse ( XrdCl::XRootDStatus statusptr,
XrdCl::AnyObject responseptr 
)
virtual

Handle the server response.

Reimplemented from XrdCl::ResponseHandler.

Definition at line 30 of file XrdClZipListHandler.cc.

32  {
33  std::unique_ptr<XRootDStatus> status( statusptr );
34  std::unique_ptr<AnyObject> response( responseptr );
35 
36  if( pStep == DONE )
37  {
38  delete this;
39  return;
40  }
41 
42  if( !status->IsOK() )
43  {
44  pHandler->HandleResponse( status.release(), response.release() );
45  delete this;
46  return;
47  }
48 
49  time_t took = time( 0 ) - pStartTime;
50  if( took > pTimeout )
51  {
52  *status = XRootDStatus( stError, errOperationExpired );
53  pHandler->HandleResponse( status.release(), 0 );
54  if( pZip.IsOpen() )
55  {
56  DoZipClose( 1 );
57  pStep = DONE;
58  }
59  else
60  delete this;
61  return;
62  }
63  uint16_t left = pTimeout - took;
64 
65  switch( pStep )
66  {
67  case STAT:
68  {
69  StatInfo *info = 0;
70  response->Get( info );
71 
72  if( info->TestFlags( StatInfo::IsDir ) )
73  DoDirList( left );
74  else
75  DoZipOpen( left );
76 
77  break;
78  }
79 
80  case OPEN:
81  {
82  DirectoryList *list = 0;
83  XRootDStatus st = pZip.List( list );
84  if( !st.IsOK() )
85  {
86  pHandler->HandleResponse( new XRootDStatus( st ), 0 );
87  pStep = DONE;
88  }
89  else
90  {
91  pDirList.reset( list );
92  DoZipClose( left );
93  }
94  break;
95  }
96 
97  case CLOSE:
98  {
99  AnyObject *resp = new AnyObject();
100  resp->Set( pDirList.release() );
101  pHandler->HandleResponse( new XRootDStatus(), resp );
102  pStep = DONE;
103  break;
104  }
105  }
106 
107  if( pStep == DONE )
108  delete this;
109  }
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)
@ IsDir
This is a directory.
XRootDStatus List(DirectoryList *&list)
const uint16_t errOperationExpired
Definition: XrdClStatus.hh:90
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32

References XrdCl::errOperationExpired, XrdCl::ResponseHandler::HandleResponse(), XrdCl::StatInfo::IsDir, XrdCl::Status::IsOK(), XrdCl::ZipArchive::IsOpen(), XrdCl::ZipArchive::List(), XrdCl::AnyObject::Set(), XrdCl::stError, and XrdCl::StatInfo::TestFlags().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: