|
Aegis
4.25.D505
|
00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1991-1997, 1999, 2001-2009, 2011, 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef OS_H 00020 #define OS_H 00021 00027 #include <common/ac/time.h> 00028 #include <common/ac/sys/types.h> 00029 00030 #include <common/nstring.h> 00031 00032 class string_list_ty; // forward 00033 class nstring_list; // forward 00034 00035 #define OS_EXEC_FLAG_NO_INPUT 0 00036 #define OS_EXEC_FLAG_INPUT 1 00037 #define OS_EXEC_FLAG_ERROK 2 00038 #define OS_EXEC_FLAG_SILENT 4 00039 00056 int os_exists(string_ty *path, bool eaccess_is_ok = false); 00057 00074 bool os_exists(const nstring &path, bool eaccess_is_ok = false); 00075 00091 void os_mkdir(string_ty *path, int mode, bool eexist_ok = false); 00092 00108 void os_mkdir(const nstring &path, int mode, bool eexist_ok = false); 00109 00119 void os_rmdir(string_ty *path); 00120 00130 void os_rmdir(const nstring &path); 00131 00139 void os_rmdir_errok(string_ty *path); 00140 00148 void os_rmdir_errok(const nstring &path); 00149 00156 void os_rmdir_bg(string_ty *path); 00157 00164 void os_rmdir_bg(const nstring &path); 00165 00176 void os_rmdir_tree(string_ty *path); 00177 00188 void os_rmdir_tree(const nstring &path); 00189 00206 void os_mkdir_between(string_ty *root, string_ty *rel, int mode); 00207 00224 void os_mkdir_between(const nstring &root, const nstring &rel, int mode); 00225 00253 void os_rename(string_ty *oldpath, string_ty *newpath); 00254 00283 void os_rename(const nstring &oldpath, const nstring &newpath); 00284 00308 void os_unlink(string_ty *path); 00309 00332 void os_unlink(const nstring &path); 00333 00355 void os_unlink_errok(string_ty *path); 00356 00378 void os_unlink_errok(const nstring &path); 00379 00388 string_ty *os_curdir(void); 00389 00399 string_ty *os_path_join(string_ty *lhs, string_ty *rhs); 00400 00410 nstring os_path_join(const nstring &lhs, const nstring &rhs); 00411 00422 string_ty *os_path_cat(string_ty *lhs, string_ty *rhs); 00423 00434 nstring os_path_cat(const nstring &lhs, const nstring &rhs); 00435 00448 string_ty *os_path_rel2abs(string_ty *root, string_ty *path); 00449 00462 nstring os_path_rel2abs(const nstring &root, const nstring &path); 00463 00477 string_ty *os_pathname(string_ty *path, int resolve); 00478 00488 nstring os_pathname(const nstring &path, bool resolve); 00489 00500 string_ty *os_basename(string_ty *name, string_ty *ext = NULL); 00501 00512 nstring os_basename(const nstring &name, const nstring &ext = ""); 00513 00524 string_ty *os_dirname(string_ty *path); 00525 00536 nstring os_dirname(const nstring &path); 00537 00546 string_ty *os_dirname_relative(string_ty *path); 00547 00556 nstring os_dirname_relative(const nstring &path); 00557 00568 string_ty *os_entryname(string_ty *path); 00569 00580 nstring os_entryname(const nstring &path); 00581 00589 string_ty *os_entryname_relative(string_ty *path); 00590 00598 nstring os_entryname_relative(const nstring &path); 00599 00614 string_ty *os_below_dir(string_ty *higher, string_ty *lower); 00615 00632 nstring os_below_dir(const nstring &upper, const nstring &lower); 00633 00644 void os_chdir(string_ty *path); 00645 00656 void os_chdir(const nstring &path); 00657 00687 void os_setuid(int id); 00688 00707 void os_setgid(int id); 00708 00724 void os_execute(string_ty *cmd, int flags, string_ty *dir); 00725 00741 void os_execute(const nstring &cmd, int flags, const nstring &dir); 00742 00756 int os_execute_retcode(string_ty *cmd, int flags, string_ty *dir); 00757 00771 int os_execute_retcode(const nstring &cmd, int flags, const nstring &dir); 00772 00773 string_ty *os_execute_slurp(string_ty *cmd, int flags, string_ty *dir); 00774 00790 void os_xargs(string_ty *the_command, struct string_list_ty *the_list, 00791 string_ty *dir); 00792 00808 void os_xargs(const nstring &the_command, const nstring_list &the_list, 00809 const nstring &dir); 00810 00811 off_t os_file_size(string_ty *); 00812 void os_mtime_range(string_ty *, time_t *, time_t *); 00813 time_t os_mtime_actual(string_ty *); 00814 void os_mtime_set(string_ty *, time_t); 00815 void os_mtime_set_errok(string_ty *, time_t); 00816 void os_chown_check(string_ty *path, int mode, int uid, int gid); 00817 00828 void os_chmod(string_ty *path, int mode); 00829 00840 void os_chmod(const nstring &path, int mode); 00841 00851 void os_chmod_errok(string_ty *path, int mode); 00852 00862 void os_chmod_errok(const nstring &path, int mode); 00863 00864 int os_chmod_query(string_ty *); 00865 00874 void os_link(string_ty *from, string_ty *to); 00875 00884 void os_link(const nstring &from, const nstring &to); 00885 00886 int os_testing_mode(void); 00887 void os_become_init(void); 00888 void os_become_init_mortal(void); 00889 void os_become_reinit_mortal(void); 00890 void os_become(int uid, int gid, int umsk); 00891 00900 void os_become_undo(void); 00901 00912 void os_become_undo(int uid, int gid); 00913 00921 void os_become_undo_atexit(void); 00922 00923 void os_become_orig(void); 00924 void os_become_query(int *uid, int *gid, int *umsk); 00925 void os_become_orig_query(int *uid, int *gid, int *umsk); 00926 00927 int os_become_active(void); 00928 #define os_become_must_be_active() \ 00929 os_become_must_be_active_gizzards(__FILE__, __LINE__) 00930 void os_become_must_be_active_gizzards(const char *, int); 00931 #define os_become_must_not_be_active() \ 00932 os_become_must_not_be_active_gizzards(__FILE__, __LINE__) 00933 void os_become_must_not_be_active_gizzards(const char *, int); 00934 00935 00947 int os_background(void); 00948 00958 int os_readable(string_ty *path); 00959 00969 int os_readable(const nstring &path); 00970 00971 bool os_executable(string_ty *); 00972 int os_waitpid(int child, int *status); 00973 int os_waitpid_status(int child, const char *cmd); 00974 00975 const char *os_shell(void); 00976 00977 enum edit_ty 00978 { 00979 edit_not_set, 00980 edit_foreground, 00981 edit_background 00982 }; 00983 00993 void os_edit(string_ty *filename, edit_ty mode); 00994 01004 void os_edit(const nstring &filename, edit_ty mode); 01005 01017 void os_edit(const nstring_list &filenames, edit_ty mode, const nstring &dir); 01018 01019 string_ty *os_edit_string(string_ty *, edit_ty); 01020 string_ty *os_edit_new(edit_ty); 01021 string_ty *os_edit_filename(int); 01022 string_ty *os_tmpdir(void); 01023 01031 int os_pathconf_name_max(const nstring &path); 01032 01040 int os_pathconf_name_max(string_ty *path); 01041 01050 int os_pathconf_path_max(const nstring &path); 01051 01060 int os_pathconf_path_max(string_ty *path); 01061 01070 void os_symlink(string_ty *src, string_ty *dst); 01071 01080 void os_symlink(const nstring &src, const nstring &dst); 01081 01091 void os_symlink_or_copy(string_ty *src, string_ty *dst); 01092 01105 string_ty *os_readlink(string_ty *path); 01106 01118 nstring os_readlink(const nstring &path); 01119 01120 int os_symlink_query(string_ty *); 01121 01131 void os_throttle(void); 01132 01142 bool os_unthrottle(void); 01143 01144 void os_owner_query(string_ty *, int *, int *); 01145 string_ty *os_fingerprint(string_ty *); 01146 01147 void os_interrupt_register(void); 01148 void os_interrupt_cope(void); 01149 void os_interrupt_ignore(void); 01150 int os_interrupt_has_occurred(void); 01151 01163 int os_isa_directory(string_ty *path); 01164 01176 bool os_isa_symlink(string_ty *path); 01177 01192 int os_isa_special_file(string_ty *path); 01193 01204 nstring os_magic_file(const nstring &filename); 01205 01216 nstring os_magic_file(string_ty *filename); 01217 01228 string_ty* os_canonify_dirname(string_ty *dirname); 01229 01239 nstring os_canonify_dirname(const nstring &dirname); 01240 01252 void os_check_path_traversable(string_ty *path); 01253 01255 #endif // OS_H 01256 // vim: set ts=8 sw=4 et :
1.7.6.1