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_PLATFORM_FILE_H_ | 5 #ifndef BASE_PLATFORM_FILE_H_ |
6 #define BASE_PLATFORM_FILE_H_ | 6 #define BASE_PLATFORM_FILE_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/base_export.h" | 15 #include "base/base_export.h" |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 // PLATFORM_FILE_(OPEN|CREATE).* are mutually exclusive. You should specify | 22 // PLATFORM_FILE_(OPEN|CREATE).* are mutually exclusive. You should specify |
jar (doing other things)
2013/06/04 23:31:50
nit: you probably need an analogous comment about
| |
23 // exactly one of the five (possibly combining with other flags) when opening | 23 // exactly one of the five (possibly combining with other flags) when opening |
24 // or creating a file. | 24 // or creating a file. |
25 enum PlatformFileFlags { | 25 enum PlatformFileFlags { |
26 PLATFORM_FILE_OPEN = 1 << 0, // Opens a file, only if it exists. | 26 PLATFORM_FILE_OPEN = 1 << 0, // Opens a file, only if it exists. |
27 PLATFORM_FILE_CREATE = 1 << 1, // Creates a new file, only if it | 27 PLATFORM_FILE_CREATE = 1 << 1, // Creates a new file, only if it |
28 // does not already exist. | 28 // does not already exist. |
29 PLATFORM_FILE_OPEN_ALWAYS = 1 << 2, // May create a new file. | 29 PLATFORM_FILE_OPEN_ALWAYS = 1 << 2, // May create a new file. |
30 PLATFORM_FILE_CREATE_ALWAYS = 1 << 3, // May overwrite an old file. | 30 PLATFORM_FILE_CREATE_ALWAYS = 1 << 3, // May overwrite an old file. |
31 PLATFORM_FILE_OPEN_TRUNCATED = 1 << 4, // Opens a file and truncates it, | 31 PLATFORM_FILE_OPEN_TRUNCATED = 1 << 4, // Opens a file and truncates it, |
32 // only if it exists. | 32 // only if it exists. |
33 PLATFORM_FILE_READ = 1 << 5, | 33 PLATFORM_FILE_READ = 1 << 5, |
34 PLATFORM_FILE_WRITE = 1 << 6, | 34 PLATFORM_FILE_WRITE = 1 << 6, |
35 PLATFORM_FILE_EXCLUSIVE_READ = 1 << 7, // EXCLUSIVE is opposite of Windows | 35 PLATFORM_FILE_EXCLUSIVE_READ = 1 << 7, // EXCLUSIVE is opposite of Windows |
36 // SHARE | 36 // SHARE |
37 PLATFORM_FILE_EXCLUSIVE_WRITE = 1 << 8, | 37 PLATFORM_FILE_EXCLUSIVE_WRITE = 1 << 8, |
38 PLATFORM_FILE_ASYNC = 1 << 9, | 38 PLATFORM_FILE_ASYNC = 1 << 9, |
39 PLATFORM_FILE_TEMPORARY = 1 << 10, // Used on Windows only | 39 PLATFORM_FILE_TEMPORARY = 1 << 10, // Used on Windows only |
40 PLATFORM_FILE_HIDDEN = 1 << 11, // Used on Windows only | 40 PLATFORM_FILE_HIDDEN = 1 << 11, // Used on Windows only |
41 PLATFORM_FILE_DELETE_ON_CLOSE = 1 << 12, | 41 PLATFORM_FILE_DELETE_ON_CLOSE = 1 << 12, |
42 | 42 |
43 PLATFORM_FILE_WRITE_ATTRIBUTES = 1 << 13, // Used on Windows only | 43 PLATFORM_FILE_WRITE_ATTRIBUTES = 1 << 13, // Used on Windows only |
44 PLATFORM_FILE_ENUMERATE = 1 << 14, // May enumerate directory | 44 PLATFORM_FILE_ENUMERATE = 1 << 14, // May enumerate directory |
45 | 45 |
46 PLATFORM_FILE_SHARE_DELETE = 1 << 15, // Used on Windows only | 46 PLATFORM_FILE_SHARE_DELETE = 1 << 15, // Used on Windows only |
47 | 47 |
48 PLATFORM_FILE_TERMINAL_DEVICE = 1 << 16, // Serial port flags | 48 PLATFORM_FILE_TERMINAL_DEVICE = 1 << 16, // Serial port flags |
49 PLATFORM_FILE_BACKUP_SEMANTICS = 1 << 17, // Used on Windows only | 49 PLATFORM_FILE_BACKUP_SEMANTICS = 1 << 17, // Used on Windows only |
50 | 50 |
51 PLATFORM_FILE_EXECUTE = 1 << 18, // Used on Windows only | 51 PLATFORM_FILE_EXECUTE = 1 << 18, // Used on Windows only |
52 | |
53 PLATFORM_FILE_APPEND = 1 << 19, | |
jar (doing other things)
2013/06/04 23:31:50
nit: You *might* want to re-order these, so that W
| |
52 }; | 54 }; |
53 | 55 |
54 // PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of | 56 // PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of |
55 // a filesystem restriction. PLATFORM_FILE_ERROR_SECURITY is returned when a | 57 // a filesystem restriction. PLATFORM_FILE_ERROR_SECURITY is returned when a |
56 // browser policy doesn't allow the operation to be executed. | 58 // browser policy doesn't allow the operation to be executed. |
57 enum PlatformFileError { | 59 enum PlatformFileError { |
58 PLATFORM_FILE_OK = 0, | 60 PLATFORM_FILE_OK = 0, |
59 PLATFORM_FILE_ERROR_FAILED = -1, | 61 PLATFORM_FILE_ERROR_FAILED = -1, |
60 PLATFORM_FILE_ERROR_IN_USE = -2, | 62 PLATFORM_FILE_ERROR_IN_USE = -2, |
61 PLATFORM_FILE_ERROR_EXISTS = -3, | 63 PLATFORM_FILE_ERROR_EXISTS = -3, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 return temp; | 242 return temp; |
241 } | 243 } |
242 | 244 |
243 private: | 245 private: |
244 PlatformFile* value_; | 246 PlatformFile* value_; |
245 }; | 247 }; |
246 | 248 |
247 } // namespace base | 249 } // namespace base |
248 | 250 |
249 #endif // BASE_PLATFORM_FILE_H_ | 251 #endif // BASE_PLATFORM_FILE_H_ |
OLD | NEW |