mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 09:47:17 +00:00
Remove windows MSVC warnings about _stat.
This commit is contained in:
parent
b76ff3bdfc
commit
665f4bf248
@ -953,62 +953,68 @@ static const uint8_t *janet_decode_mode(mode_t m) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef JANET_WINDOWS
|
||||||
|
typedef struct _stat jstat_t;
|
||||||
|
#else
|
||||||
|
typedef struct stat jstat_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Getters */
|
/* Getters */
|
||||||
static Janet os_stat_dev(struct stat *st) {
|
static Janet os_stat_dev(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_dev);
|
return janet_wrap_number(st->st_dev);
|
||||||
}
|
}
|
||||||
static Janet os_stat_inode(struct stat *st) {
|
static Janet os_stat_inode(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_ino);
|
return janet_wrap_number(st->st_ino);
|
||||||
}
|
}
|
||||||
static Janet os_stat_mode(struct stat *st) {
|
static Janet os_stat_mode(jstat_t *st) {
|
||||||
return janet_wrap_keyword(janet_decode_mode(st->st_mode));
|
return janet_wrap_keyword(janet_decode_mode(st->st_mode));
|
||||||
}
|
}
|
||||||
static Janet os_stat_permissions(struct stat *st) {
|
static Janet os_stat_permissions(jstat_t *st) {
|
||||||
return janet_wrap_string(janet_decode_permissions(st->st_mode));
|
return janet_wrap_string(janet_decode_permissions(st->st_mode));
|
||||||
}
|
}
|
||||||
static Janet os_stat_uid(struct stat *st) {
|
static Janet os_stat_uid(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_uid);
|
return janet_wrap_number(st->st_uid);
|
||||||
}
|
}
|
||||||
static Janet os_stat_gid(struct stat *st) {
|
static Janet os_stat_gid(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_gid);
|
return janet_wrap_number(st->st_gid);
|
||||||
}
|
}
|
||||||
static Janet os_stat_nlink(struct stat *st) {
|
static Janet os_stat_nlink(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_nlink);
|
return janet_wrap_number(st->st_nlink);
|
||||||
}
|
}
|
||||||
static Janet os_stat_rdev(struct stat *st) {
|
static Janet os_stat_rdev(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_rdev);
|
return janet_wrap_number(st->st_rdev);
|
||||||
}
|
}
|
||||||
static Janet os_stat_size(struct stat *st) {
|
static Janet os_stat_size(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_size);
|
return janet_wrap_number(st->st_size);
|
||||||
}
|
}
|
||||||
static Janet os_stat_accessed(struct stat *st) {
|
static Janet os_stat_accessed(jstat_t *st) {
|
||||||
return janet_wrap_number((double) st->st_atime);
|
return janet_wrap_number((double) st->st_atime);
|
||||||
}
|
}
|
||||||
static Janet os_stat_modified(struct stat *st) {
|
static Janet os_stat_modified(jstat_t *st) {
|
||||||
return janet_wrap_number((double) st->st_mtime);
|
return janet_wrap_number((double) st->st_mtime);
|
||||||
}
|
}
|
||||||
static Janet os_stat_changed(struct stat *st) {
|
static Janet os_stat_changed(jstat_t *st) {
|
||||||
return janet_wrap_number((double) st->st_ctime);
|
return janet_wrap_number((double) st->st_ctime);
|
||||||
}
|
}
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
static Janet os_stat_blocks(struct stat *st) {
|
static Janet os_stat_blocks(jstat_t *st) {
|
||||||
return janet_wrap_number(0);
|
return janet_wrap_number(0);
|
||||||
}
|
}
|
||||||
static Janet os_stat_blocksize(struct stat *st) {
|
static Janet os_stat_blocksize(jstat_t *st) {
|
||||||
return janet_wrap_number(0);
|
return janet_wrap_number(0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static Janet os_stat_blocks(struct stat *st) {
|
static Janet os_stat_blocks(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_blocks);
|
return janet_wrap_number(st->st_blocks);
|
||||||
}
|
}
|
||||||
static Janet os_stat_blocksize(struct stat *st) {
|
static Janet os_stat_blocksize(jstat_t *st) {
|
||||||
return janet_wrap_number(st->st_blksize);
|
return janet_wrap_number(st->st_blksize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct OsStatGetter {
|
struct OsStatGetter {
|
||||||
const char *name;
|
const char *name;
|
||||||
Janet(*fn)(struct stat *st);
|
Janet(*fn)(jstat_t *st);
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct OsStatGetter os_stat_getters[] = {
|
static const struct OsStatGetter os_stat_getters[] = {
|
||||||
@ -1047,12 +1053,11 @@ static Janet os_stat_or_lstat(int do_lstat, int32_t argc, Janet *argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build result */
|
/* Build result */
|
||||||
|
jstat_t st;
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
(void) do_lstat;
|
(void) do_lstat;
|
||||||
struct _stat st;
|
|
||||||
int res = _stat(path, &st);
|
int res = _stat(path, &st);
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
|
||||||
int res;
|
int res;
|
||||||
if (do_lstat) {
|
if (do_lstat) {
|
||||||
res = lstat(path, &st);
|
res = lstat(path, &st);
|
||||||
|
Loading…
Reference in New Issue
Block a user