Compose path (with boost::filesystem)
Posted
by ypnos
on Stack Overflow
See other posts from Stack Overflow
or by ypnos
Published on 2010-05-04T16:25:32Z
Indexed on
2010/05/04
16:28 UTC
Read the original article
Hit count: 284
I have a file that describes input data, which is split into several other files. In my descriptor file, I first give the path A that tells where all the other files are found.
The originator may set either a relative (to location of the descriptor file) or absolute path.
When my program is called, the user gives the name of the descriptor file. It may not be in the current working directory, so the filename B given may also contain directories.
For my program to always find the input files at the right places, I need to combine this information. If the path A given is absolute, I need to just that one. If it is relative, I need to concatenate it to the path B (i.e. directory portion of the filename).
I thought boost::filesystem::complete
may do the job for me. Unfortunately, it seems it is not. I also did not understand how to test wether a path given is absolute or not.
Any ideas?
© Stack Overflow or respective owner