| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_windows.h" | 5 #include "net/ftp/ftp_directory_listing_parser_windows.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "net/ftp/ftp_directory_listing_parser.h" | 14 #include "net/ftp/ftp_directory_listing_parser.h" |
| 14 #include "net/ftp/ftp_util.h" | 15 #include "net/ftp/ftp_util.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 bool ParseFtpDirectoryListingWindows( | 19 bool ParseFtpDirectoryListingWindows( |
| 19 const std::vector<base::string16>& lines, | 20 const std::vector<base::string16>& lines, |
| 20 std::vector<FtpDirectoryListingEntry>* entries) { | 21 std::vector<FtpDirectoryListingEntry>* entries) { |
| 21 for (size_t i = 0; i < lines.size(); i++) { | 22 for (size_t i = 0; i < lines.size(); i++) { |
| 22 if (lines[i].empty()) | 23 if (lines[i].empty()) |
| 23 continue; | 24 continue; |
| 24 | 25 |
| 25 std::vector<base::string16> columns; | 26 std::vector<base::string16> columns = base::SplitString( |
| 26 base::SplitString(base::CollapseWhitespace(lines[i], false), ' ', &columns); | 27 base::CollapseWhitespace(lines[i], false), base::ASCIIToUTF16(" "), |
| 28 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 27 | 29 |
| 28 // Every line of the listing consists of the following: | 30 // Every line of the listing consists of the following: |
| 29 // | 31 // |
| 30 // 1. date | 32 // 1. date |
| 31 // 2. time | 33 // 2. time |
| 32 // 3. size in bytes (or "<DIR>" for directories) | 34 // 3. size in bytes (or "<DIR>" for directories) |
| 33 // 4. filename (may be empty or contain spaces) | 35 // 4. filename (may be empty or contain spaces) |
| 34 // | 36 // |
| 35 // For now, make sure we have 1-3, and handle 4 later. | 37 // For now, make sure we have 1-3, and handle 4 later. |
| 36 if (columns.size() < 3) | 38 if (columns.size() < 3) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 63 continue; | 65 continue; |
| 64 } | 66 } |
| 65 | 67 |
| 66 entries->push_back(entry); | 68 entries->push_back(entry); |
| 67 } | 69 } |
| 68 | 70 |
| 69 return true; | 71 return true; |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace net | 74 } // namespace net |
| OLD | NEW |