Skip to content
Snippets Groups Projects
Commit e44195b4 authored by Simon McVittie's avatar Simon McVittie
Browse files

glnx-dirfd: Add a rewinddir() wrapper


This is useful in the same situations rewinddir() is. My use-case right
now is to remove some of the files from a directory, then go back through
the directory removing symlinks that pointed to those files.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
Forwarded: https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/25
parent 9c1a2712
No related branches found
No related tags found
1 merge request!301pv-runtime: Avoid opening libraries to determine their SONAME
......@@ -173,6 +173,24 @@ glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter,
return TRUE;
}
/**
* glnx_dirfd_iterator_rewind:
* @dfd_iter: A directory iterator
*
* Rewind to the beginning of @dfd_iter. The next call to
* glnx_dirfd_iterator_next_dent() will provide the first entry in the
* directory.
*/
void
glnx_dirfd_iterator_rewind (GLnxDirFdIterator *dfd_iter)
{
GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
g_return_if_fail (dfd_iter->initialized);
rewinddir (real_dfd_iter->d);
}
/**
* glnx_dirfd_iterator_next_dent_ensure_dtype:
* @dfd_iter: A directory iterator
......
......@@ -66,6 +66,7 @@ gboolean glnx_dirfd_iterator_next_dent_ensure_dtype (GLnxDirFdIterator *dfd_ite
struct dirent **out_dent,
GCancellable *cancellable,
GError **error);
void glnx_dirfd_iterator_rewind (GLnxDirFdIterator *dfd_iter);
void glnx_dirfd_iterator_clear (GLnxDirFdIterator *dfd_iter);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxDirFdIterator, glnx_dirfd_iterator_clear)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment