LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Filenames with tilde (http://www.linuxquestions.org/questions/programming-9/filenames-with-tilde-5094/)

rovoreed 08-04-2001 02:03 PM

Filenames with tilde
 
I want to open a file with a filename that starts with ~ so that it is created/opened in the users home directory.

But when I try to do that it fails with "No such directory".

I would have thought that this was a common requirement. So is there a handy library function that exists to convert the tilde into the users home directory path.

If not, and I have to do the conversion myself, what routines exist to get hold of the HOMEDIR variable.

All in "C" by the way.

sabeel 08-05-2001 04:27 PM

i dont know if theres a lib to automatically convert ~ to users home dir, but if you want to do it yourself and want to get hold of teh HOME, then you will have to use "environ"
use teh declaration as

extern char **environ;

and then get teh HOME var.

rovoreed 08-08-2001 04:53 PM

Thanks. I'm now decoding the environment variables and that seems to do what I want.

Thanks again

Mike


All times are GMT -5. The time now is 06:04 AM.