Boost.Nowide
stat.hpp
1//
2// Copyright (c) 2020 Alexander Grund
3//
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#ifndef BOOST_NOWIDE_STAT_HPP_INCLUDED
8#define BOOST_NOWIDE_STAT_HPP_INCLUDED
9
11#include <sys/types.h>
12// Include after sys/types.h
13#include <sys/stat.h>
14
15#if defined(__MINGW32__) && defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x0601
17struct __stat64;
18#endif
19
20namespace boost {
21namespace nowide {
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
25
26 typedef struct ::stat stat_t;
27 typedef struct ::stat posix_stat_t;
28
29 using ::stat;
30#else
34 typedef struct ::__stat64 stat_t;
38 typedef struct ::_stat posix_stat_t;
39
41 namespace detail {
42 BOOST_NOWIDE_DECL int stat(const char* path, stat_t* buffer, size_t buffer_size);
43 BOOST_NOWIDE_DECL int stat(const char* path, posix_stat_t* buffer, size_t buffer_size);
44 } // namespace detail
46
52 inline int stat(const char* path, stat_t* buffer)
53 {
54 return detail::stat(path, buffer, sizeof(*buffer));
55 }
61 inline int stat(const char* path, posix_stat_t* buffer)
62 {
63 return detail::stat(path, buffer, sizeof(*buffer));
64 }
65#endif
66} // namespace nowide
67} // namespace boost
68
69#endif
int stat(const char *path, stat_t *buffer)
UTF-8 aware stat function, returns 0 on success.
Definition: stat.hpp:52
struct ::__stat64 stat_t
Typedef for the file info structure. Able to hold 64 bit file size and timestamps on Windows and usua...
Definition: stat.hpp:34
struct ::_stat posix_stat_t
Typedef for the file info structure used in the POSIX stat call Resolves to struct _stat on Windows a...
Definition: stat.hpp:38