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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 if (!lines.empty() && !StartsWith(lines[0], ASCIIToUTF16("total "), true)) | 42 if (!lines.empty() && !StartsWith(lines[0], ASCIIToUTF16("total "), true)) |
43 return false; | 43 return false; |
44 | 44 |
45 for (size_t i = 1U; i < lines.size(); i++) { | 45 for (size_t i = 1U; i < lines.size(); i++) { |
46 if (lines[i].empty()) | 46 if (lines[i].empty()) |
47 continue; | 47 continue; |
48 | 48 |
49 std::vector<string16> columns; | 49 std::vector<string16> columns; |
50 base::SplitString(CollapseWhitespace(lines[i], false), ' ', &columns); | 50 base::SplitString(CollapseWhitespace(lines[i], false), ' ', &columns); |
51 | 51 |
52 if (columns.size() != 8) | 52 if (columns.size() < 8) |
53 return false; | 53 return false; |
54 | 54 |
55 FtpDirectoryListingEntry entry; | 55 FtpDirectoryListingEntry entry; |
56 | 56 |
57 if (columns[0].length() != 1) | 57 if (columns[0].length() != 1) |
58 return false; | 58 return false; |
59 if (columns[0][0] == 'd') { | 59 if (columns[0][0] == 'd') { |
60 entry.type = FtpDirectoryListingEntry::DIRECTORY; | 60 entry.type = FtpDirectoryListingEntry::DIRECTORY; |
61 } else if (columns[0][0] == '-') { | 61 } else if (columns[0][0] == '-') { |
62 entry.type = FtpDirectoryListingEntry::FILE; | 62 entry.type = FtpDirectoryListingEntry::FILE; |
(...skipping 13 matching lines...) Expand all Loading... |
76 return false; | 76 return false; |
77 if (entry.type != FtpDirectoryListingEntry::FILE) | 77 if (entry.type != FtpDirectoryListingEntry::FILE) |
78 entry.size = -1; | 78 entry.size = -1; |
79 | 79 |
80 // Netware uses the same date listing format as Unix "ls -l". | 80 // Netware uses the same date listing format as Unix "ls -l". |
81 if (!FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6], | 81 if (!FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6], |
82 current_time, &entry.last_modified)) { | 82 current_time, &entry.last_modified)) { |
83 return false; | 83 return false; |
84 } | 84 } |
85 | 85 |
86 entry.name = columns[7]; | 86 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 7); |
87 | 87 |
88 entries->push_back(entry); | 88 entries->push_back(entry); |
89 } | 89 } |
90 | 90 |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
94 } // namespace net | 94 } // namespace net |
OLD | NEW |