| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/ftp/ftp_directory_listing_parser_ls.h" | 5 #include "net/ftp/ftp_directory_listing_parser_ls.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { | 92 bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { |
| 93 if (line.empty() && !received_nonempty_line_) { | 93 if (line.empty() && !received_nonempty_line_) { |
| 94 // Allow empty lines only at the beginning of the listing. For example VMS | 94 // Allow empty lines only at the beginning of the listing. For example VMS |
| 95 // systems in Unix emulation mode add an empty line before the first listing | 95 // systems in Unix emulation mode add an empty line before the first listing |
| 96 // entry. | 96 // entry. |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 received_nonempty_line_ = true; | 99 received_nonempty_line_ = true; |
| 100 | 100 |
| 101 std::vector<string16> columns; | 101 std::vector<string16> columns; |
| 102 SplitString(CollapseWhitespace(line, false), ' ', &columns); | 102 base::SplitString(CollapseWhitespace(line, false), ' ', &columns); |
| 103 | 103 |
| 104 // Some FTP servers put a "total n" line at the beginning of the listing | 104 // Some FTP servers put a "total n" line at the beginning of the listing |
| 105 // (n is an integer). Allow such a line, but only once, and only if it's | 105 // (n is an integer). Allow such a line, but only once, and only if it's |
| 106 // the first non-empty line. Do not match the word exactly, because it may be | 106 // the first non-empty line. Do not match the word exactly, because it may be |
| 107 // in different languages (at least English and German have been seen in the | 107 // in different languages (at least English and German have been seen in the |
| 108 // field). | 108 // field). |
| 109 if (columns.size() == 2 && !received_total_line_) { | 109 if (columns.size() == 2 && !received_total_line_) { |
| 110 received_total_line_ = true; | 110 received_total_line_ = true; |
| 111 | 111 |
| 112 int total_number; | 112 int total_number; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return !entries_.empty(); | 177 return !entries_.empty(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { | 180 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { |
| 181 FtpDirectoryListingEntry entry = entries_.front(); | 181 FtpDirectoryListingEntry entry = entries_.front(); |
| 182 entries_.pop(); | 182 entries_.pop(); |
| 183 return entry; | 183 return entry; |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace net | 186 } // namespace net |
| OLD | NEW |