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 #ifndef BASE_TEST_TEST_FILE_UTIL_H_ | 5 #ifndef BASE_TEST_TEST_FILE_UTIL_H_ |
6 #define BASE_TEST_TEST_FILE_UTIL_H_ | 6 #define BASE_TEST_TEST_FILE_UTIL_H_ |
7 | 7 |
8 // File utility functions used only by tests. | 8 // File utility functions used only by tests. |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/file_util.h" |
14 | 15 |
15 class FilePath; | 16 class FilePath; |
16 | 17 |
17 namespace file_util { | 18 namespace file_util { |
18 | 19 |
| 20 #if defined(OS_WIN) |
| 21 enum VerifyShortcutStatus { |
| 22 VERIFY_SHORTCUT_SUCCESS = 0, |
| 23 VERIFY_SHORTCUT_FAILURE_UNEXPECTED, |
| 24 VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, |
| 25 VERIFY_SHORTCUT_FAILURE_TARGET, |
| 26 VERIFY_SHORTCUT_FAILURE_WORKING_DIR, |
| 27 VERIFY_SHORTCUT_FAILURE_ARGUMENTS, |
| 28 VERIFY_SHORTCUT_FAILURE_DESCRIPTION, |
| 29 VERIFY_SHORTCUT_FAILURE_ICON, |
| 30 VERIFY_SHORTCUT_FAILURE_APP_ID, |
| 31 VERIFY_SHORTCUT_FAILURE_DUAL_MODE, |
| 32 }; |
| 33 #endif // defined(OS_WIN) |
| 34 |
19 // Wrapper over file_util::Delete. On Windows repeatedly invokes Delete in case | 35 // Wrapper over file_util::Delete. On Windows repeatedly invokes Delete in case |
20 // of failure to workaround Windows file locking semantics. Returns true on | 36 // of failure to workaround Windows file locking semantics. Returns true on |
21 // success. | 37 // success. |
22 bool DieFileDie(const FilePath& file, bool recurse); | 38 bool DieFileDie(const FilePath& file, bool recurse); |
23 | 39 |
24 // Clear a specific file from the system cache. After this call, trying | 40 // Clear a specific file from the system cache. After this call, trying |
25 // to access this file will result in a cold load from the hard drive. | 41 // to access this file will result in a cold load from the hard drive. |
26 bool EvictFileFromSystemCache(const FilePath& file); | 42 bool EvictFileFromSystemCache(const FilePath& file); |
27 | 43 |
28 // Like CopyFileNoCache but recursively copies all files and subdirectories | 44 // Like CopyFileNoCache but recursively copies all files and subdirectories |
29 // in the given input directory to the output directory. Any files in the | 45 // in the given input directory to the output directory. Any files in the |
30 // destination that already exist will be overwritten. | 46 // destination that already exist will be overwritten. |
31 // | 47 // |
32 // Returns true on success. False means there was some error copying, so the | 48 // Returns true on success. False means there was some error copying, so the |
33 // state of the destination is unknown. | 49 // state of the destination is unknown. |
34 bool CopyRecursiveDirNoCache(const FilePath& source_dir, | 50 bool CopyRecursiveDirNoCache(const FilePath& source_dir, |
35 const FilePath& dest_dir); | 51 const FilePath& dest_dir); |
36 | 52 |
37 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 54 // Verify that a shortcut exists at |shortcut_path| with the expected |
| 55 // |properties|. |
| 56 VerifyShortcutStatus VerifyShortcut(const string16& shortcut_path, |
| 57 const ShortcutProperties& properties); |
| 58 |
38 // Returns true if the volume supports Alternate Data Streams. | 59 // Returns true if the volume supports Alternate Data Streams. |
39 bool VolumeSupportsADS(const FilePath& path); | 60 bool VolumeSupportsADS(const FilePath& path); |
40 | 61 |
41 // Returns true if the ZoneIdentifier is correctly set to "Internet" (3). | 62 // Returns true if the ZoneIdentifier is correctly set to "Internet" (3). |
42 // Note that this function must be called from the same process as | 63 // Note that this function must be called from the same process as |
43 // the one that set the zone identifier. I.e. don't use it in UI/automation | 64 // the one that set the zone identifier. I.e. don't use it in UI/automation |
44 // based tests. | 65 // based tests. |
45 bool HasInternetZoneIdentifier(const FilePath& full_path); | 66 bool HasInternetZoneIdentifier(const FilePath& full_path); |
46 #endif // defined(OS_WIN) | 67 #endif // defined(OS_WIN) |
47 | 68 |
(...skipping 18 matching lines...) Expand all Loading... |
66 const FilePath path_; | 87 const FilePath path_; |
67 void* info_; // The opaque stored permission information. | 88 void* info_; // The opaque stored permission information. |
68 size_t length_; // The length of the stored permission information. | 89 size_t length_; // The length of the stored permission information. |
69 | 90 |
70 DISALLOW_COPY_AND_ASSIGN(PermissionRestorer); | 91 DISALLOW_COPY_AND_ASSIGN(PermissionRestorer); |
71 }; | 92 }; |
72 | 93 |
73 } // namespace file_util | 94 } // namespace file_util |
74 | 95 |
75 #endif // BASE_TEST_TEST_FILE_UTIL_H_ | 96 #endif // BASE_TEST_TEST_FILE_UTIL_H_ |
OLD | NEW |