xrootd
XrdClZipListHandler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3 // Author: Michal Simon <michal.simon@cern.ch>
4 //------------------------------------------------------------------------------
5 // This file is part of the XRootD software suite.
6 //
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // In applying this licence, CERN does not waive the privileges and immunities
21 // granted to it by virtue of its status as an Intergovernmental Organization
22 // or submit itself to any jurisdiction.
23 //------------------------------------------------------------------------------
24 
25 #ifndef SRC_XRDCL_XRDCLZIPLISTHANDLER_HH_
26 #define SRC_XRDCL_XRDCLZIPLISTHANDLER_HH_
27 
29 #include "XrdCl/XrdClFileSystem.hh"
30 #include "XrdCl/XrdClFile.hh"
32 #include "XrdCl/XrdClConstants.hh"
33 #include "XrdCl/XrdClDefaultEnv.hh"
34 
35 #include <string>
36 #include <memory>
37 
38 namespace XrdCl
39 {
40 
41  //----------------------------------------------------------------------------
42  // DirList : Handle not a directory error
43  //----------------------------------------------------------------------------
45  {
46 
47  //------------------------------------------------------------------------
52  //1 - DONE : we are done
53  //------------------------------------------------------------------------
54  enum Steps
55  {
56  STAT = 0,
57  OPEN = 1,
58  CLOSE = 2,
59  DONE = 4
60  };
61 
62  public:
63 
64  //------------------------------------------------------------------------
72  //------------------------------------------------------------------------
73  ZipListHandler( const URL &url,
74  const std::string &path,
75  DirListFlags::Flags flags,
76  ResponseHandler *handler,
77  uint16_t timeout = 0 ) :
78  pUrl( url ), pFlags( flags ), pHandler( handler ),
79  pTimeout( timeout ), pStartTime( time( 0 ) ),
80  pZip( pFile ), pStep( STAT )
81  {
82  if( !pTimeout )
83  {
84  int val = DefaultRequestTimeout;
85  DefaultEnv::GetEnv()->GetInt( "RequestTimeout", val );
86  pTimeout = val;
87  }
88 
89  pUrl.SetPath( path );
90  }
91 
92  //------------------------------------------------------------------------
94  //------------------------------------------------------------------------
96  {
97 
98  }
99 
100  //------------------------------------------------------------------------
102  //------------------------------------------------------------------------
103  virtual void HandleResponse( XrdCl::XRootDStatus *statusptr,
104  XrdCl::AnyObject *responseptr );
105  private:
106 
107  //------------------------------------------------------------------------
109  //------------------------------------------------------------------------
110  void DoDirList( time_t timeLeft );
111 
112  //------------------------------------------------------------------------
114  //------------------------------------------------------------------------
115  void DoZipOpen( time_t timeLeft );
116 
117  //------------------------------------------------------------------------
119  //------------------------------------------------------------------------
120  void DoZipClose( time_t timeLeft );
121 
125  uint16_t pTimeout;
126 
127  std::unique_ptr<DirectoryList> pDirList;
128  time_t pStartTime;
129 
132 
133  int pStep;
134 
135  };
136 
137 } /* namespace XrdCl */
138 
139 #endif /* SRC_XRDCL_XRDCLZIPLISTHANDLER_HH_ */
XrdClFileSystem.hh
XrdCl::ZipListHandler::~ZipListHandler
~ZipListHandler()
Destructor.
Definition: XrdClZipListHandler.hh:95
XrdClConstants.hh
XrdCl::ZipListHandler::DoZipOpen
void DoZipOpen(time_t timeLeft)
Open the ZIP archive.
XrdClXRootDResponses.hh
XrdCl::ZipListHandler::pZip
ZipArchiveReader pZip
Definition: XrdClZipListHandler.hh:131
XrdCl::ResponseHandler
Handle an async response.
Definition: XrdClXRootDResponses.hh:1037
XrdCl::ZipListHandler
Definition: XrdClZipListHandler.hh:45
XrdClZipArchiveReader.hh
XrdCl::ZipListHandler::pHandler
ResponseHandler * pHandler
Definition: XrdClZipListHandler.hh:124
XrdCl::ZipListHandler::OPEN
@ OPEN
Definition: XrdClZipListHandler.hh:57
XrdCl::ZipListHandler::Steps
Steps
Definition: XrdClZipListHandler.hh:55
XrdCl::ZipListHandler::STAT
@ STAT
Definition: XrdClZipListHandler.hh:56
XrdCl::File
A file.
Definition: XrdClFile.hh:46
XrdCl::ZipListHandler::pDirList
std::unique_ptr< DirectoryList > pDirList
Definition: XrdClZipListHandler.hh:127
XrdCl::XRootDStatus
Request status.
Definition: XrdClXRootDResponses.hh:215
XrdCl::ZipListHandler::DoDirList
void DoDirList(time_t timeLeft)
Do normal listing if it is a directory (and not a ZIP archive)
XrdCl::ZipListHandler::HandleResponse
virtual void HandleResponse(XrdCl::XRootDStatus *statusptr, XrdCl::AnyObject *responseptr)
Handle the server response.
XrdCl::DefaultRequestTimeout
const int DefaultRequestTimeout
Definition: XrdClConstants.hh:51
XrdCl::ZipListHandler::pStartTime
time_t pStartTime
Definition: XrdClZipListHandler.hh:128
XrdCl::ZipListHandler::pTimeout
uint16_t pTimeout
Definition: XrdClZipListHandler.hh:125
XrdCl::ZipListHandler::DoZipClose
void DoZipClose(time_t timeLeft)
Close the ZIP archive.
XrdCl::ZipListHandler::pFlags
DirListFlags::Flags pFlags
Definition: XrdClZipListHandler.hh:123
XrdCl::ZipListHandler::DONE
@ DONE
Definition: XrdClZipListHandler.hh:59
XrdCl::ZipListHandler::ZipListHandler
ZipListHandler(const URL &url, const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, uint16_t timeout=0)
Definition: XrdClZipListHandler.hh:73
XrdCl::ZipListHandler::pStep
int pStep
Definition: XrdClZipListHandler.hh:133
XrdCl::URL::SetPath
void SetPath(const std::string &path)
Set the path.
Definition: XrdClURL.hh:220
XrdClFile.hh
XrdCl::ZipListHandler::pFile
File pFile
Definition: XrdClZipListHandler.hh:130
XrdCl
Definition: XrdClAnyObject.hh:26
XrdCl::ZipListHandler::pUrl
URL pUrl
Definition: XrdClZipListHandler.hh:122
XrdClDefaultEnv.hh
XrdCl::DirListFlags::Flags
Flags
Definition: XrdClFileSystem.hh:156
XrdCl::DefaultEnv::GetEnv
static Env * GetEnv()
Get default client environment.
XrdCl::URL
URL representation.
Definition: XrdClURL.hh:31
XrdCl::ZipArchiveReader
Definition: XrdClZipArchiveReader.hh:47
XrdCl::Env::GetInt
bool GetInt(const std::string &key, int &value)
XrdCl::AnyObject
Definition: XrdClAnyObject.hh:33
XrdCl::ZipListHandler::CLOSE
@ CLOSE
Definition: XrdClZipListHandler.hh:58