| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "net/ftp/ftp_directory_listing_parsers.h" | 5 #include "net/ftp/ftp_directory_listing_parsers.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return true; | 229 return true; |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace | 232 } // namespace |
| 233 | 233 |
| 234 namespace net { | 234 namespace net { |
| 235 | 235 |
| 236 FtpDirectoryListingParser::~FtpDirectoryListingParser() { | 236 FtpDirectoryListingParser::~FtpDirectoryListingParser() { |
| 237 } | 237 } |
| 238 | 238 |
| 239 FtpLsDirectoryListingParser::FtpLsDirectoryListingParser() { | 239 FtpLsDirectoryListingParser::FtpLsDirectoryListingParser() |
| 240 : received_nonempty_line_(false) { |
| 240 } | 241 } |
| 241 | 242 |
| 242 bool FtpLsDirectoryListingParser::ConsumeLine(const string16& line) { | 243 bool FtpLsDirectoryListingParser::ConsumeLine(const string16& line) { |
| 244 // Allow empty lines only at the beginning of the listing. For example VMS |
| 245 // systems in Unix emulation mode add an empty line before the first listing |
| 246 // entry. |
| 247 if (line.empty() && !received_nonempty_line_) |
| 248 return true; |
| 249 received_nonempty_line_ = true; |
| 250 |
| 243 std::vector<string16> columns; | 251 std::vector<string16> columns; |
| 244 SplitString(CollapseWhitespace(line, false), ' ', &columns); | 252 SplitString(CollapseWhitespace(line, false), ' ', &columns); |
| 245 if (columns.size() == 11) { | 253 if (columns.size() == 11) { |
| 246 // Check if it is a symlink. | 254 // Check if it is a symlink. |
| 247 if (columns[9] != ASCIIToUTF16("->")) | 255 if (columns[9] != ASCIIToUTF16("->")) |
| 248 return false; | 256 return false; |
| 249 | 257 |
| 250 // Drop the symlink target from columns, we don't use it. | 258 // Drop the symlink target from columns, we don't use it. |
| 251 columns.resize(9); | 259 columns.resize(9); |
| 252 } | 260 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (entry.type != FtpDirectoryListingEntry::FILE) | 425 if (entry.type != FtpDirectoryListingEntry::FILE) |
| 418 entry.size = -1; | 426 entry.size = -1; |
| 419 if (!VmsDateListingToTime(columns, &entry.last_modified)) | 427 if (!VmsDateListingToTime(columns, &entry.last_modified)) |
| 420 return false; | 428 return false; |
| 421 | 429 |
| 422 entries_.push(entry); | 430 entries_.push(entry); |
| 423 return true; | 431 return true; |
| 424 } | 432 } |
| 425 | 433 |
| 426 } // namespace net | 434 } // namespace net |
| OLD | NEW |