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

Side by Side Diff: net/ftp/ftp_directory_listing_parser_os2.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
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_os2.h" 5 #include "net/ftp/ftp_directory_listing_parser_os2.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 ParseFtpDirectoryListingOS2( 19 bool ParseFtpDirectoryListingOS2(
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. size in bytes (0 for directories) 32 // 1. size in bytes (0 for directories)
31 // 2. type (A for files, DIR for directories) 33 // 2. type (A for files, DIR for directories)
32 // 3. date 34 // 3. date
33 // 4. time 35 // 4. time
34 // 5. filename (may be empty or contain spaces) 36 // 5. filename (may be empty or contain spaces)
35 // 37 //
36 // For now, make sure we have 1-4, and handle 5 later. 38 // For now, make sure we have 1-4, and handle 5 later.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 continue; 70 continue;
69 } 71 }
70 72
71 entries->push_back(entry); 73 entries->push_back(entry);
72 } 74 }
73 75
74 return true; 76 return true;
75 } 77 }
76 78
77 } // namespace net 79 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_netware.cc ('k') | net/ftp/ftp_directory_listing_parser_vms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698