blob: 7f81e8aeaaf11d117df92c60317336aa7e20f5ad [file] [log] [blame]
[email protected]49df6022008-08-27 19:03:431// 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]5af2edb92008-08-08 20:16:084
5#include "base/file_util.h"
6
7#import <Cocoa/Cocoa.h>
8#include <copyfile.h>
9
[email protected]640517f2008-10-30 23:54:0410#include "base/file_path.h"
[email protected]5af2edb92008-08-08 20:16:0811#include "base/logging.h"
12#include "base/string_util.h"
13
14namespace file_util {
15
[email protected]640517f2008-10-30 23:54:0416bool GetTempDir(FilePath* path) {
[email protected]5af2edb92008-08-08 20:16:0817 NSString* tmp = NSTemporaryDirectory();
18 if (tmp == nil)
19 return false;
[email protected]640517f2008-10-30 23:54:0420 *path = FilePath([tmp fileSystemRepresentation]);
[email protected]5af2edb92008-08-08 20:16:0821 return true;
22}
[email protected]49df6022008-08-27 19:03:4323
[email protected]9e51af92009-02-04 00:58:3924bool GetShmemTempDir(FilePath* path) {
25 return GetTempDir(path);
26}
27
[email protected]640517f2008-10-30 23:54:0428bool 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]49df6022008-08-27 19:03:4331}
32
[email protected]5af2edb92008-08-08 20:16:0833} // namespace