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

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

Issue 3968001: Update code that previously constructed strings from string iterators only to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_mlsd.h" 5 #include "net/ftp/ftp_directory_listing_parser_mlsd.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 10 matching lines...) Expand all
21 // The MLSD date listing is specified at 21 // The MLSD date listing is specified at
22 // http://tools.ietf.org/html/rfc3659#page-6. 22 // http://tools.ietf.org/html/rfc3659#page-6.
23 bool MlsdDateListingToTime(const string16& text, base::Time* time) { 23 bool MlsdDateListingToTime(const string16& text, base::Time* time) {
24 base::Time::Exploded time_exploded = { 0 }; 24 base::Time::Exploded time_exploded = { 0 };
25 25
26 // We will only test 12 characters, but RFC-3659 requires 14 (we ignore the 26 // We will only test 12 characters, but RFC-3659 requires 14 (we ignore the
27 // last two digits, which contain the number of seconds). 27 // last two digits, which contain the number of seconds).
28 if (text.length() < 14) 28 if (text.length() < 14)
29 return false; 29 return false;
30 30
31 if (!base::StringToInt(text.substr(0, 4), &time_exploded.year)) 31 if (!base::StringToInt(text.begin(), text.begin() + 4, &time_exploded.year))
32 return false; 32 return false;
33 if (!base::StringToInt(text.substr(4, 2), &time_exploded.month)) 33 if (!base::StringToInt(text.begin() + 4,
34 text.begin() + 6,
35 &time_exploded.month))
34 return false; 36 return false;
35 if (!base::StringToInt(text.substr(6, 2), &time_exploded.day_of_month)) 37 if (!base::StringToInt(text.begin() + 6,
38 text.begin() + 8,
39 &time_exploded.day_of_month))
36 return false; 40 return false;
37 if (!base::StringToInt(text.substr(8, 2), &time_exploded.hour)) 41 if (!base::StringToInt(text.begin() + 8,
42 text.begin() + 10,
43 &time_exploded.hour))
38 return false; 44 return false;
39 if (!base::StringToInt(text.substr(10, 2), &time_exploded.minute)) 45 if (!base::StringToInt(text.begin() + 10,
46 text.begin() + 12,
47 &time_exploded.minute))
40 return false; 48 return false;
41 49
42 // We don't know the time zone of the server, so just use local time. 50 // We don't know the time zone of the server, so just use local time.
43 *time = base::Time::FromLocalExploded(time_exploded); 51 *time = base::Time::FromLocalExploded(time_exploded);
44 return true; 52 return true;
45 } 53 }
46 54
47 } // namespace 55 } // namespace
48 56
49 namespace net { 57 namespace net {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 133 }
126 134
127 FtpDirectoryListingEntry FtpDirectoryListingParserMlsd::PopEntry() { 135 FtpDirectoryListingEntry FtpDirectoryListingParserMlsd::PopEntry() {
128 DCHECK(EntryAvailable()); 136 DCHECK(EntryAvailable());
129 FtpDirectoryListingEntry entry = entries_.front(); 137 FtpDirectoryListingEntry entry = entries_.front();
130 entries_.pop(); 138 entries_.pop();
131 return entry; 139 return entry;
132 } 140 }
133 141
134 } // namespace net 142 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698