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

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

Issue 1215933004: New new versions of Starts/EndsWith and SplitString in net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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 | « net/ftp/ftp_directory_listing_parser_vms.cc ('k') | net/ftp/ftp_network_transaction.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_directory_listing_parser_windows.h" 5 #include "net/ftp/ftp_directory_listing_parser_windows.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "net/ftp/ftp_directory_listing_parser.h" 14 #include "net/ftp/ftp_directory_listing_parser.h"
14 #include "net/ftp/ftp_util.h" 15 #include "net/ftp/ftp_util.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 bool ParseFtpDirectoryListingWindows( 19 bool ParseFtpDirectoryListingWindows(
19 const std::vector<base::string16>& lines, 20 const std::vector<base::string16>& lines,
20 std::vector<FtpDirectoryListingEntry>* entries) { 21 std::vector<FtpDirectoryListingEntry>* entries) {
21 for (size_t i = 0; i < lines.size(); i++) { 22 for (size_t i = 0; i < lines.size(); i++) {
22 if (lines[i].empty()) 23 if (lines[i].empty())
23 continue; 24 continue;
24 25
25 std::vector<base::string16> columns; 26 std::vector<base::string16> columns = base::SplitString(
26 base::SplitString(base::CollapseWhitespace(lines[i], false), ' ', &columns); 27 base::CollapseWhitespace(lines[i], false), base::ASCIIToUTF16(" "),
28 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
27 29
28 // Every line of the listing consists of the following: 30 // Every line of the listing consists of the following:
29 // 31 //
30 // 1. date 32 // 1. date
31 // 2. time 33 // 2. time
32 // 3. size in bytes (or "<DIR>" for directories) 34 // 3. size in bytes (or "<DIR>" for directories)
33 // 4. filename (may be empty or contain spaces) 35 // 4. filename (may be empty or contain spaces)
34 // 36 //
35 // For now, make sure we have 1-3, and handle 4 later. 37 // For now, make sure we have 1-3, and handle 4 later.
36 if (columns.size() < 3) 38 if (columns.size() < 3)
(...skipping 26 matching lines...) Expand all
63 continue; 65 continue;
64 } 66 }
65 67
66 entries->push_back(entry); 68 entries->push_back(entry);
67 } 69 }
68 70
69 return true; 71 return true;
70 } 72 }
71 73
72 } // namespace net 74 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_vms.cc ('k') | net/ftp/ftp_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698