After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 631032 - Docs for g_file_enumerator_next_files_async () are unclear about end condition
Docs for g_file_enumerator_next_files_async () are unclear about end condition
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-09-30 18:00 UTC by Owen Taylor
Modified: 2018-05-24 12:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Owen Taylor 2010-09-30 18:00:43 UTC
The docs for g_file_enumerator_next_files_async() are unclear about how you are supposed to know that you've reached the end of the list of files.

Both Matthias and I read:

 The callback can be called with less than num_files files in case of error or at the end of the enumerator

as saying that a short return means you are at the end, but you actually need to call the function until you get an empty list.

<alex_away> owen: yes, or you can call it again and get NULL
<alex_away> owen: i guess its not quite 100% right to stop on short read
<owen> because?
<alex_away> owen: as you then don't know if your eof or some other error
<alex_away> but, you're unlikely to care
<owen> but if you have some other error, the error is set, right?
<alex_away> No, gio in general don't report a result + an error
<alex_away> like in read() if you read 20 bytes correctly and then get an error we return 20 bytes as a short read, and the error on next read
<alex_away> same with readdir
<owen> Ah, yeah, it says that in the case of error you have to call it again...

Since docs do describe the extra call in the case of error, it's logically possible to figure it out given enough thought. But the section should be rewritten to say something like:

 At the end of the enumerator is reached or an error occurs, the callback
 will be called with an empty list. (In this case, the previous call to
 g_file_enumerator_next_files_async() will frequently have returned less
 than num_files items.)

The short read is a detail, the empty read is the main point, not the other way around.
Comment 1 GNOME Infrastructure Team 2018-05-24 12:47:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/352.