Page MenuHomeFeedback Tracker

MakeDirectory is not recursive
New, UrgentPublic

Description

Using CreateDirectory does not recursively create parent directories if they do not exists.

For instance, this fails to create any directory:

string path = "$Profile:/Parent/Child/Grandchild";
CreateDirectory(path);

I would expect it to create each directory if the parent does not exist.

C:\PROGRAM FILES (X86)\STEAM\STEAMAPPS\COMMON\DAYZSERVER\SERVERPROFILE\
└───Parent
    └───Child
        └───Grandchild

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Additional Information

I've gone ahead and made a work around for the time being, but with most languages, creating a directory is usually recursive natively.

bool MakeDirectoryRecursive(string path)
{
    auto str = new array<string>();
    bool success = true;

    path.Replace("\\", "/");
    path.Split("/", str);

    string dir = str[0];
    for (int i = 1; i < str.Count(); i++)
    {
        if (!success) break;
        string s = str.Get(i);

        dir += "/" + s;
        if (!s.Contains("."))
            success = MakeDirectory(dir);
    }

    delete str;
    return success;
}

Event Timeline

OfficialWardog edited Additional Information. (Show Details)Oct 11 2019, 7:28 PM
OfficialWardog edited Additional Information. (Show Details)Oct 11 2019, 7:57 PM