mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Reformat and use new os/stat capabilities.
This commit is contained in:
parent
b15cf193a0
commit
cd6c009c03
@ -456,24 +456,56 @@ static const uint8_t *janet_decode_mode(mode_t m) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Getters */
|
/* Getters */
|
||||||
static Janet os_stat_dev(struct stat *st) { return janet_wrap_number(st->st_dev); }
|
static Janet os_stat_dev(struct stat *st) {
|
||||||
static Janet os_stat_inode(struct stat *st) { return janet_wrap_number(st->st_ino); }
|
return janet_wrap_number(st->st_dev);
|
||||||
static Janet os_stat_mode(struct stat *st) { return janet_wrap_keyword(janet_decode_mode(st->st_mode)); }
|
}
|
||||||
static Janet os_stat_permissions(struct stat *st) { return janet_wrap_string(janet_decode_permissions(st->st_mode)); }
|
static Janet os_stat_inode(struct stat *st) {
|
||||||
static Janet os_stat_uid(struct stat *st) { return janet_wrap_number(st->st_uid); }
|
return janet_wrap_number(st->st_ino);
|
||||||
static Janet os_stat_gid(struct stat *st) { return janet_wrap_number(st->st_gid); }
|
}
|
||||||
static Janet os_stat_nlink(struct stat *st) { return janet_wrap_number(st->st_nlink); }
|
static Janet os_stat_mode(struct stat *st) {
|
||||||
static Janet os_stat_rdev(struct stat *st) { return janet_wrap_number(st->st_rdev); }
|
return janet_wrap_keyword(janet_decode_mode(st->st_mode));
|
||||||
static Janet os_stat_size(struct stat *st) { return janet_wrap_number(st->st_size); }
|
}
|
||||||
static Janet os_stat_accessed(struct stat *st) { return janet_wrap_number((double) st->st_atime); }
|
static Janet os_stat_permissions(struct stat *st) {
|
||||||
static Janet os_stat_modified(struct stat *st) { return janet_wrap_number((double) st->st_mtime); }
|
return janet_wrap_string(janet_decode_permissions(st->st_mode));
|
||||||
static Janet os_stat_changed(struct stat *st) { return janet_wrap_number((double) st->st_ctime); }
|
}
|
||||||
|
static Janet os_stat_uid(struct stat *st) {
|
||||||
|
return janet_wrap_number(st->st_uid);
|
||||||
|
}
|
||||||
|
static Janet os_stat_gid(struct stat *st) {
|
||||||
|
return janet_wrap_number(st->st_gid);
|
||||||
|
}
|
||||||
|
static Janet os_stat_nlink(struct stat *st) {
|
||||||
|
return janet_wrap_number(st->st_nlink);
|
||||||
|
}
|
||||||
|
static Janet os_stat_rdev(struct stat *st) {
|
||||||
|
return janet_wrap_number(st->st_rdev);
|
||||||
|
}
|
||||||
|
static Janet os_stat_size(struct stat *st) {
|
||||||
|
return janet_wrap_number(st->st_size);
|
||||||
|
}
|
||||||
|
static Janet os_stat_accessed(struct stat *st) {
|
||||||
|
return janet_wrap_number((double) st->st_atime);
|
||||||
|
}
|
||||||
|
static Janet os_stat_modified(struct stat *st) {
|
||||||
|
return janet_wrap_number((double) st->st_mtime);
|
||||||
|
}
|
||||||
|
static Janet os_stat_changed(struct stat *st) {
|
||||||
|
return janet_wrap_number((double) st->st_ctime);
|
||||||
|
}
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
static Janet os_stat_blocks(struct stat *st) { return janet_wrap_number(0); }
|
static Janet os_stat_blocks(struct stat *st) {
|
||||||
static Janet os_stat_blocksize(struct stat *st) { return janet_wrap_number(0); }
|
return janet_wrap_number(0);
|
||||||
|
}
|
||||||
|
static Janet os_stat_blocksize(struct stat *st) {
|
||||||
|
return janet_wrap_number(0);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static Janet os_stat_blocks(struct stat *st) { return janet_wrap_number(st->st_blocks); }
|
static Janet os_stat_blocks(struct stat *st) {
|
||||||
static Janet os_stat_blocksize(struct stat *st) { return janet_wrap_number(st->st_blksize); }
|
return janet_wrap_number(st->st_blocks);
|
||||||
|
}
|
||||||
|
static Janet os_stat_blocksize(struct stat *st) {
|
||||||
|
return janet_wrap_number(st->st_blksize);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct OsStatGetter {
|
struct OsStatGetter {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
(defn- rm
|
(defn- rm
|
||||||
"Remove a directory and all sub directories."
|
"Remove a directory and all sub directories."
|
||||||
[path]
|
[path]
|
||||||
(if (= ((os/stat path) :mode) :directory)
|
(if (= (os/stat path :mode) :directory)
|
||||||
(do
|
(do
|
||||||
(each subpath (os/dir path) (rm subpath))
|
(each subpath (os/dir path) (rm subpath))
|
||||||
(os/rmdir path))
|
(os/rmdir path))
|
||||||
@ -32,8 +32,8 @@
|
|||||||
(def f (file/open dest))
|
(def f (file/open dest))
|
||||||
(if (not f) (break true))
|
(if (not f) (break true))
|
||||||
(file/close f)
|
(file/close f)
|
||||||
(let [mod-dest ((os/stat dest) :modified)
|
(let [mod-dest (os/stat dest :modified)
|
||||||
mod-src ((os/stat src) :modified)]
|
mod-src (os/stat src :modified)]
|
||||||
(< mod-dest mod-src)))
|
(< mod-dest mod-src)))
|
||||||
|
|
||||||
(defn- needs-build-some
|
(defn- needs-build-some
|
||||||
|
Loading…
Reference in New Issue
Block a user