How to list files in a directory using wildcards?

I am browsing the Gio docs but I cannot find a way to list all *.conf files in a directory.

There isn’t. You can only enumerate all files and match on the filename (for example with g_str_has_suffix() or g_pattern_spec_match_string())

1 Like

Ok. But, how do you enumerate the files in the first place?

Envoyé depuis Proton Mail mobile

-------- Message d’origine --------

You can use the low level GDir API, which is mainly a portable layer on top of readdir. Or you can use GFileEnumerator.

1 Like

Also note we have a number of GJS-specific guides for topics like file management, most of which should demonstrate “best practices”.

Using asynchronous operations for files is pretty important, especially if this is going to be used in a shell extension. Performing blocking I/O in an extension will almost certainly result in it not passing review.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.