[API]Creation of folders within the FileIO objects

• Sep 6, 2022 - 23:06
Reported version
3.6
Type
Plugins
Frequency
Once
Severity
S5 - Suggestion
Reproducibility
Always
Status
active
Regression
No
Workaround
No
Project

If a FileIO object has a source file located on a folder that doesn't exist, writing to that file fails.
The request is about having FileIO creating all the necessary folders instead of failing.

FileIO {
    id: testfile
}

testfile.source = "path/to/somewhere/idontexist/foo.txt";
if (!testfile.write("bar")) // --> return false, and the file "foo.txt" does not exist
    console.log("Could not write " + testfile.source);
}

This request comes after the discussion Creating folders from a plugin.

It appears that there is no ways in QML/javascript to create folders (see this question on Stack Overflow).

The current workaround is non platform-agnostic solution that should therefore avoide.

The recommended approach is to delegate these tasks to backend objects.
FIleIO is good candidate for this.