[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feat : create multiple dir in


Cordialement,

Olivier Cruilles
Mail: olivier.cruilles@xxxxxxxx

you can take a look at this page:  https://gambaswiki.org/edit/comp/gb.util/shell/mkdir

olivier

> Le 4 mai 2026 à 11:20, Alexandre Six <six.alexandre@xxxxxxxxx> a écrit :
> 
> 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
>    Next
> End
> Let me know if you have any suggestions or if there’s a better way to handle this!
> 
> 
> 
> 


Follow-Ups:
Re: Feat : create multiple dir inAlexandre Six <six.alexandre@xxxxxxxxx>
References:
Feat : create multiple dir inAlexandre Six <six.alexandre@xxxxxxxxx>