00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OS_H
00021 #define OS_H
00022
00028 #include <common/ac/time.h>
00029
00030 #include <common/main.h>
00031 #include <common/nstring.h>
00032
00033 class string_list_ty;
00034 class nstring_list;
00035
00036 #define OS_EXEC_FLAG_NO_INPUT 0
00037 #define OS_EXEC_FLAG_INPUT 1
00038 #define OS_EXEC_FLAG_ERROK 2
00039 #define OS_EXEC_FLAG_SILENT 4
00040
00057 int os_exists(string_ty *path, bool eaccess_is_ok = false);
00058
00075 bool os_exists(const nstring &path, bool eaccess_is_ok = false);
00076
00089 void os_mkdir(string_ty *path, int mode);
00090
00103 void os_mkdir(const nstring &path, int mode);
00104
00114 void os_rmdir(string_ty *path);
00115
00125 void os_rmdir(const nstring &path);
00126
00134 void os_rmdir_errok(string_ty *path);
00135
00143 void os_rmdir_errok(const nstring &path);
00144
00151 void os_rmdir_bg(string_ty *path);
00152
00159 void os_rmdir_bg(const nstring &path);
00160
00171 void os_rmdir_tree(string_ty *path);
00172
00183 void os_rmdir_tree(const nstring &path);
00184
00201 void os_mkdir_between(string_ty *root, string_ty *rel, int mode);
00202
00219 void os_mkdir_between(const nstring &root, const nstring &rel, int mode);
00220
00248 void os_rename(string_ty *oldpath, string_ty *newpath);
00249
00278 void os_rename(const nstring &oldpath, const nstring &newpath);
00279
00303 void os_unlink(string_ty *path);
00304
00327 void os_unlink(const nstring &path);
00328
00350 void os_unlink_errok(string_ty *path);
00351
00373 void os_unlink_errok(const nstring &path);
00374
00383 string_ty *os_curdir(void);
00384
00394 string_ty *os_path_join(string_ty *lhs, string_ty *rhs);
00395
00405 nstring os_path_join(const nstring &lhs, const nstring &rhs);
00406
00416 nstring os_path_join(const nstring &lhs, const nstring &rhs);
00417
00428 string_ty *os_path_cat(string_ty *lhs, string_ty *rhs);
00429
00440 nstring os_path_cat(const nstring &lhs, const nstring &rhs);
00441
00452 nstring os_path_cat(const nstring &lhs, const nstring &rhs);
00453
00466 string_ty *os_path_rel2abs(string_ty *root, string_ty *path);
00467
00480 nstring os_path_rel2abs(const nstring &root, const nstring &path);
00481
00495 string_ty *os_pathname(string_ty *path, int resolve);
00496
00506 nstring os_pathname(const nstring &path, bool resolve);
00507
00518 string_ty *os_basename(string_ty *name, string_ty *ext = NULL);
00519
00530 nstring os_basename(const nstring &name, const nstring &ext = "");
00531
00542 string_ty *os_dirname(string_ty *path);
00543
00554 nstring os_dirname(const nstring &path);
00555
00564 string_ty *os_dirname_relative(string_ty *path);
00565
00574 nstring os_dirname_relative(const nstring &path);
00575
00586 string_ty *os_entryname(string_ty *path);
00587
00598 nstring os_entryname(const nstring &path);
00599
00607 string_ty *os_entryname_relative(string_ty *path);
00608
00616 nstring os_entryname_relative(const nstring &path);
00617
00632 string_ty *os_below_dir(string_ty *higher, string_ty *lower);
00633
00650 nstring os_below_dir(const nstring &upper, const nstring &lower);
00651
00662 void os_chdir(string_ty *path);
00663
00674 void os_chdir(const nstring &path);
00675
00705 void os_setuid(int id);
00706
00725 void os_setgid(int id);
00726
00742 void os_execute(string_ty *cmd, int flags, string_ty *dir);
00743
00759 void os_execute(const nstring &cmd, int flags, const nstring &dir);
00760
00774 int os_execute_retcode(string_ty *cmd, int flags, string_ty *dir);
00775
00789 int os_execute_retcode(const nstring &cmd, int flags, const nstring &dir);
00790
00791 string_ty *os_execute_slurp(string_ty *cmd, int flags, string_ty *dir);
00792
00808 void os_xargs(string_ty *the_command, struct string_list_ty *the_list,
00809 string_ty *dir);
00810
00826 void os_xargs(const nstring &the_command, const nstring_list &the_list,
00827 const nstring &dir);
00828
00829 long os_file_size(string_ty *);
00830 void os_mtime_range(string_ty *, time_t *, time_t *);
00831 time_t os_mtime_actual(string_ty *);
00832 void os_mtime_set(string_ty *, time_t);
00833 void os_mtime_set_errok(string_ty *, time_t);
00834 void os_chown_check(string_ty *path, int mode, int uid, int gid);
00835
00846 void os_chmod(string_ty *path, int mode);
00847
00858 void os_chmod(const nstring &path, int mode);
00859
00869 void os_chmod_errok(string_ty *path, int mode);
00870
00880 void os_chmod_errok(const nstring &path, int mode);
00881
00882 int os_chmod_query(string_ty *);
00883
00892 void os_link(string_ty *from, string_ty *to);
00893
00902 void os_link(const nstring &from, const nstring &to);
00903
00904 int os_testing_mode(void);
00905 void os_become_init(void);
00906 void os_become_init_mortal(void);
00907 void os_become_reinit_mortal(void);
00908 void os_become(int uid, int gid, int umsk);
00909
00918 void os_become_undo(void);
00919
00930 void os_become_undo(int uid, int gid);
00931
00939 void os_become_undo_atexit(void);
00940
00941 void os_become_orig(void);
00942 void os_become_query(int *uid, int *gid, int *umsk);
00943 void os_become_orig_query(int *uid, int *gid, int *umsk);
00944
00945 int os_become_active(void);
00946 #define os_become_must_be_active() \
00947 os_become_must_be_active_gizzards(__FILE__, __LINE__)
00948 void os_become_must_be_active_gizzards(const char *, int);
00949 #define os_become_must_not_be_active() \
00950 os_become_must_not_be_active_gizzards(__FILE__, __LINE__)
00951 void os_become_must_not_be_active_gizzards(const char *, int);
00952
00953
00965 int os_background(void);
00966
00976 int os_readable(string_ty *path);
00977
00987 int os_readable(const nstring &path);
00988
00989 bool os_executable(string_ty *);
00990 int os_waitpid(int child, int *status);
00991 int os_waitpid_status(int child, const char *cmd);
00992
00993 const char *os_shell(void);
00994
00995 enum edit_ty
00996 {
00997 edit_not_set,
00998 edit_foreground,
00999 edit_background
01000 };
01001
01011 void os_edit(string_ty *filename, edit_ty mode);
01012
01022 void os_edit(const nstring &filename, edit_ty mode);
01023
01024 string_ty *os_edit_string(string_ty *, edit_ty);
01025 string_ty *os_edit_new(edit_ty);
01026 string_ty *os_edit_filename(int);
01027 string_ty *os_tmpdir(void);
01028
01036 int os_pathconf_name_max(const nstring &path);
01037
01045 int os_pathconf_name_max(string_ty *path);
01046
01055 int os_pathconf_path_max(const nstring &path);
01056
01065 int os_pathconf_path_max(string_ty *path);
01066
01075 void os_symlink(string_ty *src, string_ty *dst);
01076
01085 void os_symlink(const nstring &src, const nstring &dst);
01086
01096 void os_symlink_or_copy(string_ty *src, string_ty *dst);
01097
01098 string_ty *os_readlink(string_ty *);
01099 int os_symlink_query(string_ty *);
01100
01110 void os_throttle(void);
01111
01121 bool os_unthrottle(void);
01122
01123 void os_owner_query(string_ty *, int *, int *);
01124 string_ty *os_fingerprint(string_ty *);
01125
01126 void os_interrupt_register(void);
01127 void os_interrupt_cope(void);
01128 void os_interrupt_ignore(void);
01129 int os_interrupt_has_occurred(void);
01130
01142 int os_isa_directory(string_ty *path);
01143
01155 bool os_isa_symlink(string_ty *path);
01156
01171 int os_isa_special_file(string_ty *path);
01172
01183 nstring os_magic_file(const nstring &filename);
01184
01195 nstring os_magic_file(string_ty *filename);
01196
01207 string_ty* os_canonify_dirname(string_ty *dirname);
01208
01218 nstring os_canonify_dirname(const nstring &dirname);
01219
01231 void os_check_path_traversable(string_ty *path);
01232
01234 #endif // OS_H