| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Creates a reparse point from |source| (an empty directory) to |target|. | 132 // Creates a reparse point from |source| (an empty directory) to |target|. |
| 133 ReparsePoint(const FilePath& source, const FilePath& target) { | 133 ReparsePoint(const FilePath& source, const FilePath& target) { |
| 134 dir_.Set( | 134 dir_.Set( |
| 135 ::CreateFile(source.value().c_str(), | 135 ::CreateFile(source.value().c_str(), |
| 136 FILE_ALL_ACCESS, | 136 FILE_ALL_ACCESS, |
| 137 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 137 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
| 138 NULL, | 138 NULL, |
| 139 OPEN_EXISTING, | 139 OPEN_EXISTING, |
| 140 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. | 140 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. |
| 141 NULL)); | 141 NULL)); |
| 142 created_ = dir_.IsValid() && SetReparsePoint(dir_, target); | 142 created_ = dir_.IsValid() && SetReparsePoint(dir_.Get(), target); |
| 143 } | 143 } |
| 144 | 144 |
| 145 ~ReparsePoint() { | 145 ~ReparsePoint() { |
| 146 if (created_) | 146 if (created_) |
| 147 DeleteReparsePoint(dir_); | 147 DeleteReparsePoint(dir_.Get()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool IsValid() { return created_; } | 150 bool IsValid() { return created_; } |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 win::ScopedHandle dir_; | 153 win::ScopedHandle dir_; |
| 154 bool created_; | 154 bool created_; |
| 155 DISALLOW_COPY_AND_ASSIGN(ReparsePoint); | 155 DISALLOW_COPY_AND_ASSIGN(ReparsePoint); |
| 156 }; | 156 }; |
| 157 | 157 |
| (...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2587 // Trying to close it should crash. This is important for security. | 2587 // Trying to close it should crash. This is important for security. |
| 2588 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2588 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
| 2589 #endif | 2589 #endif |
| 2590 } | 2590 } |
| 2591 | 2591 |
| 2592 #endif // defined(OS_POSIX) | 2592 #endif // defined(OS_POSIX) |
| 2593 | 2593 |
| 2594 } // namespace | 2594 } // namespace |
| 2595 | 2595 |
| 2596 } // namespace base | 2596 } // namespace base |
| OLD | NEW |