| 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_os2.h" | 5 #include "net/ftp/ftp_directory_listing_parser_os2.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 22 matching lines...) Expand all Loading... |
| 33 // 4. time | 33 // 4. time |
| 34 // 5. filename (may be empty or contain spaces) | 34 // 5. filename (may be empty or contain spaces) |
| 35 // | 35 // |
| 36 // For now, make sure we have 1-4, and handle 5 later. | 36 // For now, make sure we have 1-4, and handle 5 later. |
| 37 if (columns.size() < 4) | 37 if (columns.size() < 4) |
| 38 return false; | 38 return false; |
| 39 | 39 |
| 40 FtpDirectoryListingEntry entry; | 40 FtpDirectoryListingEntry entry; |
| 41 if (!base::StringToInt64(columns[0], &entry.size)) | 41 if (!base::StringToInt64(columns[0], &entry.size)) |
| 42 return false; | 42 return false; |
| 43 if (EqualsASCII(columns[1], "DIR")) { | 43 if (base::EqualsASCII(columns[1], "DIR")) { |
| 44 if (entry.size != 0) | 44 if (entry.size != 0) |
| 45 return false; | 45 return false; |
| 46 entry.type = FtpDirectoryListingEntry::DIRECTORY; | 46 entry.type = FtpDirectoryListingEntry::DIRECTORY; |
| 47 entry.size = -1; | 47 entry.size = -1; |
| 48 } else if (EqualsASCII(columns[1], "A")) { | 48 } else if (base::EqualsASCII(columns[1], "A")) { |
| 49 entry.type = FtpDirectoryListingEntry::FILE; | 49 entry.type = FtpDirectoryListingEntry::FILE; |
| 50 if (entry.size < 0) | 50 if (entry.size < 0) |
| 51 return false; | 51 return false; |
| 52 } else { | 52 } else { |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (!FtpUtil::WindowsDateListingToTime(columns[2], | 56 if (!FtpUtil::WindowsDateListingToTime(columns[2], |
| 57 columns[3], | 57 columns[3], |
| 58 &entry.last_modified)) { | 58 &entry.last_modified)) { |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 | 61 |
| 62 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 4); | 62 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 4); |
| 63 if (entry.name.empty()) { | 63 if (entry.name.empty()) { |
| 64 // Some FTP servers send listing entries with empty names. | 64 // Some FTP servers send listing entries with empty names. |
| 65 // It's not obvious how to display such an entry, so ignore them. | 65 // It's not obvious how to display such an entry, so ignore them. |
| 66 // We don't want to make the parsing fail at this point though. | 66 // We don't want to make the parsing fail at this point though. |
| 67 // Other entries can still be useful. | 67 // Other entries can still be useful. |
| 68 continue; | 68 continue; |
| 69 } | 69 } |
| 70 | 70 |
| 71 entries->push_back(entry); | 71 entries->push_back(entry); |
| 72 } | 72 } |
| 73 | 73 |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace net | 77 } // namespace net |
| OLD | NEW |