Skip to content

<filesystem>: create_directories() should throw for empty paths #1283

@StephanTLavavej

Description

@StephanTLavavej

Reported by Ville Voutilainen:

C:\Temp>type meow.cpp
#include <filesystem>
#include <iostream>
using namespace std;
using namespace std::filesystem;

int main() {
    cout << boolalpha;

    const path p{};

    try {
        const bool result = create_directories(p);

        cout << "create_directories returned " << result << ".\n";
    } catch (const filesystem_error& e) {
        cout << "create_directories threw " << e.what() << ".\n";
    }
}
C:\Temp>cl /EHsc /nologo /W4 /std:c++17 /MTd meow.cpp && meow
meow.cpp
create_directories returned false.

This behavior differs from libstdc++ on Compiler Explorer:

create_directories threw filesystem error: cannot create directories: Invalid argument [].

And from libc++ on Compiler Explorer:

create_directories threw filesystem error: in create_directory: No such file or directory [""].

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions