diff options
author | Simon McVittie <smcv@collabora.com> | 2021-04-22 15:40:51 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-04-22 15:59:05 +0100 |
commit | a0750a00b1b2282c9db6becf9a9664e509c84ba3 (patch) | |
tree | 561b542a9344c0805b258efed0a7944ee9c1cd9b /glnx-dirfd.c | |
parent | 4c9055ac08bb64dca146724f488cce4c1ce4c628 (diff) | |
download | libglnx-wip/smcv/rewinddir.tar.gz |
glnx-dirfd: Add a rewinddir() wrapperwip/smcv/rewinddir
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: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'glnx-dirfd.c')
-rw-r--r-- | glnx-dirfd.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/glnx-dirfd.c b/glnx-dirfd.c index 6d1e2d2..0a63bcb 100644 --- a/glnx-dirfd.c +++ b/glnx-dirfd.c @@ -174,6 +174,24 @@ glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter, } /** + * 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 * @out_dent: (out) (transfer none): Pointer to dirent; do not free |