Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:46

0001 //
0002 // Copyright (c) 2020 Alexander Grund
0003 //
0004 // Distributed under the Boost Software License, Version 1.0.
0005 // https://www.boost.org/LICENSE_1_0.txt
0006 
0007 #ifndef BOOST_NOWIDE_STAT_HPP_INCLUDED
0008 #define BOOST_NOWIDE_STAT_HPP_INCLUDED
0009 
0010 #include <boost/nowide/config.hpp>
0011 #include <sys/types.h>
0012 // Include after sys/types.h
0013 #include <sys/stat.h>
0014 
0015 #if defined(__MINGW32__) && defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x0601
0016 /// Forward declaration in case MinGW32 is used and __MSVCRT_VERSION__ is defined lower than 6.1
0017 struct __stat64;
0018 #endif
0019 
0020 namespace boost {
0021 namespace nowide {
0022 #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
0023     // Note: `using x = struct ::stat` causes a bogus warning in GCC < 11
0024     // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66159
0025 
0026     typedef struct ::stat stat_t;
0027     typedef struct ::stat posix_stat_t;
0028 
0029     using ::stat;
0030 #else
0031     /// \brief Typedef for the file info structure.
0032     /// Able to hold 64 bit file size and timestamps on Windows and usually also on other 64 Bit systems
0033     /// This allows to write portable code with optional LFS support
0034     typedef struct ::__stat64 stat_t;
0035     /// \brief Typedef for the file info structure used in the POSIX stat call
0036     /// Resolves to `struct _stat` on Windows and `struct stat` otherwise
0037     /// This allows to write portable code using the default stat function
0038     typedef struct ::_stat posix_stat_t;
0039 
0040     /// \cond INTERNAL
0041     namespace detail {
0042         BOOST_NOWIDE_DECL int stat(const char* path, stat_t* buffer, size_t buffer_size);
0043         BOOST_NOWIDE_DECL int stat(const char* path, posix_stat_t* buffer, size_t buffer_size);
0044     } // namespace detail
0045     /// \endcond
0046 
0047     ///
0048     /// \brief UTF-8 aware stat function, returns 0 on success
0049     ///
0050     /// Return information about a file from an UTF-8 encoded path
0051     ///
0052     inline int stat(const char* path, stat_t* buffer)
0053     {
0054         return detail::stat(path, buffer, sizeof(*buffer));
0055     }
0056     ///
0057     /// \brief UTF-8 aware stat function, returns 0 on success
0058     ///
0059     /// Return information about a file from an UTF-8 encoded path
0060     ///
0061     inline int stat(const char* path, posix_stat_t* buffer)
0062     {
0063         return detail::stat(path, buffer, sizeof(*buffer));
0064     }
0065 #endif
0066 } // namespace nowide
0067 } // namespace boost
0068 
0069 #endif