| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Partial <sys/stat.h>-lookalike-ish. Note that this is a C header, so that | 5 // Partial <sys/stat.h>-lookalike-ish. Note that this is a C header, so that |
| 6 // crappy (and non-crappy) C programs can use it. | 6 // crappy (and non-crappy) C programs can use it. |
| 7 // | 7 // |
| 8 // In general, functions/types/macros are given "mojio_"/"MOJIO_"/etc. prefixes. | 8 // In general, functions/types/macros are given "mojio_"/"MOJIO_"/etc. prefixes. |
| 9 // There are a handful of exceptions (noted below). | 9 // There are a handful of exceptions (noted below). |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #define MOJIO_S_IFSOCK 0140000 | 53 #define MOJIO_S_IFSOCK 0140000 |
| 54 | 54 |
| 55 #define MOJIO_S_ISBLK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFBLK) | 55 #define MOJIO_S_ISBLK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFBLK) |
| 56 #define MOJIO_S_ISCHR(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFCHR) | 56 #define MOJIO_S_ISCHR(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFCHR) |
| 57 #define MOJIO_S_ISDIR(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFDIR) | 57 #define MOJIO_S_ISDIR(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFDIR) |
| 58 #define MOJIO_S_ISFIFO(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFIFO) | 58 #define MOJIO_S_ISFIFO(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFIFO) |
| 59 #define MOJIO_S_ISLNK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFLNK) | 59 #define MOJIO_S_ISLNK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFLNK) |
| 60 #define MOJIO_S_ISREG(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFREG) | 60 #define MOJIO_S_ISREG(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFREG) |
| 61 #define MOJIO_S_ISSOCK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFSOCK) | 61 #define MOJIO_S_ISSOCK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFSOCK) |
| 62 | 62 |
| 63 // These are for backwards compatibility with older versions of POSIX. Since we | 63 // POSIX.1-2008 says we should define |st_atime| to |st_atim.tv_sec| (and |
| 64 // didn't prefix the names of the members in |struct mojio_stat| below, we don't | 64 // similarly for |st_mtime| and |st_ctime|). This is to provide (source) |
| 65 // prefix these macro names either. This means that we'll collide with the | 65 // backwards compatibility with older versions of POSIX. |
| 66 // "real" <sys/stat.h>, but that should be fine as long as it follows | 66 // |
| 67 // POSIX.1-2008 to the letter (since the macro definitions will be identical, | 67 // We could reasonably provide these macros on systems that are compliant with |
| 68 // which is valid). | 68 // POSIX.1-2008 (or later): even though they might collide with macro |
| 69 #define st_atime st_atim.tv_sec | 69 // definitions in the "real" <sys/stat.h>, it's okay since the macro definitions |
| 70 #define st_mtime st_mtim.tv_sec | 70 // will be identical. However, providing these macros on systems that aren't |
| 71 #define st_ctime st_ctim.tv_sec | 71 // POSIX.1-2008-compliant (like Android) leads to an intractable conflict. Thus |
| 72 // we provide prefixed macros instead. |
| 73 #define mojio_st_atime st_atim.tv_sec |
| 74 #define mojio_st_mtime st_mtim.tv_sec |
| 75 #define mojio_st_ctime st_ctim.tv_sec |
| 72 | 76 |
| 73 // Types ----------------------------------------------------------------------- | 77 // Types ----------------------------------------------------------------------- |
| 74 | 78 |
| 75 struct mojio_stat { | 79 struct mojio_stat { |
| 76 mojio_dev_t st_dev; | 80 mojio_dev_t st_dev; |
| 77 mojio_ino_t st_ino; | 81 mojio_ino_t st_ino; |
| 78 mojio_mode_t st_mode; | 82 mojio_mode_t st_mode; |
| 79 mojio_nlink_t st_nlink; | 83 mojio_nlink_t st_nlink; |
| 80 mojio_uid_t st_uid; | 84 mojio_uid_t st_uid; |
| 81 mojio_gid_t st_gid; | 85 mojio_gid_t st_gid; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // mode_t umask(mode_t); | 119 // mode_t umask(mode_t); |
| 116 // int utimensat(int, const char*, const struct timespec [2], int); | 120 // int utimensat(int, const char*, const struct timespec [2], int); |
| 117 | 121 |
| 118 int mojio_fstat(int fd, struct mojio_stat* buf); | 122 int mojio_fstat(int fd, struct mojio_stat* buf); |
| 119 | 123 |
| 120 #ifdef __cplusplus | 124 #ifdef __cplusplus |
| 121 } // extern "C" | 125 } // extern "C" |
| 122 #endif | 126 #endif |
| 123 | 127 |
| 124 #endif // SERVICES_FILES_C_MOJIO_SYS_STAT_H_ | 128 #endif // SERVICES_FILES_C_MOJIO_SYS_STAT_H_ |
| OLD | NEW |