Skip to content

mkdir() rejects an empty path, and nothing says so #42

Description

@skipbit

path::mkdir(std::string{}) fails. A test pins that it does — an empty path must not be folded into the "already exists" success case — but no page or comment states it, so the only place the behaviour is written down is the test.

The reason it was left out until now is that the outcome rests on what std::filesystem::create_directories puts in the error_code for an empty path, which the standard does not specify. Measuring it under one standard library was not enough to write it as a contract.

That has changed: the suite now runs under libstdc++ and libc++ on Linux, and under Apple's libc++ on macOS, and the test passes on all of them. Two independent implementations agree that the call fails.

What can be written is the intent, not the mechanism — that an empty path is not accepted as an existing directory and comes back as a failure — without naming a specific errc, which is still implementation-defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions