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

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

Issue 465035: Split FTP LIST parsing code into individual files for each listing style. (Closed)
Patch Set: fix Created 11 years 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
« no previous file with comments | « net/ftp/ftp_util.h ('k') | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 std::replace(result.begin(), result.end(), '.', '/'); 97 std::replace(result.begin(), result.end(), '.', '/');
98 std::replace(result.begin(), result.end(), ']', '/'); 98 std::replace(result.begin(), result.end(), ']', '/');
99 99
100 // Make sure the result doesn't end with a slash. 100 // Make sure the result doesn't end with a slash.
101 if (result[result.length() - 1] == '/') 101 if (result[result.length() - 1] == '/')
102 result = result.substr(0, result.length() - 1); 102 result = result.substr(0, result.length() - 1);
103 103
104 return result; 104 return result;
105 } 105 }
106 106
107 // static
108 bool FtpUtil::ThreeLetterMonthToNumber(const string16& text, int* number) {
109 const static char* months[] = { "jan", "feb", "mar", "apr", "may", "jun",
110 "jul", "aug", "sep", "oct", "nov", "dec" };
111
112 for (size_t i = 0; i < arraysize(months); i++) {
113 if (LowerCaseEqualsASCII(text, months[i])) {
114 *number = i + 1;
115 return true;
116 }
117 }
118
119 // Special cases for directory listings in German (other three-letter month
120 // abbreviations are the same as in English). Note that we don't need to do
121 // a case-insensitive compare here. Only "ls -l" style listings may use
122 // localized month names, and they will always start capitalized. Also,
123 // converting non-ASCII characters to lowercase would be more complicated.
124 if (text == UTF8ToUTF16("M\xc3\xa4r")) {
125 // The full month name is M-(a-umlaut)-rz (March), which is M-(a-umlaut)r
126 // when abbreviated.
127 *number = 3;
128 return true;
129 }
130 if (text == ASCIIToUTF16("Mai")) {
131 *number = 5;
132 return true;
133 }
134 if (text == ASCIIToUTF16("Okt")) {
135 *number = 10;
136 return true;
137 }
138 if (text == ASCIIToUTF16("Dez")) {
139 *number = 12;
140 return true;
141 }
142
143 return false;
144 }
145
146
107 } // namespace 147 } // namespace
OLDNEW
« no previous file with comments | « net/ftp/ftp_util.h ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698