| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace base { | 21 namespace base { |
| 22 | 22 |
| 23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 24 typedef HANDLE PlatformFile; | 24 typedef HANDLE PlatformFile; |
| 25 const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; | 25 const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; |
| 26 #elif defined(OS_POSIX) | 26 #elif defined(OS_POSIX) |
| 27 typedef int PlatformFile; | 27 typedef int PlatformFile; |
| 28 const PlatformFile kInvalidPlatformFileValue = -1; | 28 const PlatformFile kInvalidPlatformFileValue = -1; |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 // PLATFORM_FILE_(OPEN|CREATE).* are mutually exclusive. You should specify |
| 32 // exactly one of the five (possibly combining with other flags) when openning |
| 33 // or creating a file. |
| 31 enum PlatformFileFlags { | 34 enum PlatformFileFlags { |
| 32 PLATFORM_FILE_OPEN = 1, | 35 PLATFORM_FILE_OPEN = 1, // Opens a file, only if it exists. |
| 33 PLATFORM_FILE_CREATE = 2, | 36 PLATFORM_FILE_CREATE = 2, // Creates a new file, only if it does not |
| 34 PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file. | 37 // already exist. |
| 35 PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file. | 38 PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file. |
| 36 PLATFORM_FILE_READ = 16, | 39 PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file. |
| 37 PLATFORM_FILE_WRITE = 32, | 40 PLATFORM_FILE_OPEN_TRUNCATED = 16, // Opens a file and truncates it, only if |
| 38 PLATFORM_FILE_EXCLUSIVE_READ = 64, // EXCLUSIVE is opposite of Windows SHARE | 41 // it exists. |
| 39 PLATFORM_FILE_EXCLUSIVE_WRITE = 128, | 42 PLATFORM_FILE_READ = 32, |
| 40 PLATFORM_FILE_ASYNC = 256, | 43 PLATFORM_FILE_WRITE = 64, |
| 41 PLATFORM_FILE_TEMPORARY = 512, // Used on Windows only | 44 PLATFORM_FILE_EXCLUSIVE_READ = 128, // EXCLUSIVE is opposite of Windows SHARE |
| 42 PLATFORM_FILE_HIDDEN = 1024, // Used on Windows only | 45 PLATFORM_FILE_EXCLUSIVE_WRITE = 256, |
| 43 PLATFORM_FILE_DELETE_ON_CLOSE = 2048, | 46 PLATFORM_FILE_ASYNC = 512, |
| 44 PLATFORM_FILE_TRUNCATE = 4096, | 47 PLATFORM_FILE_TEMPORARY = 1024, // Used on Windows only |
| 48 PLATFORM_FILE_HIDDEN = 2048, // Used on Windows only |
| 49 PLATFORM_FILE_DELETE_ON_CLOSE = 4096, |
| 50 |
| 45 PLATFORM_FILE_WRITE_ATTRIBUTES = 8192, // Used on Windows only | 51 PLATFORM_FILE_WRITE_ATTRIBUTES = 8192, // Used on Windows only |
| 46 PLATFORM_FILE_ENUMERATE = 16384, // May enumerate directory | 52 PLATFORM_FILE_ENUMERATE = 16384, // May enumerate directory |
| 47 }; | 53 }; |
| 48 | 54 |
| 49 // PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of | 55 // PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of |
| 50 // a filesystem restriction. PLATFORM_FILE_ERROR_SECURITY is returned when a | 56 // a filesystem restriction. PLATFORM_FILE_ERROR_SECURITY is returned when a |
| 51 // browser policy doesn't allow the operation to be executed. | 57 // browser policy doesn't allow the operation to be executed. |
| 52 enum PlatformFileError { | 58 enum PlatformFileError { |
| 53 PLATFORM_FILE_OK = 0, | 59 PLATFORM_FILE_OK = 0, |
| 54 PLATFORM_FILE_ERROR_FAILED = -1, | 60 PLATFORM_FILE_ERROR_FAILED = -1, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return temp; | 174 return temp; |
| 169 } | 175 } |
| 170 | 176 |
| 171 private: | 177 private: |
| 172 PlatformFile* value_; | 178 PlatformFile* value_; |
| 173 }; | 179 }; |
| 174 | 180 |
| 175 } // namespace base | 181 } // namespace base |
| 176 | 182 |
| 177 #endif // BASE_PLATFORM_FILE_H_ | 183 #endif // BASE_PLATFORM_FILE_H_ |
| OLD | NEW |