Re: How do I compute the full absolute path of a filename?



 George  twisted the bytes to say:

George  twisted the bytes to say:

Thanks George, for your prompt response. This routine works, but it
does not strip any "../" sequences from the path. I guess I'll have to
write one based on yours :)

dmg




 George> You cehck for the path to be absolute and in case it's not prepend the cwd.
 George> Something like:

 George> if(g_path_is_absolute(filename))
 George> 	absfilename = g_strdup(filename);
 George> else {
 George> 	char *cwd = g_get_current_dir();
 George> 	absfilename = g_strconcat(cwd, "/", filename, NULL);
 George> 	g_free(cwd);
 George> }

 George> George


--
Daniel M. German                  "I still have to see a problem,
                                   however complicated, which, when
                                    you looked at it in the right way
   Poul Anderson ->                did not become still more complicated."
http://csgwww.uwaterloo.ca/~dmg/home.html
dmg@csg.uwaterloo.ca

 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]