OLD | NEW |
(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 |
OLD | NEW |