[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feat : create multiple dir in
[Thread Prev] | [Thread Next]
- Subject: Re: Feat : create multiple dir in
- From: Alexandre Six <six.alexandre@xxxxxxxxx>
- Date: Mon, 4 May 2026 21:08:39 +0200
- To: user@xxxxxxxxxxxxxxxxxxxxxx
- Cc: Olivier Cruilles <olivier.cruilles@xxxxxxxx>
Hi Olivier, Thanks a lot, that is exactly what I was looking for. Have a nice evening. Le lun. 4 mai 2026 à 17:33, Olivier Cruilles <olivier.cruilles@xxxxxxxx> a écrit : > > 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! > > > > > >
| Feat : create multiple dir in | Alexandre Six <six.alexandre@xxxxxxxxx> |
| Re: Feat : create multiple dir in | Olivier Cruilles <olivier.cruilles@xxxxxxxx> |