michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_PLATFORM_FILE_H_ michael@0: #define BASE_PLATFORM_FILE_H_ michael@0: michael@0: #include "build/build_config.h" michael@0: #if defined(OS_WIN) michael@0: #include michael@0: #endif michael@0: michael@0: #include michael@0: michael@0: namespace base { michael@0: michael@0: #if defined(OS_WIN) michael@0: typedef HANDLE PlatformFile; michael@0: const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; michael@0: #elif defined(OS_POSIX) michael@0: typedef int PlatformFile; michael@0: const PlatformFile kInvalidPlatformFileValue = -1; michael@0: #endif michael@0: michael@0: enum PlatformFileFlags { michael@0: PLATFORM_FILE_OPEN = 1, michael@0: PLATFORM_FILE_CREATE = 2, michael@0: PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file. michael@0: PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file. michael@0: PLATFORM_FILE_READ = 16, michael@0: PLATFORM_FILE_WRITE = 32, michael@0: PLATFORM_FILE_EXCLUSIVE_READ = 64, // EXCLUSIVE is opposite of Windows SHARE michael@0: PLATFORM_FILE_EXCLUSIVE_WRITE = 128, michael@0: PLATFORM_FILE_ASYNC = 256 michael@0: }; michael@0: michael@0: // Creates or open the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and michael@0: // |created| is provided, |created| will be set to true if the file was created michael@0: // or to false in case the file was just opened. michael@0: PlatformFile CreatePlatformFile(const std::wstring& name, michael@0: int flags, michael@0: bool* created); michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_PLATFORM_FILE_H_