Home | History | Annotate | Download | only in files
      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 "build/build_config.h"
     10 
     11 #if defined(OS_WIN)
     12 #include "base/win/scoped_handle.h"
     13 #include "base/win/windows_types.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 
     20 namespace base {
     21 
     22 #if defined(OS_WIN)
     23 
     24 using PlatformFile = HANDLE;
     25 using 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.
     30 const PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE;
     31 
     32 #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     33 
     34 using PlatformFile = int;
     35 using ScopedPlatformFile = ::base::ScopedFD;
     36 
     37 constexpr PlatformFile kInvalidPlatformFile = -1;
     38 
     39 #endif
     40 
     41 }  // namespace
     42 
     43 #endif  // BASE_FILES_PLATFORM_FILE_H_
     44