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_netware.h" | 5 #include "net/ftp/ftp_directory_listing_parser_netware.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_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 if (!lines.empty() && | 42 if (!lines.empty() && |
43 !base::StartsWith(lines[0], base::ASCIIToUTF16("total "), | 43 !base::StartsWith(lines[0], base::ASCIIToUTF16("total "), |
44 base::CompareCase::SENSITIVE)) { | 44 base::CompareCase::SENSITIVE)) { |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 for (size_t i = 1U; i < lines.size(); i++) { | 48 for (size_t i = 1U; i < lines.size(); i++) { |
49 if (lines[i].empty()) | 49 if (lines[i].empty()) |
50 continue; | 50 continue; |
51 | 51 |
52 std::vector<base::string16> columns; | 52 std::vector<base::string16> columns = base::SplitString( |
53 base::SplitString(base::CollapseWhitespace(lines[i], false), ' ', &columns); | 53 base::CollapseWhitespace(lines[i], false), base::ASCIIToUTF16(" "), |
| 54 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
54 | 55 |
55 if (columns.size() < 8) | 56 if (columns.size() < 8) |
56 return false; | 57 return false; |
57 | 58 |
58 FtpDirectoryListingEntry entry; | 59 FtpDirectoryListingEntry entry; |
59 | 60 |
60 if (columns[0].length() != 1) | 61 if (columns[0].length() != 1) |
61 return false; | 62 return false; |
62 if (columns[0][0] == 'd') { | 63 if (columns[0][0] == 'd') { |
63 entry.type = FtpDirectoryListingEntry::DIRECTORY; | 64 entry.type = FtpDirectoryListingEntry::DIRECTORY; |
(...skipping 24 matching lines...) Expand all Loading... |
88 | 89 |
89 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 7); | 90 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 7); |
90 | 91 |
91 entries->push_back(entry); | 92 entries->push_back(entry); |
92 } | 93 } |
93 | 94 |
94 return true; | 95 return true; |
95 } | 96 } |
96 | 97 |
97 } // namespace net | 98 } // namespace net |
OLD | NEW |