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, time_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 ResponseHandler * Wrap (std::function< void(XRootDStatus &, AnyObject &)> func)
 
static ResponseHandler * Wrap (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,
time_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:115
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() && DoZipClose( 1, DONE ) )
55  return;
56  delete this;
57  return;
58  }
59  time_t left = pTimeout - took;
60 
61  switch( pStep )
62  {
63  case STAT:
64  {
65  StatInfo *info = 0;
66  response->Get( info );
67 
68  if( info->TestFlags( StatInfo::IsDir ) )
69  DoDirList( left );
70  else if( DoZipOpen( left ) )
71  return;
72 
73  break;
74  }
75 
76  case OPEN:
77  {
78  DirectoryList *list = 0;
79  XRootDStatus st = pZip.List( list );
80  if( !st.IsOK() )
81  {
82  pHandler->HandleResponse( new XRootDStatus( st ), 0 );
83  pStep = DONE;
84  }
85  else
86  {
87  pDirList.reset( list );
88  if( DoZipClose( left ) )
89  return;
90  }
91  break;
92  }
93 
94  case CLOSE:
95  {
96  AnyObject *resp = new AnyObject();
97  resp->Set( pDirList.release() );
98  pHandler->HandleResponse( new XRootDStatus(), resp );
99  pStep = DONE;
100  break;
101  }
102  }
103 
104  if( pStep == DONE )
105  delete this;
106  }
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: