1// Copyright 2017 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_FILES_PLATFORM_FILE_H_ 6#define BASE_FILES_PLATFORM_FILE_H_ 7 8#include "base/files/scoped_file.h" 9#include "util/build_config.h" 10 11#if defined(OS_WIN) 12#include <windows.h> 13#include "base/win/scoped_handle.h" 14#endif 15 16// This file defines platform-independent types for dealing with 17// platform-dependent files. If possible, use the higher-level base::File class 18// rather than these primitives. 19 20namespace base { 21 22#if defined(OS_WIN) 23 24using PlatformFile = HANDLE; 25using ScopedPlatformFile = ::base::win::ScopedHandle; 26 27// It would be nice to make this constexpr but INVALID_HANDLE_VALUE is a 28// ((void*)(-1)) which Clang rejects since reinterpret_cast is technically 29// disallowed in constexpr. Visual Studio accepts this, however. 30const PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE; 31 32#elif defined(OS_POSIX) || defined(OS_FUCHSIA) 33 34using PlatformFile = int; 35using ScopedPlatformFile = ::base::ScopedFD; 36 37constexpr PlatformFile kInvalidPlatformFile = -1; 38 39#endif 40 41} // namespace base 42 43#endif // BASE_FILES_PLATFORM_FILE_H_ 44