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

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

Issue 2610973002: Fix a pair of bugs in UNIX->VMS path conversion. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | net/ftp/ftp_util_unittest.cc » ('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) 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 27 matching lines...) Expand all
38 38
39 base::StringTokenizer tokenizer(unix_path, "/"); 39 base::StringTokenizer tokenizer(unix_path, "/");
40 std::vector<std::string> tokens; 40 std::vector<std::string> tokens;
41 while (tokenizer.GetNext()) 41 while (tokenizer.GetNext())
42 tokens.push_back(tokenizer.token()); 42 tokens.push_back(tokenizer.token());
43 43
44 if (unix_path[0] == '/') { 44 if (unix_path[0] == '/') {
45 // It's an absolute path. 45 // It's an absolute path.
46 46
47 if (tokens.empty()) { 47 if (tokens.empty()) {
48 DCHECK_EQ(1U, unix_path.length()); 48 // It's just "/" or a series of slashes, which all mean the same thing.
49 return "[]"; 49 return "[]";
50 } 50 }
51 51
52 if (tokens.size() == 1) 52 if (tokens.size() == 1)
53 return unix_path.substr(1); // Drop the leading slash. 53 return tokens.front(); // Return without leading slashes.
54 54
55 std::string result(tokens[0] + ":["); 55 std::string result(tokens[0] + ":[");
56 if (tokens.size() == 2) { 56 if (tokens.size() == 2) {
57 // Don't ask why, it just works that way on VMS. 57 // Don't ask why, it just works that way on VMS.
58 result.append("000000"); 58 result.append("000000");
59 } else { 59 } else {
60 result.append(tokens[1]); 60 result.append(tokens[1]);
61 for (size_t i = 2; i < tokens.size() - 1; i++) 61 for (size_t i = 2; i < tokens.size() - 1; i++)
62 result.append("." + tokens[i]); 62 result.append("." + tokens[i]);
63 } 63 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 while (!iter.end() && !u_isspace(iter.get())) 367 while (!iter.end() && !u_isspace(iter.get()))
368 iter.Advance(); 368 iter.Advance();
369 } 369 }
370 370
371 base::string16 result(text.substr(iter.array_pos())); 371 base::string16 result(text.substr(iter.array_pos()));
372 base::TrimWhitespace(result, base::TRIM_ALL, &result); 372 base::TrimWhitespace(result, base::TRIM_ALL, &result);
373 return result; 373 return result;
374 } 374 }
375 375
376 } // namespace net 376 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/ftp/ftp_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698