1 /* dir-as-cwd.c: 2 * 3 **************************************************************** 4 * Copyright (C) 2003 Tom Lord 5 * 6 * See the file "COPYING" for further information about 7 * the copyright and warranty status of this work. 8 */ 9 10 11 #include "hackerlab/fs/file-names.h" 12 #include "hackerlab/fs/cwd.h" 13 #include "hackerlab/vu/safe.h" 14 #include "tla/libfsutils/dir-as-cwd.h" 15 16 17 18 t_uchar * directory_as_cwd(const t_uchar * dir)19directory_as_cwd (const t_uchar * dir) 20 { 21 int here_fd; 22 t_uchar * answer = 0; 23 24 here_fd = safe_open (".", O_RDONLY, 0); 25 26 safe_chdir (dir); 27 28 answer = safe_current_working_directory (); 29 30 safe_fchdir (here_fd); 31 safe_close (here_fd); 32 return answer; 33 } 34 35 36 37 38 /* tag: Tom Lord Fri May 30 21:47:40 2003 (dir-as-cwd.c) 39 */ 40