diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-08 13:10:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-08 13:10:56 -0700 |
commit | 478ae133483a91b35028eca9666689669fe55015 (patch) | |
tree | 53ff027735fc2b9479bdc7d962b454ba636a065f /sysif.c | |
parent | 44638912c7353e46c5d2d9b6fe9362f662809f02 (diff) | |
download | txr-478ae133483a91b35028eca9666689669fe55015.tar.gz txr-478ae133483a91b35028eca9666689669fe55015.tar.bz2 txr-478ae133483a91b35028eca9666689669fe55015.zip |
New path slot in stat struct.
* ftw.c (ftw_callback): Pass path to stat_to_struct function.
* socket.c (path_s): Variable definition removed from here.
(sock_load_init): Do not intern path symbol here.
* sysif.c (path_s): Variable definition moved here.
(stat_to_struct): New parameter, path. Store its argument in
the path slot of the structure.
(stat_impl): New parameter, path. Pass argument to
stat_to_struct.
(statp, statl): Pass path down to stat_impl.
(statf): Pass nil down as path argument of stat_impl.
(sysif_init): Intern path symbol here.
Add path_s to the slot list in the make_struct_type
call which creates the stat structure type.
* sysif.h (path_s): Declared here now.
(stat_to_struct): Declaration updated.
* txr.1: Documented new slot of stat structure and
behavior of stat, lstat and fstat w.r.t. this slot.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -92,7 +92,7 @@ val gid_k, rdev_k, size_k, blksize_k, blocks_k; val atime_k, mtime_k, ctime_k; val dev_s, ino_s, mode_s, nlink_s, uid_s; val gid_s, rdev_s, size_s, blksize_s, blocks_s; -val atime_s, mtime_s, ctime_s; +val atime_s, mtime_s, ctime_s, path_s; #if HAVE_PWUID val passwd_s, gecos_s, dir_s, shell_s; @@ -654,7 +654,7 @@ static val stat_to_list(struct stat st) nao); } -val stat_to_struct(struct stat st) +val stat_to_struct(struct stat st, val path) { args_decl(args, ARGS_MIN); val strct = make_struct(stat_s, nil, args); @@ -676,13 +676,15 @@ val stat_to_struct(struct stat st) slotset(strct, atime_s, num(st.st_atime)); slotset(strct, mtime_s, num(st.st_mtime)); slotset(strct, ctime_s, num(st.st_ctime)); + if (path) + slotset(strct, path_s, path); return strct; } #endif static val stat_impl(val obj, int (*statfn)(val, struct stat *), - val name) + val name, val path) { #if HAVE_SYS_STAT struct stat st; @@ -693,7 +695,7 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *), name, obj, num(errno), string_utf8(strerror(errno)), nao); return if3(opt_compat && opt_compat <= 113, - stat_to_list(st), stat_to_struct(st)); + stat_to_list(st), stat_to_struct(st, path)); #else uw_throwf(file_error_s, lit("~a is not implemented"), name, nao); #endif @@ -701,17 +703,17 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *), val statp(val path) { - return stat_impl(path, w_stat, lit("stat")); + return stat_impl(path, w_stat, lit("stat"), path); } static val statl(val path) { - return stat_impl(path, w_lstat, lit("lstat")); + return stat_impl(path, w_lstat, lit("lstat"), path); } val statf(val stream) { - return stat_impl(stream, w_fstat, lit("fstat")); + return stat_impl(stream, w_fstat, lit("fstat"), nil); } #if HAVE_SYS_STAT @@ -1483,6 +1485,7 @@ void sysif_init(void) atime_s = intern(lit("atime"), user_package); mtime_s = intern(lit("mtime"), user_package); ctime_s = intern(lit("ctime"), user_package); + path_s = intern(lit("path"), user_package); #if HAVE_PWUID passwd_s = intern(lit("passwd"), user_package); gecos_s = intern(lit("gecos"), user_package); @@ -1506,7 +1509,7 @@ void sysif_init(void) make_struct_type(stat_s, nil, nil, list(dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, - mtime_s, ctime_s, nao), nil, nil, nil, nil); + mtime_s, ctime_s, path_s, nao), nil, nil, nil, nil); #if HAVE_PWUID make_struct_type(passwd_s, nil, nil, list(name_s, passwd_s, uid_s, gid_s, |