author | Olivier Brunel
<jjk@jjacky.com> 2023-05-30 17:24:21 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-07-05 07:39:26 UTC |
parent | fbd5e246c1a238516152113f2c4ff57396ad0374 |
src/doc/direntry.h.0.md | +3 | -0 |
src/doc/direntry.h/sascandirat.3.md | +8 | -4 |
src/liblimb/include/limb/direntry.h | +1 | -0 |
diff --git a/src/doc/direntry.h.0.md b/src/doc/direntry.h.0.md index bb27378..5f7ac2c 100644 --- a/src/doc/direntry.h.0.md +++ b/src/doc/direntry.h.0.md @@ -35,3 +35,6 @@ The following functions are defined : : [sascandirat](3) :: Scan a directory to fill a *stralloc*. + +: [sascandir](3) +:: Similar to [sascandirat](3) except for relative path. diff --git a/src/doc/direntry.h/sascandirat.3.md b/src/doc/direntry.h/sascandirat.3.md index 0dc0ded..27851cf 100644 --- a/src/doc/direntry.h/sascandirat.3.md +++ b/src/doc/direntry.h/sascandirat.3.md @@ -3,7 +3,7 @@ # NAME -sascandirat - scan a directory to fill a stralloc +sascandirat, sascandir - scan a directory to fill a stralloc # SYNOPSIS @@ -14,6 +14,7 @@ sascandirat - scan a directory to fill a stralloc typedef ssize_t (*sascande) (stralloc *<em>sa</em>, direntry *<em>de</em>, int <em>dirfd</em>) int sascandirat(stralloc *<em>sa</em>, int <em>dirfd</em>, const char *<em>name</em>, sascande <em>fn</em>, size_t *<em>mlen</em>) +int sascandir(stralloc *<em>sa</em>, const char *<em>name</em>, sascande <em>fn</em>, size_t *<em>mlen</em>) ``` # DESCRIPTION @@ -32,12 +33,15 @@ working directory. Once the entire directory has been scanned, if `mlen` is not *NULL* the pointed value will be set to the maximum length returned by `fn`. +The `sascandir`() macro is similar, except when `name` describes a relative +path, in which case it is relative to the current working directory. + # RETURN VALUE -The function returns the number of entries for which data was added into `sa` on -success. Otherwise it returns -1 and sets `errno` to indicate the error. +These functions returns the number of entries for which data was added into `sa` +on success. Otherwise it returns -1 and sets `errno` to indicate the error. # ERRORS -The function may fail and set `errno` for the error described for +These functions may fail and set `errno` for the error described for [opendirat](3), [readdir](3), as well as those set by the function `fn`. diff --git a/src/liblimb/include/limb/direntry.h b/src/liblimb/include/limb/direntry.h index 42157cb..78a308b 100644 --- a/src/liblimb/include/limb/direntry.h +++ b/src/liblimb/include/limb/direntry.h @@ -14,5 +14,6 @@ typedef ssize_t (*sascande) (stralloc *sa, direntry *de, int bfd); extern DIR *opendirat(int bfd, const char *name); extern int sascandirat(stralloc *sa, int bfd, const char *name, sascande fn, size_t *mlen); +#define sascandir(sa,name,fn,mlen) sascandirat(sa, AT_FDCWD, name, fn, mlen) #endif /* LIMB_DIRENTRY_H */