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

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

Issue 3774002: Fix FTP directory listing for ftp.cisco.com. (Closed)
Patch Set: fixes Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_ls.h" 5 #include "net/ftp/ftp_directory_listing_parser_ls.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 FtpDirectoryListingEntry entry; 134 FtpDirectoryListingEntry entry;
135 if (columns[0][0] == 'l') { 135 if (columns[0][0] == 'l') {
136 entry.type = FtpDirectoryListingEntry::SYMLINK; 136 entry.type = FtpDirectoryListingEntry::SYMLINK;
137 } else if (columns[0][0] == 'd') { 137 } else if (columns[0][0] == 'd') {
138 entry.type = FtpDirectoryListingEntry::DIRECTORY; 138 entry.type = FtpDirectoryListingEntry::DIRECTORY;
139 } else { 139 } else {
140 entry.type = FtpDirectoryListingEntry::FILE; 140 entry.type = FtpDirectoryListingEntry::FILE;
141 } 141 }
142 142
143 if (!base::StringToInt64(columns[2 + column_offset], &entry.size)) 143 if (!base::StringToInt64(columns[2 + column_offset], &entry.size)) {
144 return false; 144 // Some FTP servers do not separate owning group name from file size,
145 // like "group1234". We still want to display the file name for that entry,
146 // but can't really get the size (What if the group is named "group1",
147 // and the size is in fact 234? We can't distinguish between that
148 // and "group" with size 1234). Use a dummy value for the size.
149 // TODO(phajdan.jr): Use a value that means "unknown" instead of 0 bytes.
150 entry.size = 0;
151 }
145 if (entry.size < 0) 152 if (entry.size < 0)
146 return false; 153 return false;
147 if (entry.type != FtpDirectoryListingEntry::FILE) 154 if (entry.type != FtpDirectoryListingEntry::FILE)
148 entry.size = -1; 155 entry.size = -1;
149 156
150 if (!FtpUtil::LsDateListingToTime(columns[3 + column_offset], 157 if (!FtpUtil::LsDateListingToTime(columns[3 + column_offset],
151 columns[4 + column_offset], 158 columns[4 + column_offset],
152 columns[5 + column_offset], 159 columns[5 + column_offset],
153 current_time_, 160 current_time_,
154 &entry.last_modified)) { 161 &entry.last_modified)) {
(...skipping 22 matching lines...) Expand all
177 return !entries_.empty(); 184 return !entries_.empty();
178 } 185 }
179 186
180 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { 187 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() {
181 FtpDirectoryListingEntry entry = entries_.front(); 188 FtpDirectoryListingEntry entry = entries_.front();
182 entries_.pop(); 189 entries_.pop();
183 return entry; 190 return entry;
184 } 191 }
185 192
186 } // namespace net 193 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parser_ls_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698