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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser_hprc.cc
diff --git a/net/ftp/ftp_directory_listing_parser_hprc.cc b/net/ftp/ftp_directory_listing_parser_hprc.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b65ec6844340919c84234257014d999eb624145e
--- /dev/null
+++ b/net/ftp/ftp_directory_listing_parser_hprc.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/ftp/ftp_directory_listing_parser_hprc.h"
+
+#include "base/logging.h"
+#include "base/time.h"
+
+namespace net {
+
+FtpDirectoryListingParserHprc::FtpDirectoryListingParserHprc(
+ const base::Time& current_time)
+ : current_time_(current_time) {
+}
+
+FtpServerType FtpDirectoryListingParserHprc::GetServerType() const {
+ return SERVER_HPRC;
+}
+
+bool FtpDirectoryListingParserHprc::ConsumeLine(const string16& line) {
+ if (line.empty())
+ return false;
+
+ // All lines begin with a space.
+ if (line[0] != ' ')
+ return false;
+
+ FtpDirectoryListingEntry entry;
+ entry.name = line.substr(1);
+
+ // We don't know anything beyond the file name, so just pick some arbitrary
+ // values.
+ // TODO(phajdan.jr): consider adding an UNKNOWN entry type.
+ entry.type = FtpDirectoryListingEntry::FILE;
+ entry.size = 0;
+ entry.last_modified = current_time_;
+
+ entries_.push(entry);
+ return true;
+}
+
+bool FtpDirectoryListingParserHprc::OnEndOfInput() {
+ return true;
+}
+
+bool FtpDirectoryListingParserHprc::EntryAvailable() const {
+ return !entries_.empty();
+}
+
+FtpDirectoryListingEntry FtpDirectoryListingParserHprc::PopEntry() {
+ DCHECK(EntryAvailable());
+ FtpDirectoryListingEntry entry = entries_.front();
+ entries_.pop();
+ return entry;
+}
+
+} // namespace net
« 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