|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 #ifndef BASE_PLATFORM_FILE_H_ |
|
6 #define BASE_PLATFORM_FILE_H_ |
|
7 |
|
8 #include "build/build_config.h" |
|
9 #if defined(OS_WIN) |
|
10 #include <windows.h> |
|
11 #endif |
|
12 |
|
13 #include <string> |
|
14 |
|
15 namespace base { |
|
16 |
|
17 #if defined(OS_WIN) |
|
18 typedef HANDLE PlatformFile; |
|
19 const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; |
|
20 #elif defined(OS_POSIX) |
|
21 typedef int PlatformFile; |
|
22 const PlatformFile kInvalidPlatformFileValue = -1; |
|
23 #endif |
|
24 |
|
25 enum PlatformFileFlags { |
|
26 PLATFORM_FILE_OPEN = 1, |
|
27 PLATFORM_FILE_CREATE = 2, |
|
28 PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file. |
|
29 PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file. |
|
30 PLATFORM_FILE_READ = 16, |
|
31 PLATFORM_FILE_WRITE = 32, |
|
32 PLATFORM_FILE_EXCLUSIVE_READ = 64, // EXCLUSIVE is opposite of Windows SHARE |
|
33 PLATFORM_FILE_EXCLUSIVE_WRITE = 128, |
|
34 PLATFORM_FILE_ASYNC = 256 |
|
35 }; |
|
36 |
|
37 // Creates or open the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and |
|
38 // |created| is provided, |created| will be set to true if the file was created |
|
39 // or to false in case the file was just opened. |
|
40 PlatformFile CreatePlatformFile(const std::wstring& name, |
|
41 int flags, |
|
42 bool* created); |
|
43 |
|
44 } // namespace base |
|
45 |
|
46 #endif // BASE_PLATFORM_FILE_H_ |