| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_util.h" | 5 #include "net/ftp/ftp_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/time.h" |
| 12 | 13 |
| 13 // For examples of Unix<->VMS path conversions, see the unit test file. On VMS | 14 // For examples of Unix<->VMS path conversions, see the unit test file. On VMS |
| 14 // a path looks differently depending on whether it's a file or directory. | 15 // a path looks differently depending on whether it's a file or directory. |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 std::string FtpUtil::UnixFilePathToVMS(const std::string& unix_path) { | 20 std::string FtpUtil::UnixFilePathToVMS(const std::string& unix_path) { |
| 20 if (unix_path.empty()) | 21 if (unix_path.empty()) |
| 21 return std::string(); | 22 return std::string(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return true; | 137 return true; |
| 137 } | 138 } |
| 138 if (text == ASCIIToUTF16("Dez")) { | 139 if (text == ASCIIToUTF16("Dez")) { |
| 139 *number = 12; | 140 *number = 12; |
| 140 return true; | 141 return true; |
| 141 } | 142 } |
| 142 | 143 |
| 143 return false; | 144 return false; |
| 144 } | 145 } |
| 145 | 146 |
| 147 // static |
| 148 bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, |
| 149 const string16& rest, base::Time* time) { |
| 150 base::Time::Exploded time_exploded = { 0 }; |
| 151 |
| 152 if (!ThreeLetterMonthToNumber(month, &time_exploded.month)) |
| 153 return false; |
| 154 |
| 155 if (!StringToInt(day, &time_exploded.day_of_month)) |
| 156 return false; |
| 157 |
| 158 if (!StringToInt(rest, &time_exploded.year)) { |
| 159 // Maybe it's time. Does it look like time (MM:HH)? |
| 160 if (rest.length() != 5 || rest[2] != ':') |
| 161 return false; |
| 162 |
| 163 if (!StringToInt(rest.substr(0, 2), &time_exploded.hour)) |
| 164 return false; |
| 165 |
| 166 if (!StringToInt(rest.substr(3, 2), &time_exploded.minute)) |
| 167 return false; |
| 168 |
| 169 // Use current year. |
| 170 base::Time::Exploded now_exploded; |
| 171 base::Time::Now().LocalExplode(&now_exploded); |
| 172 time_exploded.year = now_exploded.year; |
| 173 } |
| 174 |
| 175 // We don't know the time zone of the listing, so just use local time. |
| 176 *time = base::Time::FromLocalExploded(time_exploded); |
| 177 return true; |
| 178 } |
| 146 | 179 |
| 147 } // namespace | 180 } // namespace |
| OLD | NEW |