Thank you Victor! I have written a recursive function to read all the
directories and files.
#include <gtk/gtk.h>
void read_all_files(const gchar* file) {
GDir *dir = g_dir_open(file, 0, NULL);
while ((file = g_dir_read_name(dir))) {
if (!g_file_test(file, G_FILE_TEST_IS_DIR)) {
g_print("%s was opened\n", file);
}
else {
read_all_files(file);
}
}
}
However, it seems that this function still only reads the 1st level of
subdirectory and print out all the files there and not reading any file at
2nd, 3rd, 4th, etc... levels. Do you have any suggestion on how to improve
this function so that it will import every single file and all subfolders
nested deeply inside the main folder?
On Mon, Jun 6, 2011 at 8:00 AM, <[email protected]> wrote:
> Send gtk-list mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.gnome.org/mailman/listinfo/gtk-list
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gtk-list digest..."
>
>
> Today's Topics:
>
> 1. GtkFileChooser: How to get names of files that are inside
> subfolders? (Phong Cao)
> 2. Re: GtkFileChooser: How to get names of files that are inside
> subfolders? (Victor Ananjevsky)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 6 Jun 2011 01:29:17 -0400
> From: Phong Cao <[email protected]>
> To: [email protected], [email protected]
> Subject: GtkFileChooser: How to get names of files that are inside
> subfolders?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello everybody,
>
> I am trying to develop a music manager that lets the users import all audio
> files from a folder. That folder may contain many subfolders, and each
> subfolder may contain many files. I know that I need to create a
> GtkFileChooser Dialog with GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER enabled so
> that the user can choose folders instead of files.
>
> However, I do not know how to make this GtkFileChooser selects/imports all
> the files available in that directory (not only the files that are shown in
> the GtkFileChooser but the files that are deeply contained inside
> subfolders).
>
> Thank you for reading my questions! I hope you guys have a good day!
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.gnome.org/archives/gtk-list/attachments/20110606/73db2c97/attachment.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Mon, 6 Jun 2011 08:47:02 +0300
> From: Victor Ananjevsky <[email protected]>
> To: [email protected]
> Subject: Re: GtkFileChooser: How to get names of files that are inside
> subfolders?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=US-ASCII
>
> On Mon, 6 Jun 2011 01:29:17 -0400
> Phong Cao <[email protected]> wrote:
>
> > Hello everybody,
> >
> > I am trying to develop a music manager that lets the users import all
> audio
> > files from a folder. That folder may contain many subfolders, and each
> > subfolder may contain many files. I know that I need to create a
> > GtkFileChooser Dialog with GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER enabled
> so
> > that the user can choose folders instead of files.
> >
> > However, I do not know how to make this GtkFileChooser selects/imports
> all
> > the files available in that directory (not only the files that are shown
> in
> > the GtkFileChooser but the files that are deeply contained inside
> > subfolders).
>
> g_dir_open()/g_dir_read_name()/g_dir_close() + recursion
>
>
> >
> > Thank you for reading my questions! I hope you guys have a good day!
>
>
> --
> Victor Ananjevsky <[email protected]>
>
>
> ------------------------------
>
> _______________________________________________
> gtk-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>
> End of gtk-list Digest, Vol 86, Issue 9
> ***************************************
>
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list