/ Published in: C++

This one just demonstrates an easy way to get the information via pwuid's. Might not the most elegnt way ut works on every unix I believe.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
string get_home(void) { /* the passwd struct */ struct passwd *passwd; /* we pass the current users UID to the struct variable*/ passwd = getpwuid ( getuid()); /* then we pass the UID to pw_name which is a char value of the /home/ directory */ string user(passwd->pw_name); /*then we make sure we have the full path + our secret config dir*/ user = "/home/" + user + "/.mkproject/"; return user; }
Comments
