diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 18:36:33 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 18:36:33 +0000 |
commit | f36a813bcc5c1d7e86375e761e592cd1959117f8 (patch) | |
tree | ddb121d1b4fc035474abaab07c981cda822a8594 /base/file_util.h | |
parent | bfe3b9e2ec11565e3a1d90133d1a49d1fef1b817 (diff) | |
download | chromium_src-f36a813bcc5c1d7e86375e761e592cd1959117f8.zip chromium_src-f36a813bcc5c1d7e86375e761e592cd1959117f8.tar.gz chromium_src-f36a813bcc5c1d7e86375e761e592cd1959117f8.tar.bz2 |
Move test utilities into test_file_util.*.
Split from CL 7134019.
brettw: base.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7740081
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99416 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.h')
-rw-r--r-- | base/file_util.h | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/base/file_util.h b/base/file_util.h index cd7fa9f..1010b63 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -13,9 +13,6 @@ #if defined(OS_WIN) #include <windows.h> -#if defined(UNIT_TEST) -#include <aclapi.h> -#endif #elif defined(OS_POSIX) #include <sys/stat.h> #include <unistd.h> @@ -577,58 +574,6 @@ BASE_EXPORT bool HasFileBeenModifiedSince( const FileEnumerator::FindInfo& find_info, const base::Time& cutoff_time); -#ifdef UNIT_TEST - -inline bool MakeFileUnreadable(const FilePath& path) { -#if defined(OS_POSIX) - struct stat stat_buf; - if (stat(path.value().c_str(), &stat_buf) != 0) - return false; - stat_buf.st_mode &= ~(S_IRUSR | S_IRGRP | S_IROTH); - - return chmod(path.value().c_str(), stat_buf.st_mode) == 0; - -#elif defined(OS_WIN) - PACL old_dacl; - PSECURITY_DESCRIPTOR security_descriptor; - if (GetNamedSecurityInfo(const_cast<wchar_t*>(path.value().c_str()), - SE_FILE_OBJECT, - DACL_SECURITY_INFORMATION, NULL, NULL, &old_dacl, - NULL, &security_descriptor) != ERROR_SUCCESS) - return false; - - // Deny Read access for the current user. - EXPLICIT_ACCESS change; - change.grfAccessPermissions = GENERIC_READ; - change.grfAccessMode = DENY_ACCESS; - change.grfInheritance = 0; - change.Trustee.pMultipleTrustee = NULL; - change.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; - change.Trustee.TrusteeForm = TRUSTEE_IS_NAME; - change.Trustee.TrusteeType = TRUSTEE_IS_USER; - change.Trustee.ptstrName = L"CURRENT_USER"; - - PACL new_dacl; - if (SetEntriesInAcl(1, &change, old_dacl, &new_dacl) != ERROR_SUCCESS) { - LocalFree(security_descriptor); - return false; - } - - DWORD rc = SetNamedSecurityInfo(const_cast<wchar_t*>(path.value().c_str()), - SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, - NULL, NULL, new_dacl, NULL); - LocalFree(security_descriptor); - LocalFree(new_dacl); - - return rc == ERROR_SUCCESS; -#else - NOTIMPLEMENTED(); - return false; -#endif -} - -#endif // UNIT_TEST - #if defined(OS_WIN) // Loads the file passed in as an image section and touches pages to avoid // subsequent hard page faults during LoadLibrary. The size to be pre read |