Created
September 19, 2011 06:29
-
-
Save ashokgelal/1226055 to your computer and use it in GitHub Desktop.
chdir implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void changeDir(char *path){ | |
if(path == '\0'){ | |
// get home path | |
uid_t id = getuid(); | |
struct passwd *pwd = getpwuid(id); | |
path = (pwd == NULL ? ) "." : pwd->pw_dir; | |
} | |
int status = chdir(path); | |
if(status == 0){ | |
// first get the current directory | |
char cur_path[4096]; | |
getcwd(cur_path, 4096); | |
printf("%c]0;%s%s%c", '\033', "Olet tässä: ", curr_path, '\007'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment