Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 } | 78 } |
| 79 | 79 |
| 80 #if !defined(OS_LINUX) && !defined(OS_MACOSX) | 80 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
| 81 bool EvictFileFromSystemCache(const FilePath& file) { | 81 bool EvictFileFromSystemCache(const FilePath& file) { |
| 82 // There doesn't seem to be a POSIX way to cool the disk cache. | 82 // There doesn't seem to be a POSIX way to cool the disk cache. |
| 83 NOTIMPLEMENTED(); | 83 NOTIMPLEMENTED(); |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 bool MakeFileUnreadable(const FilePath& path) { | |
| 89 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); | |
| 90 } | |
| 91 | |
| 92 bool MakeFileUnwritable(const FilePath& path) { | |
| 93 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); | |
| 94 } | |
| 95 | |
| 88 } // namespace base | 96 } // namespace base |
| 89 | 97 |
| 90 namespace file_util { | 98 namespace file_util { |
| 91 | 99 |
| 92 using base::DenyFilePermission; | 100 using base::DenyFilePermission; |
| 93 using base::GetPermissionInfo; | 101 using base::GetPermissionInfo; |
| 94 using base::RestorePermissionInfo; | 102 using base::RestorePermissionInfo; |
| 95 | 103 |
| 96 bool MakeFileUnreadable(const base::FilePath& path) { | |
| 97 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); | |
| 98 } | |
| 99 | |
| 100 bool MakeFileUnwritable(const base::FilePath& path) { | |
| 101 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); | |
| 102 } | |
| 103 | |
| 104 PermissionRestorer::PermissionRestorer(const base::FilePath& path) | 104 PermissionRestorer::PermissionRestorer(const base::FilePath& path) |
|
rvargas (doing something else)
2014/08/06 23:21:49
base::FilePermissionRestorer
| |
| 105 : path_(path), info_(NULL), length_(0) { | 105 : path_(path), info_(NULL), length_(0) { |
| 106 info_ = GetPermissionInfo(path_, &length_); | 106 info_ = GetPermissionInfo(path_, &length_); |
| 107 DCHECK(info_ != NULL); | 107 DCHECK(info_ != NULL); |
| 108 DCHECK_NE(0u, length_); | 108 DCHECK_NE(0u, length_); |
| 109 } | 109 } |
| 110 | 110 |
| 111 PermissionRestorer::~PermissionRestorer() { | 111 PermissionRestorer::~PermissionRestorer() { |
| 112 if (!RestorePermissionInfo(path_, info_, length_)) | 112 if (!RestorePermissionInfo(path_, info_, length_)) |
| 113 NOTREACHED(); | 113 NOTREACHED(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace file_util | 116 } // namespace file_util |
| OLD | NEW |