Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: net/ftp/ftp_directory_listing_parser_hprc.cc

Issue 3448029: FTP: fix directory listing parser for ftp.usa.hp.com (Closed)
Patch Set: attempt to fix Windows trybots Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/ftp/ftp_directory_listing_parser_hprc.h"
6
7 #include "base/logging.h"
8 #include "base/time.h"
9
10 namespace net {
11
12 FtpDirectoryListingParserHprc::FtpDirectoryListingParserHprc(
13 const base::Time& current_time)
14 : current_time_(current_time) {
15 }
16
17 FtpServerType FtpDirectoryListingParserHprc::GetServerType() const {
18 return SERVER_HPRC;
19 }
20
21 bool FtpDirectoryListingParserHprc::ConsumeLine(const string16& line) {
22 if (line.empty())
23 return false;
24
25 // All lines begin with a space.
26 if (line[0] != ' ')
27 return false;
28
29 FtpDirectoryListingEntry entry;
30 entry.name = line.substr(1);
31
32 // We don't know anything beyond the file name, so just pick some arbitrary
33 // values.
34 // TODO(phajdan.jr): consider adding an UNKNOWN entry type.
35 entry.type = FtpDirectoryListingEntry::FILE;
36 entry.size = 0;
37 entry.last_modified = current_time_;
38
39 entries_.push(entry);
40 return true;
41 }
42
43 bool FtpDirectoryListingParserHprc::OnEndOfInput() {
44 return true;
45 }
46
47 bool FtpDirectoryListingParserHprc::EntryAvailable() const {
48 return !entries_.empty();
49 }
50
51 FtpDirectoryListingEntry FtpDirectoryListingParserHprc::PopEntry() {
52 DCHECK(EntryAvailable());
53 FtpDirectoryListingEntry entry = entries_.front();
54 entries_.pop();
55 return entry;
56 }
57
58 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_hprc.h ('k') | net/ftp/ftp_directory_listing_parser_hprc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698