00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN) 00003 // Author: Michal Simon <michal.simon@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // This file is part of the XRootD software suite. 00006 // 00007 // XRootD is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // XRootD is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // In applying this licence, CERN does not waive the privileges and immunities 00021 // granted to it by virtue of its status as an Intergovernmental Organization 00022 // or submit itself to any jurisdiction. 00023 //------------------------------------------------------------------------------ 00024 00025 #ifndef SRC_XRDCL_XRDCLZIPLISTHANDLER_HH_ 00026 #define SRC_XRDCL_XRDCLZIPLISTHANDLER_HH_ 00027 00028 #include "XrdCl/XrdClXRootDResponses.hh" 00029 #include "XrdCl/XrdClFileSystem.hh" 00030 #include "XrdCl/XrdClFile.hh" 00031 #include "XrdCl/XrdClZipArchiveReader.hh" 00032 #include "XrdCl/XrdClConstants.hh" 00033 #include "XrdCl/XrdClDefaultEnv.hh" 00034 00035 #include <string> 00036 #include <memory> 00037 00038 namespace XrdCl 00039 { 00040 00041 //---------------------------------------------------------------------------- 00042 // DirList : Handle not a directory error 00043 //---------------------------------------------------------------------------- 00044 class ZipListHandler : public ResponseHandler 00045 { 00046 00047 //------------------------------------------------------------------------ 00052 //1 - DONE : we are done 00053 //------------------------------------------------------------------------ 00054 enum Steps 00055 { 00056 STAT = 0, 00057 OPEN = 1, 00058 CLOSE = 2, 00059 DONE = 4 00060 }; 00061 00062 public: 00063 00064 //------------------------------------------------------------------------ 00072 //------------------------------------------------------------------------ 00073 ZipListHandler( const URL &url, 00074 const std::string &path, 00075 DirListFlags::Flags flags, 00076 ResponseHandler *handler, 00077 uint16_t timeout = 0 ) : 00078 pUrl( url ), pFlags( flags ), pHandler( handler ), 00079 pTimeout( timeout ), pStartTime( time( 0 ) ), 00080 pZip( pFile ), pStep( STAT ) 00081 { 00082 if( !pTimeout ) 00083 { 00084 int val = DefaultRequestTimeout; 00085 DefaultEnv::GetEnv()->GetInt( "RequestTimeout", val ); 00086 pTimeout = val; 00087 } 00088 00089 pUrl.SetPath( path ); 00090 } 00091 00092 //------------------------------------------------------------------------ 00094 //------------------------------------------------------------------------ 00095 ~ZipListHandler() 00096 { 00097 00098 } 00099 00100 //------------------------------------------------------------------------ 00102 //------------------------------------------------------------------------ 00103 virtual void HandleResponse( XrdCl::XRootDStatus *statusptr, 00104 XrdCl::AnyObject *responseptr ); 00105 private: 00106 00107 //------------------------------------------------------------------------ 00109 //------------------------------------------------------------------------ 00110 void DoDirList( time_t timeLeft ); 00111 00112 //------------------------------------------------------------------------ 00114 //------------------------------------------------------------------------ 00115 void DoZipOpen( time_t timeLeft ); 00116 00117 //------------------------------------------------------------------------ 00119 //------------------------------------------------------------------------ 00120 void DoZipClose( time_t timeLeft ); 00121 00122 URL pUrl; 00123 DirListFlags::Flags pFlags; 00124 ResponseHandler *pHandler; 00125 uint16_t pTimeout; 00126 00127 std::unique_ptr<DirectoryList> pDirList; 00128 time_t pStartTime; 00129 00130 File pFile; 00131 ZipArchiveReader pZip; 00132 00133 int pStep; 00134 00135 }; 00136 00137 } /* namespace XrdCl */ 00138 00139 #endif /* SRC_XRDCL_XRDCLZIPLISTHANDLER_HH_ */