Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. int chdir(const char* path)
  2. {
  3.    
  4.     if (access(path) == -1) {
  5.     errno = ENOENT;
  6.     return 1;
  7.     }
  8.     if (!is_directory(path)) {
  9.     errno = ENOTDIR;
  10.     return 1;
  11.     }
  12.     char* normalized_path = io_get_absolute_path(path);
  13.     int result = setenv("CWD", path, 1);
  14.     free(normalized_path);
  15.  
  16.     return result;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement