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 <windows.h> | 7 #include <windows.h> |
8 #include <aclapi.h> | 8 #include <aclapi.h> |
9 #include <shlwapi.h> | 9 #include <shlwapi.h> |
10 | 10 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (lines[2] != "") | 252 if (lines[2] != "") |
253 return false; | 253 return false; |
254 // fall through: | 254 // fall through: |
255 case 2: | 255 case 2: |
256 return lines[0] == "[ZoneTransfer]" && lines[1] == "ZoneId=3"; | 256 return lines[0] == "[ZoneTransfer]" && lines[1] == "ZoneId=3"; |
257 default: | 257 default: |
258 return false; | 258 return false; |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 } // namespace base | 262 bool MakeFileUnreadable(const FilePath& path) { |
263 | |
264 namespace file_util { | |
265 | |
266 using base::DenyFilePermission; | |
267 using base::GetPermissionInfo; | |
268 using base::RestorePermissionInfo; | |
269 | |
270 bool MakeFileUnreadable(const base::FilePath& path) { | |
271 return DenyFilePermission(path, GENERIC_READ); | 263 return DenyFilePermission(path, GENERIC_READ); |
272 } | 264 } |
273 | 265 |
274 bool MakeFileUnwritable(const base::FilePath& path) { | 266 bool MakeFileUnwritable(const FilePath& path) { |
275 return DenyFilePermission(path, GENERIC_WRITE); | 267 return DenyFilePermission(path, GENERIC_WRITE); |
276 } | 268 } |
277 | 269 |
278 PermissionRestorer::PermissionRestorer(const base::FilePath& path) | 270 FilePermissionRestorer::FilePermissionRestorer(const FilePath& path) |
279 : path_(path), info_(NULL), length_(0) { | 271 : path_(path), info_(NULL), length_(0) { |
280 info_ = GetPermissionInfo(path_, &length_); | 272 info_ = GetPermissionInfo(path_, &length_); |
281 DCHECK(info_ != NULL); | 273 DCHECK(info_ != NULL); |
282 DCHECK_NE(0u, length_); | 274 DCHECK_NE(0u, length_); |
283 } | 275 } |
284 | 276 |
285 PermissionRestorer::~PermissionRestorer() { | 277 FilePermissionRestorer::~FilePermissionRestorer() { |
286 if (!RestorePermissionInfo(path_, info_, length_)) | 278 if (!RestorePermissionInfo(path_, info_, length_)) |
287 NOTREACHED(); | 279 NOTREACHED(); |
288 } | 280 } |
289 | 281 |
290 } // namespace file_util | 282 } // namespace base |
OLD | NEW |