Blame view

3rdparty/boost_1_81_0/boost/nowide/stat.hpp 2.26 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  //
  // Copyright (c) 2020 Alexander Grund
  //
  // Distributed under the Boost Software License, Version 1.0.
  // https://www.boost.org/LICENSE_1_0.txt
  
  #ifndef BOOST_NOWIDE_STAT_HPP_INCLUDED
  #define BOOST_NOWIDE_STAT_HPP_INCLUDED
  
  #include <boost/nowide/config.hpp>
  #include <sys/types.h>
  // Include after sys/types.h
  #include <sys/stat.h>
  
  #if defined(__MINGW32__) && defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x0601
  /// Forward declaration in case MinGW32 is used and __MSVCRT_VERSION__ is defined lower than 6.1
  struct __stat64;
  #endif
  
  namespace boost {
  namespace nowide {
  #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
      // Note: `using x = struct ::stat` causes a bogus warning in GCC < 11
      // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66159
  
      typedef struct ::stat stat_t;
      typedef struct ::stat posix_stat_t;
  
      using ::stat;
  #else
      /// \brief Typedef for the file info structure.
      /// Able to hold 64 bit file size and timestamps on Windows and usually also on other 64 Bit systems
      /// This allows to write portable code with optional LFS support
      typedef struct ::__stat64 stat_t;
      /// \brief Typedef for the file info structure used in the POSIX stat call
      /// Resolves to `struct _stat` on Windows and `struct stat` otherwise
      /// This allows to write portable code using the default stat function
      typedef struct ::_stat posix_stat_t;
  
      /// \cond INTERNAL
      namespace detail {
          BOOST_NOWIDE_DECL int stat(const char* path, stat_t* buffer, size_t buffer_size);
          BOOST_NOWIDE_DECL int stat(const char* path, posix_stat_t* buffer, size_t buffer_size);
      } // namespace detail
      /// \endcond
  
      ///
      /// \brief UTF-8 aware stat function, returns 0 on success
      ///
      /// Return information about a file from an UTF-8 encoded path
      ///
      inline int stat(const char* path, stat_t* buffer)
      {
          return detail::stat(path, buffer, sizeof(*buffer));
      }
      ///
      /// \brief UTF-8 aware stat function, returns 0 on success
      ///
      /// Return information about a file from an UTF-8 encoded path
      ///
      inline int stat(const char* path, posix_stat_t* buffer)
      {
          return detail::stat(path, buffer, sizeof(*buffer));
      }
  #endif
  } // namespace nowide
  } // namespace boost
  
  #endif