[Toybox] mkpathat() behavior

Rob Landley rob at landley.net
Wed May 7 09:58:01 PDT 2014


On 05/07/14 04:52, Ashwini Sharma wrote:
> Hi Rob, list,
>
> __mkpathat()__ function doesn't create the last component in the given path
> if (flags & 1) == 0, e.g. input path is "a/b/c" and flags = 2, then __a__
> and __b__ are created but __c__ isn't.
 
That's right. If you have a path to a directory and want to create the
entire thing, use flags = 3. 

If you have a path to a file and just want to create the directory leading 
up to that file (or confirm it exists and is a directory), use flags = 2.

If you want to use it as just "mkdir", flags = 1.

Then add the verbose flag if you want it to say what it's doing.

> Is it expecting the filename also in the path component, to make the path
> recursively.

If it's a path to a file, yes. If it's not a path to a file, feed it just
the path and use flags=3.

> I guess it shouldn't otherwise it defies the purpose of mkpathat().

I don't understand. Could you explain your use case?

Mostly likely I didn't document it well enough, but I may be missing
something...

> regards,
> Ashwini

Rob

 1399481881.0


More information about the Toybox mailing list