OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/test/test_file_util.h" | 5 #include "base/test/test_file_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 #if !defined(OS_LINUX) && !defined(OS_MACOSX) | 83 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
84 bool EvictFileFromSystemCache(const base::FilePath& file) { | 84 bool EvictFileFromSystemCache(const base::FilePath& file) { |
85 // There doesn't seem to be a POSIX way to cool the disk cache. | 85 // There doesn't seem to be a POSIX way to cool the disk cache. |
86 NOTIMPLEMENTED(); | 86 NOTIMPLEMENTED(); |
87 return false; | 87 return false; |
88 } | 88 } |
89 #endif | 89 #endif |
90 | 90 |
91 std::wstring FilePathAsWString(const base::FilePath& path) { | 91 std::wstring FilePathAsWString(const base::FilePath& path) { |
92 return UTF8ToWide(path.value()); | 92 return base::UTF8ToWide(path.value()); |
93 } | 93 } |
94 base::FilePath WStringAsFilePath(const std::wstring& path) { | 94 base::FilePath WStringAsFilePath(const std::wstring& path) { |
95 return base::FilePath(WideToUTF8(path)); | 95 return base::FilePath(base::WideToUTF8(path)); |
96 } | 96 } |
97 | 97 |
98 bool MakeFileUnreadable(const base::FilePath& path) { | 98 bool MakeFileUnreadable(const base::FilePath& path) { |
99 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); | 99 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); |
100 } | 100 } |
101 | 101 |
102 bool MakeFileUnwritable(const base::FilePath& path) { | 102 bool MakeFileUnwritable(const base::FilePath& path) { |
103 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); | 103 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); |
104 } | 104 } |
105 | 105 |
106 PermissionRestorer::PermissionRestorer(const base::FilePath& path) | 106 PermissionRestorer::PermissionRestorer(const base::FilePath& path) |
107 : path_(path), info_(NULL), length_(0) { | 107 : path_(path), info_(NULL), length_(0) { |
108 info_ = GetPermissionInfo(path_, &length_); | 108 info_ = GetPermissionInfo(path_, &length_); |
109 DCHECK(info_ != NULL); | 109 DCHECK(info_ != NULL); |
110 DCHECK_NE(0u, length_); | 110 DCHECK_NE(0u, length_); |
111 } | 111 } |
112 | 112 |
113 PermissionRestorer::~PermissionRestorer() { | 113 PermissionRestorer::~PermissionRestorer() { |
114 if (!RestorePermissionInfo(path_, info_, length_)) | 114 if (!RestorePermissionInfo(path_, info_, length_)) |
115 NOTREACHED(); | 115 NOTREACHED(); |
116 } | 116 } |
117 | 117 |
118 } // namespace file_util | 118 } // namespace file_util |
OLD | NEW |