[email protected] | 49df602 | 2008-08-27 19:03:43 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 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. | ||||
[email protected] | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 4 | |
5 | #include "base/file_util.h" | ||||
6 | |||||
7 | #import <Cocoa/Cocoa.h> | ||||
8 | #include <copyfile.h> | ||||
9 | |||||
[email protected] | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 10 | #include "base/file_path.h" |
[email protected] | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 11 | #include "base/logging.h" |
12 | #include "base/string_util.h" | ||||
13 | |||||
14 | namespace file_util { | ||||
15 | |||||
[email protected] | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 16 | bool GetTempDir(FilePath* path) { |
[email protected] | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 17 | NSString* tmp = NSTemporaryDirectory(); |
18 | if (tmp == nil) | ||||
19 | return false; | ||||
[email protected] | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 20 | *path = FilePath([tmp fileSystemRepresentation]); |
[email protected] | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 21 | return true; |
22 | } | ||||
[email protected] | 49df602 | 2008-08-27 19:03:43 | [diff] [blame] | 23 | |
[email protected] | 9e51af9 | 2009-02-04 00:58:39 | [diff] [blame] | 24 | bool GetShmemTempDir(FilePath* path) { |
25 | return GetTempDir(path); | ||||
26 | } | ||||
27 | |||||
[email protected] | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 28 | bool CopyFile(const FilePath& from_path, const FilePath& to_path) { |
29 | return (copyfile(from_path.value().c_str(), | ||||
30 | to_path.value().c_str(), NULL, COPYFILE_ALL) == 0); | ||||
[email protected] | 49df602 | 2008-08-27 19:03:43 | [diff] [blame] | 31 | } |
32 | |||||
[email protected] | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 33 | } // namespace |