1+ /**
2+ * @file stat.h
3+ *
4+ */
5+ /* Copyright (C) 2026 by Arjan van Vught mailto:info@gd32-dmx.org
6+ *
7+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8+ * of this software and associated documentation files (the "Software"), to deal
9+ * in the Software without restriction, including without limitation the rights
10+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+ * copies of the Software, and to permit persons to whom the Software is
12+ * furnished to do so, subject to the following conditions:
13+
14+ * The above copyright notice and this permission notice shall be included in
15+ * all copies or substantial portions of the Software.
16+
17+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+ * THE SOFTWARE.
24+ */
25+
26+ #ifndef SYS_STAT_H_
27+ #define SYS_STAT_H_
28+
29+ #include <time.h>
30+ #include <sys/types.h>
31+
32+ struct stat { // NOLINT
33+ mode_t st_mode ;
34+ off_t st_size ;
35+ // time_t st_atime;
36+ time_t st_mtime ;
37+ // time_t st_ctime;
38+ };
39+
40+ #define S_IFMT 0170000 ///< These bits determine file type.
41+ #define S_IFDIR 0040000 ///< Directory.
42+ #define S_IFCHR 0020000 ///< Character device.
43+ #define S_IFBLK 0060000 ///< Block device
44+ #define S_IFREG 0100000 ///< Regular file.
45+ #define S_IFIFO 0010000 ///< FIFO. */
46+ #define S_IFLNK 0120000 ///< Symbolic link.
47+ #define S_IFSOCK 0140000 ///< Socket.
48+ #define S_IREAD 0400 ///< Read by owner.
49+ #define S_IWRITE 0200 ///< Write by owner.
50+ #define S_IEXEC 0100 ///< Execute by owner.
51+
52+ #define S_IRUSR S_IREAD ///< Read by owner.
53+ #define S_IWUSR S_IWRITE ///< Write by owner.
54+ #define S_IXUSR S_IEXEC ///< Execute by owner.
55+ #define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC) ///< Read,Write,Execute by owner
56+
57+ #define S_IRGRP (S_IRUSR >> 3) ///< Read by group.
58+ #define S_IWGRP (S_IWUSR >> 3) ///< Write by group.
59+ #define S_IXGRP (S_IXUSR >> 3) ///< Execute by group.
60+ #define S_IRWXG (S_IRWXU >> 3) ///< Read,Write,Execute by user
61+
62+ #define S_IROTH (S_IRGRP >> 3) ///< Read by others.
63+ #define S_IWOTH (S_IWGRP >> 3) ///< Write by others.
64+ #define S_IXOTH (S_IXGRP >> 3) ///< Execute by others.
65+ #define S_IRWXO (S_IRWXG >> 3) ///< Read,Write,Execute by other
66+
67+ #pragma GCC diagnostic push
68+ #pragma GCC diagnostic ignored "-Wshadow"
69+
70+ int stat (const char * path , struct stat * buf ); // NOLINT
71+
72+ #pragma GCC diagnostic pop
73+
74+ #endif // SYS_STAT_H_
0 commit comments