std.path.buildPath

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 4 12:32:31 PDT 2017


On 2017-06-04 19:05, Patrick Schluter wrote:

> buildPath("/usr/bin", "/usr/bin/gcc")
>
> /usr/bin/usr/bin/gcc is obviously wrong.

Says who? It might be exactly what I want. The case that came up is 
inside DStep. The user provides a set of files C header to be translated 
to D modules. The user also provides a flag to indicate where to place 
the resulting files. I wanted to be able to keep the existing directory 
structure of the header files in the new target location. Example:

dstep -o result /usr/include/libxml2/libxml/*.h

The internals of DStep will do something like:

buildPath("result", "/usr/include/libxml2/libxml");

Which currently results in "/usr/include/libxml2/libxml". The end result 
is that DStep will try to write a file to "/usr/include/libxml2/libxml", 
which the user most likely will not have access to (without using sudo). 
I expected the result of buildPath to be 
"result/usr/include/libxml2/libxml".

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list