Documentation Correction?

I think this should comply with rules, but just let me know if not. When I was getting helped on my first question one reference was to a good doc page: create_dir_all in std::fs - Rust. And first thing I was reminded, as I saw this in another version of the page, is that the assertion:

".. This function currently corresponds to the mkdir function on Unix.." is incorrect, in that specifically in Unix it corresponds to mkdir -p. mkdir alone will not work with something like /a/b/c if b does not yet exist, but mkdir -p will (in Unix). This "create_dir_all() command is exactly what I was looking for, as it is, at least for me on linux behaving like mkdir -p. Thank you. Please let me know if this is an incorrect context for this post.

1 Like

The documentation is referring to the mkdir function from libc, which is different from the mkdir command.

1 Like

The mkdir function is not recursive either. It returns an error if a parent does not exist.

ENOENT
A component of the path prefix specified by path does not name an existing directory or path is an empty string.

The same appears to be true for CreateDirectory on Windows.

ERROR_PATH_NOT_FOUND
One or more intermediate directories do not exist; this function will only create the final directory in the path.

Perhaps the docs should change This function currently corresponds to the... to This function currently corresponds to repeated applications of the...?

1 Like

Yes, but in shell "mkdir -p" is recursive, just like the create_dir_all function. Sorry if I did not state this clearly.