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

Side by Side Diff: chrome/browser/chromeos/drive/file_system_util.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/drive/file_system_util.h" 5 #include "chrome/browser/chromeos/drive/file_system_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 // Moves all files under |directory_from| to |directory_to|. 117 // Moves all files under |directory_from| to |directory_to|.
118 void MoveAllFilesFromDirectory(const base::FilePath& directory_from, 118 void MoveAllFilesFromDirectory(const base::FilePath& directory_from,
119 const base::FilePath& directory_to) { 119 const base::FilePath& directory_to) {
120 base::FileEnumerator enumerator(directory_from, false, // not recursive 120 base::FileEnumerator enumerator(directory_from, false, // not recursive
121 base::FileEnumerator::FILES); 121 base::FileEnumerator::FILES);
122 for (base::FilePath file_from = enumerator.Next(); !file_from.empty(); 122 for (base::FilePath file_from = enumerator.Next(); !file_from.empty();
123 file_from = enumerator.Next()) { 123 file_from = enumerator.Next()) {
124 const base::FilePath file_to = directory_to.Append(file_from.BaseName()); 124 const base::FilePath file_to = directory_to.Append(file_from.BaseName());
125 if (!file_util::PathExists(file_to)) // Do not overwrite existing files. 125 if (!base::PathExists(file_to)) // Do not overwrite existing files.
126 base::Move(file_from, file_to); 126 base::Move(file_from, file_to);
127 } 127 }
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 const base::FilePath& GetDriveGrandRootPath() { 132 const base::FilePath& GetDriveGrandRootPath() {
133 CR_DEFINE_STATIC_LOCAL(base::FilePath, grand_root_path, 133 CR_DEFINE_STATIC_LOCAL(base::FilePath, grand_root_path,
134 (util::kDriveGrandRootDirName)); 134 (util::kDriveGrandRootDirName));
135 return grand_root_path; 135 return grand_root_path;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ReplaceChars(output, kSlash, std::string(kEscapedSlash), &output); 308 ReplaceChars(output, kSlash, std::string(kEscapedSlash), &output);
309 return output; 309 return output;
310 } 310 }
311 311
312 void MigrateCacheFilesFromOldDirectories( 312 void MigrateCacheFilesFromOldDirectories(
313 const base::FilePath& cache_root_directory) { 313 const base::FilePath& cache_root_directory) {
314 const base::FilePath persistent_directory = 314 const base::FilePath persistent_directory =
315 cache_root_directory.AppendASCII("persistent"); 315 cache_root_directory.AppendASCII("persistent");
316 const base::FilePath tmp_directory = 316 const base::FilePath tmp_directory =
317 cache_root_directory.AppendASCII("tmp"); 317 cache_root_directory.AppendASCII("tmp");
318 if (!file_util::PathExists(persistent_directory)) 318 if (!base::PathExists(persistent_directory))
319 return; 319 return;
320 320
321 const base::FilePath cache_file_directory = 321 const base::FilePath cache_file_directory =
322 cache_root_directory.Append(kCacheFileDirectory); 322 cache_root_directory.Append(kCacheFileDirectory);
323 323
324 // Move all files inside "persistent" to "files". 324 // Move all files inside "persistent" to "files".
325 MoveAllFilesFromDirectory(persistent_directory, cache_file_directory); 325 MoveAllFilesFromDirectory(persistent_directory, cache_file_directory);
326 base::Delete(persistent_directory, true /* recursive */); 326 base::Delete(persistent_directory, true /* recursive */);
327 327
328 // Move all files inside "tmp" to "files". 328 // Move all files inside "tmp" to "files".
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 base::MD5Update(&context, base::StringPiece(buffer.get(), result)); 470 base::MD5Update(&context, base::StringPiece(buffer.get(), result));
471 } 471 }
472 472
473 base::MD5Digest digest; 473 base::MD5Digest digest;
474 base::MD5Final(&digest, &context); 474 base::MD5Final(&digest, &context);
475 return MD5DigestToBase16(digest); 475 return MD5DigestToBase16(digest);
476 } 476 }
477 477
478 } // namespace util 478 } // namespace util
479 } // namespace drive 479 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698