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

Unified Diff: net/ftp/ftp_directory_listing_parser_os2.cc

Issue 7590011: FTP: add directory listing parser for OS/2 format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
Index: net/ftp/ftp_directory_listing_parser_os2.cc
diff --git a/net/ftp/ftp_directory_listing_parser_windows.cc b/net/ftp/ftp_directory_listing_parser_os2.cc
similarity index 80%
copy from net/ftp/ftp_directory_listing_parser_windows.cc
copy to net/ftp/ftp_directory_listing_parser_os2.cc
index 2317fa3a6ccd228db29e7ab4029f83c805025717..47ceb2b14ece262a8ed0d95210d7586355936cb6 100644
--- a/net/ftp/ftp_directory_listing_parser_windows.cc
+++ b/net/ftp/ftp_directory_listing_parser_os2.cc
@@ -2,7 +2,7 @@
// 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_windows.h"
+#include "net/ftp/ftp_directory_listing_parser_os2.h"
#include <vector>
@@ -74,7 +74,7 @@ bool WindowsDateListingToTime(const std::vector<string16>& columns,
namespace net {
-bool ParseFtpDirectoryListingWindows(
+bool ParseFtpDirectoryListingOS2(
const std::vector<string16>& lines,
std::vector<FtpDirectoryListingEntry>* entries) {
for (size_t i = 0; i < lines.size(); i++) {
@@ -86,31 +86,39 @@ bool ParseFtpDirectoryListingWindows(
// Every line of the listing consists of the following:
//
- // 1. date
- // 2. time
- // 3. size in bytes (or "<DIR>" for directories)
- // 4. filename (may be empty or contain spaces)
+ // 1. size in bytes (0 for directories)
+ // 2. type (A for files, DIR for directories)
+ // 3. date
+ // 4. time
+ // 5. filename (may be empty or contain spaces)
//
- // For now, make sure we have 1-3, and handle 4 later.
- if (columns.size() < 3)
+ // For now, make sure we have 1-4, and handle 5 later.
+ if (columns.size() < 4)
return false;
FtpDirectoryListingEntry entry;
- if (EqualsASCII(columns[2], "<DIR>")) {
+ if (!base::StringToInt64(columns[0], &entry.size))
+ return false;
+ if (EqualsASCII(columns[1], "DIR")) {
+ if (entry.size != 0)
+ return false;
entry.type = FtpDirectoryListingEntry::DIRECTORY;
entry.size = -1;
- } else {
+ } else if (EqualsASCII(columns[1], "A")) {
entry.type = FtpDirectoryListingEntry::FILE;
- if (!base::StringToInt64(columns[2], &entry.size))
- return false;
if (entry.size < 0)
return false;
+ } else {
+ return false;
}
- if (!WindowsDateListingToTime(columns, &entry.last_modified))
+ if (!FtpUtil::WindowsDateListingToTime(columns[2],
+ columns[3],
+ &entry.last_modified)) {
return false;
+ }
- entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 3);
+ entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 4);
if (entry.name.empty()) {
// Some FTP servers send listing entries with empty names.
// It's not obvious how to display such an entry, so ignore them.

Powered by Google App Engine
This is Rietveld 408576698