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_util.h" | 5 #include "net/ftp/ftp_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
11 #include "base/i18n/char_iterator.h" | 11 #include "base/i18n/char_iterator.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_piece.h" | |
15 #include "base/string_split.h" | 16 #include "base/string_split.h" |
16 #include "base/string_tokenizer.h" | 17 #include "base/string_tokenizer.h" |
17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "unicode/datefmt.h" | 21 #include "unicode/datefmt.h" |
21 #include "unicode/dtfmtsym.h" | 22 #include "unicode/dtfmtsym.h" |
22 #include "unicode/uchar.h" | 23 #include "unicode/uchar.h" |
23 | 24 |
25 using base::StringPiece16; | |
26 | |
24 // For examples of Unix<->VMS path conversions, see the unit test file. On VMS | 27 // For examples of Unix<->VMS path conversions, see the unit test file. On VMS |
25 // a path looks differently depending on whether it's a file or directory. | 28 // a path looks differently depending on whether it's a file or directory. |
26 | 29 |
27 namespace net { | 30 namespace net { |
28 | 31 |
29 // static | 32 // static |
30 std::string FtpUtil::UnixFilePathToVMS(const std::string& unix_path) { | 33 std::string FtpUtil::UnixFilePathToVMS(const std::string& unix_path) { |
31 if (unix_path.empty()) | 34 if (unix_path.empty()) |
32 return std::string(); | 35 return std::string(); |
33 | 36 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 return false; | 207 return false; |
205 | 208 |
206 if (!base::StringToInt(day, &time_exploded.day_of_month)) | 209 if (!base::StringToInt(day, &time_exploded.day_of_month)) |
207 return false; | 210 return false; |
208 if (time_exploded.day_of_month > 31) | 211 if (time_exploded.day_of_month > 31) |
209 return false; | 212 return false; |
210 | 213 |
211 if (!base::StringToInt(rest, &time_exploded.year)) { | 214 if (!base::StringToInt(rest, &time_exploded.year)) { |
212 // Maybe it's time. Does it look like time (HH:MM)? | 215 // Maybe it's time. Does it look like time (HH:MM)? |
213 if (rest.length() == 5 && rest[2] == ':') { | 216 if (rest.length() == 5 && rest[2] == ':') { |
214 if (!base::StringToInt(rest.begin(), | 217 if (!base::StringToInt(StringPiece16(rest.begin(), rest.begin() + 2), |
215 rest.begin() + 2, | |
216 &time_exploded.hour)) | 218 &time_exploded.hour)) |
erikwright (departed)
2011/12/14 04:24:08
need {} around if and else blocks when condition w
| |
217 return false; | 219 return false; |
218 | 220 |
219 if (!base::StringToInt(rest.begin() + 3, | 221 if (!base::StringToInt(StringPiece16(rest.begin() + 3, rest.begin() + 5), |
erikwright (departed)
2011/12/14 04:24:08
need {} around if and else blocks when condition w
| |
220 rest.begin() + 5, | |
221 &time_exploded.minute)) | 222 &time_exploded.minute)) |
222 return false; | 223 return false; |
223 } else if (rest.length() == 4 && rest[1] == ':') { | 224 } else if (rest.length() == 4 && rest[1] == ':') { |
224 // Sometimes it's just H:MM. | 225 // Sometimes it's just H:MM. |
225 if (!base::StringToInt(rest.begin(), | 226 if (!base::StringToInt(StringPiece16(rest.begin(), rest.begin() + 1), |
erikwright (departed)
2011/12/14 04:24:08
need {} around if and else blocks when condition w
| |
226 rest.begin() + 1, | |
227 &time_exploded.hour)) | 227 &time_exploded.hour)) |
228 return false; | 228 return false; |
229 | 229 |
230 if (!base::StringToInt(rest.begin() + 2, | 230 if (!base::StringToInt(StringPiece16(rest.begin() + 2, rest.begin() + 4), |
erikwright (departed)
2011/12/14 04:24:08
need {} around if and else blocks when condition w
| |
231 rest.begin() + 4, | |
232 &time_exploded.minute)) | 231 &time_exploded.minute)) |
233 return false; | 232 return false; |
234 } else { | 233 } else { |
235 return false; | 234 return false; |
236 } | 235 } |
237 | 236 |
238 // Guess the year. | 237 // Guess the year. |
239 base::Time::Exploded current_exploded; | 238 base::Time::Exploded current_exploded; |
240 current_time.LocalExplode(¤t_exploded); | 239 current_time.LocalExplode(¤t_exploded); |
241 | 240 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 while (!iter.end() && !u_isspace(iter.get())) | 329 while (!iter.end() && !u_isspace(iter.get())) |
331 iter.Advance(); | 330 iter.Advance(); |
332 } | 331 } |
333 | 332 |
334 string16 result(text.substr(iter.array_pos())); | 333 string16 result(text.substr(iter.array_pos())); |
335 TrimWhitespace(result, TRIM_ALL, &result); | 334 TrimWhitespace(result, TRIM_ALL, &result); |
336 return result; | 335 return result; |
337 } | 336 } |
338 | 337 |
339 } // namespace | 338 } // namespace |
OLD | NEW |