-
Notifications
You must be signed in to change notification settings - Fork 149
/
XrdClZipListHandler.cc
132 lines (117 loc) · 3.68 KB
/
XrdClZipListHandler.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//------------------------------------------------------------------------------
// Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
// Author: Michal Simon <michal.simon@cern.ch>
//------------------------------------------------------------------------------
// This file is part of the XRootD software suite.
//
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//
// In applying this licence, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//------------------------------------------------------------------------------
#include "XrdClZipListHandler.hh"
namespace XrdCl
{
void ZipListHandler::HandleResponse( XrdCl::XRootDStatus *statusptr,
XrdCl::AnyObject *responseptr )
{
std::unique_ptr<XRootDStatus> status( statusptr );
std::unique_ptr<AnyObject> response( responseptr );
if( !status->IsOK() )
{
pHandler->HandleResponse( status.release(), response.release() );
delete this;
return;
}
time_t took = time( 0 ) - pStartTime;
if( took > pTimeout )
{
*status = XRootDStatus( stError, errOperationExpired );
pHandler->HandleResponse( status.release(), 0 );
delete this;
return;
}
uint16_t left = pTimeout - took;
switch( pStep )
{
case STAT:
{
StatInfo *info = 0;
response->Get( info );
if( info->TestFlags( StatInfo::IsDir ) )
DoDirList( left );
else
DoZipOpen( left );
break;
}
case OPEN:
{
DirectoryList *list = 0;
XRootDStatus st = pZip.List( list );
if( !st.IsOK() )
{
pHandler->HandleResponse( new XRootDStatus( st ), 0 );
pStep = DONE;
}
else
{
pDirList.reset( list );
DoZipClose( left );
}
break;
}
case CLOSE:
{
AnyObject *resp = new AnyObject();
resp->Set( pDirList.release() );
pHandler->HandleResponse( new XRootDStatus(), resp );
pStep = DONE;
break;
}
}
if( pStep == DONE )
delete this;
}
void ZipListHandler::DoDirList( time_t timeLeft )
{
FileSystem fs( pUrl );
XRootDStatus st = fs.DirList( pUrl.GetPath(), pFlags, pHandler , timeLeft );
pStep = DONE; // no matter whether it works or not, either way we are done
if( !st.IsOK() )
pHandler->HandleResponse( new XRootDStatus( st ), 0 );
}
void ZipListHandler::DoZipOpen( time_t timeLeft )
{
XRootDStatus st = pZip.Open( pUrl.GetURL(), this, timeLeft );
if( !st.IsOK() )
{
pHandler->HandleResponse( new XRootDStatus( st ), 0 );
pStep = DONE;
}
else
pStep = OPEN;
}
void ZipListHandler::DoZipClose( time_t timeLeft )
{
XRootDStatus st = pZip.Close( this, timeLeft );
if( !st.IsOK() )
{
pHandler->HandleResponse( new XRootDStatus( st ), 0 );
pStep = DONE;
}
else
pStep = CLOSE;
}
} /* namespace XrdCl */