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.
5 #include "base/files/file_util.h"
7 #import <Foundation/Foundation.h>
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"
18 bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
19 ThreadRestrictions::AssertIOAllowed();
20 if (from_path.ReferencesParent() || to_path.ReferencesParent())
22 return (copyfile(from_path.value().c_str(),
23 to_path.value().c_str(), NULL, COPYFILE_DATA) == 0);
26 bool GetTempDir(base::FilePath* path) {
27 NSString* tmp = NSTemporaryDirectory();
30 *path = base::mac::NSStringToFilePath(tmp);
34 FilePath GetHomeDir() {
35 NSString* tmp = NSHomeDirectory();
37 FilePath mac_home_dir = base::mac::NSStringToFilePath(tmp);
38 if (!mac_home_dir.empty())
42 // Fall back on temp dir if no home directory is defined.
48 return FilePath("/tmp");