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

Side by Side Diff: chrome/common/extensions/extension_file_util.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « chrome/common/chrome_paths.cc ('k') | chrome/common/extensions/extension_file_util_unittest.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir, 65 base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir,
66 const std::string& id, 66 const std::string& id,
67 const std::string& version, 67 const std::string& version,
68 const base::FilePath& extensions_dir) { 68 const base::FilePath& extensions_dir) {
69 base::FilePath extension_dir = extensions_dir.AppendASCII(id); 69 base::FilePath extension_dir = extensions_dir.AppendASCII(id);
70 base::FilePath version_dir; 70 base::FilePath version_dir;
71 71
72 // Create the extension directory if it doesn't exist already. 72 // Create the extension directory if it doesn't exist already.
73 if (!base::PathExists(extension_dir)) { 73 if (!base::PathExists(extension_dir)) {
74 if (!file_util::CreateDirectory(extension_dir)) 74 if (!base::CreateDirectory(extension_dir))
75 return base::FilePath(); 75 return base::FilePath();
76 } 76 }
77 77
78 // Get a temp directory on the same file system as the profile. 78 // Get a temp directory on the same file system as the profile.
79 base::FilePath install_temp_dir = GetInstallTempDir(extensions_dir); 79 base::FilePath install_temp_dir = GetInstallTempDir(extensions_dir);
80 base::ScopedTempDir extension_temp_dir; 80 base::ScopedTempDir extension_temp_dir;
81 if (install_temp_dir.empty() || 81 if (install_temp_dir.empty() ||
82 !extension_temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { 82 !extension_temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) {
83 LOG(ERROR) << "Creating of temp dir under in the profile failed."; 83 LOG(ERROR) << "Creating of temp dir under in the profile failed.";
84 return base::FilePath(); 84 return base::FilePath();
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 510 }
511 if (!base::PathIsWritable(temp_path)) { 511 if (!base::PathIsWritable(temp_path)) {
512 DLOG(WARNING) << "Can't write to path: " << temp_path.value(); 512 DLOG(WARNING) << "Can't write to path: " << temp_path.value();
513 return base::FilePath(); 513 return base::FilePath();
514 } 514 }
515 // This is a directory we can write to. 515 // This is a directory we can write to.
516 return temp_path; 516 return temp_path;
517 } 517 }
518 518
519 // Directory doesn't exist, so create it. 519 // Directory doesn't exist, so create it.
520 if (!file_util::CreateDirectory(temp_path)) { 520 if (!base::CreateDirectory(temp_path)) {
521 DLOG(WARNING) << "Couldn't create directory: " << temp_path.value(); 521 DLOG(WARNING) << "Couldn't create directory: " << temp_path.value();
522 return base::FilePath(); 522 return base::FilePath();
523 } 523 }
524 return temp_path; 524 return temp_path;
525 } 525 }
526 526
527 void DeleteFile(const base::FilePath& path, bool recursive) { 527 void DeleteFile(const base::FilePath& path, bool recursive) {
528 base::DeleteFile(path, recursive); 528 base::DeleteFile(path, recursive);
529 } 529 }
530 530
531 } // namespace extension_file_util 531 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths.cc ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698