Skip to main content

ensure_dir

Function ensure_dir 

Source
fn ensure_dir(dir: &Path, within: Option<&Path>) -> Result<()>
Expand description

Creates the missing directories of dir, each 0700 at creation and widened to 0755 once it exists, so the mode does not depend on the umask (mkdir applies it to the requested mode: under 077 a 0755 request yields 0700, and scxcli list as a user could not read /usr/share/scx). Directories that already exist are left as they are, whatever their mode: those are the administrator’s.

With within (DESTDIR), the existing prefix is resolved before each missing directory is made under it: pkg/usr/share -> /outside would otherwise get an scx created in /outside before the file itself is refused.