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

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

Issue 1120012: Fix the "ls -l" style date parser to correctly guess the year if it is not provided. (Closed)
Patch Set: better comments Created 10 years, 9 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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_parser_netware.h" 5 #include "net/ftp/ftp_directory_listing_parser_netware.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/ftp/ftp_util.h" 10 #include "net/ftp/ftp_util.h"
(...skipping 13 matching lines...) Expand all
24 (text[5] == 'A' || text[5] == '-') && 24 (text[5] == 'A' || text[5] == '-') &&
25 (text[6] == 'F' || text[6] == '-') && 25 (text[6] == 'F' || text[6] == '-') &&
26 (text[7] == 'M' || text[7] == '-') && 26 (text[7] == 'M' || text[7] == '-') &&
27 (text[8] == 'S' || text[8] == '-'); 27 (text[8] == 'S' || text[8] == '-');
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 namespace net { 32 namespace net {
33 33
34 FtpDirectoryListingParserNetware::FtpDirectoryListingParserNetware() 34 FtpDirectoryListingParserNetware::FtpDirectoryListingParserNetware(
35 : received_first_line_(false) { 35 const base::Time& current_time)
36 : received_first_line_(false),
37 current_time_(current_time) {
36 } 38 }
37 39
38 bool FtpDirectoryListingParserNetware::ConsumeLine(const string16& line) { 40 bool FtpDirectoryListingParserNetware::ConsumeLine(const string16& line) {
39 if (!received_first_line_) { 41 if (!received_first_line_) {
40 received_first_line_ = true; 42 received_first_line_ = true;
41 43
42 return StartsWith(line, ASCIIToUTF16("total "), true); 44 return StartsWith(line, ASCIIToUTF16("total "), true);
43 } 45 }
44 46
45 std::vector<string16> columns; 47 std::vector<string16> columns;
(...skipping 22 matching lines...) Expand all
68 70
69 if (!StringToInt64(columns[3], &entry.size)) 71 if (!StringToInt64(columns[3], &entry.size))
70 return false; 72 return false;
71 if (entry.size < 0) 73 if (entry.size < 0)
72 return false; 74 return false;
73 if (entry.type != FtpDirectoryListingEntry::FILE) 75 if (entry.type != FtpDirectoryListingEntry::FILE)
74 entry.size = -1; 76 entry.size = -1;
75 77
76 // Netware uses the same date listing format as Unix "ls -l". 78 // Netware uses the same date listing format as Unix "ls -l".
77 if (!FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6], 79 if (!FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6],
78 &entry.last_modified)) { 80 current_time_, &entry.last_modified)) {
79 return false; 81 return false;
80 } 82 }
81 83
82 entry.name = columns[7]; 84 entry.name = columns[7];
83 85
84 entries_.push(entry); 86 entries_.push(entry);
85 return true; 87 return true;
86 } 88 }
87 89
88 bool FtpDirectoryListingParserNetware::OnEndOfInput() { 90 bool FtpDirectoryListingParserNetware::OnEndOfInput() {
89 return true; 91 return true;
90 } 92 }
91 93
92 bool FtpDirectoryListingParserNetware::EntryAvailable() const { 94 bool FtpDirectoryListingParserNetware::EntryAvailable() const {
93 return !entries_.empty(); 95 return !entries_.empty();
94 } 96 }
95 97
96 FtpDirectoryListingEntry FtpDirectoryListingParserNetware::PopEntry() { 98 FtpDirectoryListingEntry FtpDirectoryListingParserNetware::PopEntry() {
97 FtpDirectoryListingEntry entry = entries_.front(); 99 FtpDirectoryListingEntry entry = entries_.front();
98 entries_.pop(); 100 entries_.pop();
99 return entry; 101 return entry;
100 } 102 }
101 103
102 } // namespace net 104 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_netware.h ('k') | net/ftp/ftp_directory_listing_parser_netware_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698