-   Programming (
-   -   Filenames with tilde (

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


All times are GMT -5. The time now is 07:55 PM.