Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: net/ftp/ftp_util.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // error. Just try another one. 167 // error. Just try another one.
168 if (U_FAILURE(status)) 168 if (U_FAILURE(status))
169 continue; 169 continue;
170 170
171 int32_t months_count; 171 int32_t months_count;
172 const icu::UnicodeString* months = 172 const icu::UnicodeString* months =
173 format_symbols.getShortMonths(months_count); 173 format_symbols.getShortMonths(months_count);
174 174
175 for (int32_t month = 0; month < months_count; month++) { 175 for (int32_t month = 0; month < months_count; month++) {
176 base::string16 month_name(months[month].getBuffer(), 176 base::string16 month_name(months[month].getBuffer(),
177 static_cast<size_t>(months[month].length())); 177 static_cast<size_t>(months[month].length()));
178 178
179 // Ignore the case of the month names. The simplest way to handle that 179 // Ignore the case of the month names. The simplest way to handle that
180 // is to make everything lowercase. 180 // is to make everything lowercase.
181 month_name = base::i18n::ToLower(month_name); 181 month_name = base::i18n::ToLower(month_name);
182 182
183 map_[month_name] = month + 1; 183 map_[month_name] = month + 1;
184 184
185 // Sometimes ICU returns longer strings, but in FTP listings a shorter 185 // Sometimes ICU returns longer strings, but in FTP listings a shorter
186 // abbreviation is used (for example for the Russian locale). Make sure 186 // abbreviation is used (for example for the Russian locale). Make sure
187 // we always have a map entry for a three-letter abbreviation. 187 // we always have a map entry for a three-letter abbreviation.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 int* number) { 221 int* number) {
222 return AbbreviatedMonthsMap::GetInstance()->GetMonthNumber(text, number); 222 return AbbreviatedMonthsMap::GetInstance()->GetMonthNumber(text, number);
223 } 223 }
224 224
225 // static 225 // static
226 bool FtpUtil::LsDateListingToTime(const base::string16& month, 226 bool FtpUtil::LsDateListingToTime(const base::string16& month,
227 const base::string16& day, 227 const base::string16& day,
228 const base::string16& rest, 228 const base::string16& rest,
229 const base::Time& current_time, 229 const base::Time& current_time,
230 base::Time* result) { 230 base::Time* result) {
231 base::Time::Exploded time_exploded = { 0 }; 231 base::Time::Exploded time_exploded = {0};
232 232
233 if (!AbbreviatedMonthToNumber(month, &time_exploded.month)) { 233 if (!AbbreviatedMonthToNumber(month, &time_exploded.month)) {
234 // Work around garbage sent by some servers in the same column 234 // Work around garbage sent by some servers in the same column
235 // as the month. Take just last 3 characters of the string. 235 // as the month. Take just last 3 characters of the string.
236 if (month.length() < 3 || 236 if (month.length() < 3 ||
237 !AbbreviatedMonthToNumber(month.substr(month.length() - 3), 237 !AbbreviatedMonthToNumber(month.substr(month.length() - 3),
238 &time_exploded.month)) { 238 &time_exploded.month)) {
239 return false; 239 return false;
240 } 240 }
241 } 241 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 // We don't know the time zone of the listing, so just use local time. 286 // We don't know the time zone of the listing, so just use local time.
287 *result = base::Time::FromLocalExploded(time_exploded); 287 *result = base::Time::FromLocalExploded(time_exploded);
288 return true; 288 return true;
289 } 289 }
290 290
291 // static 291 // static
292 bool FtpUtil::WindowsDateListingToTime(const base::string16& date, 292 bool FtpUtil::WindowsDateListingToTime(const base::string16& date,
293 const base::string16& time, 293 const base::string16& time,
294 base::Time* result) { 294 base::Time* result) {
295 base::Time::Exploded time_exploded = { 0 }; 295 base::Time::Exploded time_exploded = {0};
296 296
297 // Date should be in format MM-DD-YY[YY]. 297 // Date should be in format MM-DD-YY[YY].
298 std::vector<base::string16> date_parts; 298 std::vector<base::string16> date_parts;
299 base::SplitString(date, '-', &date_parts); 299 base::SplitString(date, '-', &date_parts);
300 if (date_parts.size() != 3) 300 if (date_parts.size() != 3)
301 return false; 301 return false;
302 if (!base::StringToInt(date_parts[0], &time_exploded.month)) 302 if (!base::StringToInt(date_parts[0], &time_exploded.month))
303 return false; 303 return false;
304 if (!base::StringToInt(date_parts[1], &time_exploded.day_of_month)) 304 if (!base::StringToInt(date_parts[1], &time_exploded.day_of_month))
305 return false; 305 return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 while (!iter.end() && !u_isspace(iter.get())) 364 while (!iter.end() && !u_isspace(iter.get()))
365 iter.Advance(); 365 iter.Advance();
366 } 366 }
367 367
368 base::string16 result(text.substr(iter.array_pos())); 368 base::string16 result(text.substr(iter.array_pos()));
369 base::TrimWhitespace(result, base::TRIM_ALL, &result); 369 base::TrimWhitespace(result, base::TRIM_ALL, &result);
370 return result; 370 return result;
371 } 371 }
372 372
373 } // namespace 373 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698