OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <copyfile.h> | 8 #include <copyfile.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/thread_restrictions.h" |
13 | 14 |
14 namespace file_util { | 15 namespace file_util { |
15 | 16 |
16 bool GetTempDir(FilePath* path) { | 17 bool GetTempDir(FilePath* path) { |
17 NSString* tmp = NSTemporaryDirectory(); | 18 NSString* tmp = NSTemporaryDirectory(); |
18 if (tmp == nil) | 19 if (tmp == nil) |
19 return false; | 20 return false; |
20 *path = FilePath([tmp fileSystemRepresentation]); | 21 *path = FilePath([tmp fileSystemRepresentation]); |
21 return true; | 22 return true; |
22 } | 23 } |
23 | 24 |
24 bool GetShmemTempDir(FilePath* path) { | 25 bool GetShmemTempDir(FilePath* path) { |
25 return GetTempDir(path); | 26 return GetTempDir(path); |
26 } | 27 } |
27 | 28 |
28 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { | 29 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { |
| 30 base::ThreadRestrictions::AssertIOAllowed(); |
29 return (copyfile(from_path.value().c_str(), | 31 return (copyfile(from_path.value().c_str(), |
30 to_path.value().c_str(), NULL, COPYFILE_ALL) == 0); | 32 to_path.value().c_str(), NULL, COPYFILE_ALL) == 0); |
31 } | 33 } |
32 | 34 |
33 } // namespace | 35 } // namespace |
OLD | NEW |