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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 entry.type = FtpDirectoryListingEntry::DIRECTORY; | 41 entry.type = FtpDirectoryListingEntry::DIRECTORY; |
42 entry.size = -1; | 42 entry.size = -1; |
43 } else { | 43 } else { |
44 entry.type = FtpDirectoryListingEntry::FILE; | 44 entry.type = FtpDirectoryListingEntry::FILE; |
45 if (!base::StringToInt64(columns[2], &entry.size)) | 45 if (!base::StringToInt64(columns[2], &entry.size)) |
46 return false; | 46 return false; |
47 if (entry.size < 0) | 47 if (entry.size < 0) |
48 return false; | 48 return false; |
49 } | 49 } |
50 | 50 |
51 if (!FtpUtil::WindowsDateListingToTime(columns[0], | 51 if (!FtpUtil::WindowsDateListingToTime( |
52 columns[1], | 52 columns[0], columns[1], &entry.last_modified)) { |
53 &entry.last_modified)) { | |
54 return false; | 53 return false; |
55 } | 54 } |
56 | 55 |
57 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 3); | 56 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 3); |
58 if (entry.name.empty()) { | 57 if (entry.name.empty()) { |
59 // Some FTP servers send listing entries with empty names. | 58 // Some FTP servers send listing entries with empty names. |
60 // It's not obvious how to display such an entry, so ignore them. | 59 // It's not obvious how to display such an entry, so ignore them. |
61 // We don't want to make the parsing fail at this point though. | 60 // We don't want to make the parsing fail at this point though. |
62 // Other entries can still be useful. | 61 // Other entries can still be useful. |
63 continue; | 62 continue; |
64 } | 63 } |
65 | 64 |
66 entries->push_back(entry); | 65 entries->push_back(entry); |
67 } | 66 } |
68 | 67 |
69 return true; | 68 return true; |
70 } | 69 } |
71 | 70 |
72 } // namespace net | 71 } // namespace net |
OLD | NEW |