[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Feat : create multiple dir in
[Thread Prev] | [Thread Next]
- Subject: Feat : create multiple dir in
- From: Alexandre Six <six.alexandre@xxxxxxxxx>
- Date: Mon, 4 May 2026 17:20:59 +0200
- To: Gambas mailing list <user@xxxxxxxxxxxxxxxxxxxxxx>
Hi all, Is there a built-in way in Gambas to create multiple directories (including parent directories) if they don’t exist, similar to Python’s os.makedirs()? I searched the Gambas repository but couldn’t find such a function. I assume it’s based on the C mkdir() function. Could we use C++17’s std::filesystem::create_directories for this purpose? Alternatively, we could use the shell command mkdir -p, though that might be less optimal. It’s not a critical issue, but it could be useful for some use cases, don’t you think? For now, I’ve written my own function in Gambas: Private Function CreateDirectoriesIfNotExists(path As String) Dim tree As String[] Dim folder As String Dim i As Integer Dim progressivePath As String = "/" tree = Split(path, "/") For i = 1 To tree.Count - 2 ' First element is empty, last is the filename, so we skip them progressivePath = progressivePath & tree[i] & "/" Try Mkdir progressivePath If Error Then Print "Folder: " & progressivePath & " already exists" ' TODO: add logging here Endif NextEnd Let me know if you have any suggestions or if there’s a better way to handle this!