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

Side by Side Diff: base/files/file_util_mac.mm

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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/files/file_util_linux.cc ('k') | base/files/file_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/files/file_util.h"
6
7 #include <copyfile.h>
8 #import <Foundation/Foundation.h>
9
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/mac/foundation_util.h"
13 #include "base/strings/string_util.h"
14 #include "base/threading/thread_restrictions.h"
15
16 namespace base {
17
18 bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
19 ThreadRestrictions::AssertIOAllowed();
20 if (from_path.ReferencesParent() || to_path.ReferencesParent())
21 return false;
22 return (copyfile(from_path.value().c_str(),
23 to_path.value().c_str(), NULL, COPYFILE_DATA) == 0);
24 }
25
26 bool GetTempDir(base::FilePath* path) {
27 NSString* tmp = NSTemporaryDirectory();
28 if (tmp == nil)
29 return false;
30 *path = base::mac::NSStringToFilePath(tmp);
31 return true;
32 }
33
34 FilePath GetHomeDir() {
35 NSString* tmp = NSHomeDirectory();
36 if (tmp != nil) {
37 FilePath mac_home_dir = base::mac::NSStringToFilePath(tmp);
38 if (!mac_home_dir.empty())
39 return mac_home_dir;
40 }
41
42 // Fall back on temp dir if no home directory is defined.
43 FilePath rv;
44 if (GetTempDir(&rv))
45 return rv;
46
47 // Last resort.
48 return FilePath("/tmp");
49 }
50
51 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_linux.cc ('k') | base/files/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698