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 <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 bool DieFileDie(const FilePath& file, bool recurse) { | 76 bool DieFileDie(const FilePath& file, bool recurse) { |
77 // There is no need to workaround Windows problems on POSIX. | 77 // There is no need to workaround Windows problems on POSIX. |
78 // Just pass-through. | 78 // Just pass-through. |
79 return DeleteFile(file, recurse); | 79 return DeleteFile(file, recurse); |
80 } | 80 } |
81 | 81 |
82 #if !defined(OS_LINUX) && !defined(OS_MACOSX) | 82 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
83 bool EvictFileFromSystemCache(const FilePath& file) { | 83 bool EvictFileFromSystemCache(const FilePath& file) { |
84 // There doesn't seem to be a POSIX way to cool the disk cache. | 84 // There doesn't seem to be a POSIX way to cool the disk cache. |
85 NOTIMPLEMENTED(); | 85 NOTIMPLEMENTED(); |
86 return false; | 86 return false; |
87 } | 87 } |
88 #endif | 88 #endif |
89 | 89 |
90 bool MakeFileUnreadable(const FilePath& path) { | 90 bool MakeFileUnreadable(const FilePath& path) { |
91 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); | 91 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); |
92 } | 92 } |
93 | 93 |
94 bool MakeFileUnwritable(const FilePath& path) { | 94 bool MakeFileUnwritable(const FilePath& path) { |
95 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); | 95 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); |
96 } | 96 } |
97 | 97 |
98 FilePermissionRestorer::FilePermissionRestorer(const FilePath& path) | 98 FilePermissionRestorer::FilePermissionRestorer(const FilePath& path) |
99 : path_(path), info_(NULL), length_(0) { | 99 : path_(path), info_(NULL), length_(0) { |
100 info_ = GetPermissionInfo(path_, &length_); | 100 info_ = GetPermissionInfo(path_, &length_); |
101 DCHECK(info_ != NULL); | 101 DCHECK(info_ != NULL); |
102 DCHECK_NE(0u, length_); | 102 DCHECK_NE(0u, length_); |
103 } | 103 } |
104 | 104 |
105 FilePermissionRestorer::~FilePermissionRestorer() { | 105 FilePermissionRestorer::~FilePermissionRestorer() { |
106 if (!RestorePermissionInfo(path_, info_, length_)) | 106 if (!RestorePermissionInfo(path_, info_, length_)) |
107 NOTREACHED(); | 107 NOTREACHED(); |
108 } | 108 } |
109 | 109 |
110 } // namespace base | 110 } // namespace base |
OLD | NEW |