| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_vms.h" | 5 #include "net/ftp/ftp_directory_listing_parser_vms.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 28 matching lines...) Expand all Loading... |
| 39 // Even directories have extensions in the listings. Don't display extensions | 39 // Even directories have extensions in the listings. Don't display extensions |
| 40 // for directories; it's awkward for non-VMS users. Also, VMS is | 40 // for directories; it's awkward for non-VMS users. Also, VMS is |
| 41 // case-insensitive, but generally uses uppercase characters. This may look | 41 // case-insensitive, but generally uses uppercase characters. This may look |
| 42 // awkward, so we convert them to lower case. | 42 // awkward, so we convert them to lower case. |
| 43 std::vector<base::string16> filename_parts = | 43 std::vector<base::string16> filename_parts = |
| 44 base::SplitString(listing_parts[0], base::ASCIIToUTF16("."), | 44 base::SplitString(listing_parts[0], base::ASCIIToUTF16("."), |
| 45 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 45 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 46 if (filename_parts.size() != 2) | 46 if (filename_parts.size() != 2) |
| 47 return false; | 47 return false; |
| 48 if (base::EqualsASCII(filename_parts[1], "DIR")) { | 48 if (base::EqualsASCII(filename_parts[1], "DIR")) { |
| 49 *parsed_filename = base::StringToLowerASCII(filename_parts[0]); | 49 *parsed_filename = base::ToLowerASCII(filename_parts[0]); |
| 50 *type = FtpDirectoryListingEntry::DIRECTORY; | 50 *type = FtpDirectoryListingEntry::DIRECTORY; |
| 51 } else { | 51 } else { |
| 52 *parsed_filename = base::StringToLowerASCII(listing_parts[0]); | 52 *parsed_filename = base::ToLowerASCII(listing_parts[0]); |
| 53 *type = FtpDirectoryListingEntry::FILE; | 53 *type = FtpDirectoryListingEntry::FILE; |
| 54 } | 54 } |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool ParseVmsFilesize(const base::string16& input, int64* size) { | 58 bool ParseVmsFilesize(const base::string16& input, int64* size) { |
| 59 if (base::ContainsOnlyChars(input, base::ASCIIToUTF16("*"))) { | 59 if (base::ContainsOnlyChars(input, base::ASCIIToUTF16("*"))) { |
| 60 // Response consisting of asterisks means unknown size. | 60 // Response consisting of asterisks means unknown size. |
| 61 *size = -1; | 61 *size = -1; |
| 62 return true; | 62 return true; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 entries->push_back(entry); | 292 entries->push_back(entry); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // The only place where we return true is after receiving the "Total" line, | 295 // The only place where we return true is after receiving the "Total" line, |
| 296 // that should be present in every VMS listing. Alternatively, if the listing | 296 // that should be present in every VMS listing. Alternatively, if the listing |
| 297 // contains error messages, it's OK not to have the "Total" line. | 297 // contains error messages, it's OK not to have the "Total" line. |
| 298 return seen_error; | 298 return seen_error; |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace net | 301 } // namespace net |
| OLD | NEW |