2 // Copyright (c) 2020 Alexander Grund
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_NOWIDE_STAT_HPP_INCLUDED
8 #define BOOST_NOWIDE_STAT_HPP_INCLUDED
10 #include <boost/nowide/config.hpp>
11 #include <sys/types.h>
12 // Include after sys/types.h
15 #if defined(__MINGW32__) && defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x0601
16 /// Forward declaration in case MinGW32 is used and __MSVCRT_VERSION__ is defined lower than 6.1
22 #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
23 // Note: `using x = struct ::stat` causes a bogus warning in GCC < 11
24 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66159
26 typedef struct ::stat stat_t;
27 typedef struct ::stat posix_stat_t;
31 /// \brief Typedef for the file info structure.
32 /// Able to hold 64 bit filesize and timestamps on Windows and usually also on other 64 Bit systems
33 /// This allows to write portable code with option LFS support
34 typedef struct ::__stat64 stat_t;
35 /// \brief Typedef for the file info structure used in the POSIX stat call
36 /// Resolves to `struct _stat` on Windows and `struct stat` otherwise
37 /// This allows to write portable code using the default stat function
38 typedef struct ::_stat posix_stat_t;
42 BOOST_NOWIDE_DECL int stat(const char* path, posix_stat_t* buffer, size_t buffer_size);
47 /// \brief UTF-8 aware stat function, returns 0 on success
49 /// Return information about a file from an UTF-8 encoded path
51 BOOST_NOWIDE_DECL int stat(const char* path, stat_t* buffer);
53 /// \brief UTF-8 aware stat function, returns 0 on success
55 /// Return information about a file from an UTF-8 encoded path
57 inline int stat(const char* path, posix_stat_t* buffer)
59 return detail::stat(path, buffer, sizeof(*buffer));