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

Side by Side Diff: base/test/test_file_util_win.cc

Issue 1284833004: Remove remaining legacy SplitString calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « base/strings/string_split_unittest.cc ('k') | chrome/browser/io_thread.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/test/test_file_util.h" 5 #include "base/test/test_file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <aclapi.h> 8 #include <aclapi.h>
9 #include <shlwapi.h> 9 #include <shlwapi.h>
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // Return whether the ZoneIdentifier is correctly set to "Internet" (3) 236 // Return whether the ZoneIdentifier is correctly set to "Internet" (3)
237 // Only returns a valid result when called from same process as the 237 // Only returns a valid result when called from same process as the
238 // one that (was supposed to have) set the zone identifier. 238 // one that (was supposed to have) set the zone identifier.
239 bool HasInternetZoneIdentifier(const FilePath& full_path) { 239 bool HasInternetZoneIdentifier(const FilePath& full_path) {
240 FilePath zone_path(full_path.value() + L":Zone.Identifier"); 240 FilePath zone_path(full_path.value() + L":Zone.Identifier");
241 std::string zone_path_contents; 241 std::string zone_path_contents;
242 if (!ReadFileToString(zone_path, &zone_path_contents)) 242 if (!ReadFileToString(zone_path, &zone_path_contents))
243 return false; 243 return false;
244 244
245 std::vector<std::string> lines; 245 std::vector<std::string> lines = SplitString(
246 // This call also trims whitespaces, including carriage-returns (\r). 246 zone_path_contents, "\n", TRIM_WHITESPACE, SPLIT_WANT_ALL);
247 SplitString(zone_path_contents, '\n', &lines);
248
249 switch (lines.size()) { 247 switch (lines.size()) {
250 case 3: 248 case 3:
251 // optional empty line at end of file: 249 // optional empty line at end of file:
252 if (!lines[2].empty()) 250 if (!lines[2].empty())
253 return false; 251 return false;
254 // fall through: 252 // fall through:
255 case 2: 253 case 2:
256 return lines[0] == "[ZoneTransfer]" && lines[1] == "ZoneId=3"; 254 return lines[0] == "[ZoneTransfer]" && lines[1] == "ZoneId=3";
257 default: 255 default:
258 return false; 256 return false;
(...skipping 14 matching lines...) Expand all
273 DCHECK(info_ != NULL); 271 DCHECK(info_ != NULL);
274 DCHECK_NE(0u, length_); 272 DCHECK_NE(0u, length_);
275 } 273 }
276 274
277 FilePermissionRestorer::~FilePermissionRestorer() { 275 FilePermissionRestorer::~FilePermissionRestorer() {
278 if (!RestorePermissionInfo(path_, info_, length_)) 276 if (!RestorePermissionInfo(path_, info_, length_))
279 NOTREACHED(); 277 NOTREACHED();
280 } 278 }
281 279
282 } // namespace base 280 } // namespace base
OLDNEW
« no previous file with comments | « base/strings/string_split_unittest.cc ('k') | chrome/browser/io_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698