pkgtools

morpheus pkg tools
git clone git://git.2f30.org/pkgtools
Log | Files | Refs | README | LICENSE

commit 01dc894209e7c7a486fb28e134a148f1d0d0b0fa
parent 3cec1e4924580621e9627a6a0da97734b1356498
Author: sin <sin@2f30.org>
Date:   Fri, 30 May 2014 14:25:28 +0100

Use rewinddir(dir);

Diffstat:
Mremovepkg.c | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/removepkg.c b/removepkg.c @@ -60,17 +60,17 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } + dir = opendir("var/pkg"); + if (!dir) { + fprintf(stderr, "opendir %s: %s\n", "var/pkg", + strerror(errno)); + return EXIT_FAILURE; + } + for (i = 0; i < argc; i++) { strlcpy(filename, argv[i], sizeof(filename)); found = 0; - dir = opendir("var/pkg"); - if (!dir) { - fprintf(stderr, "opendir %s: %s\n", "var/pkg", - strerror(errno)); - return EXIT_FAILURE; - } - while ((dp = readdir(dir))) { if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) @@ -82,13 +82,16 @@ main(int argc, char *argv[]) break; } } - - closedir(dir); if (found == 0) { fprintf(stderr, "package %s not installed\n", argv[i]); return EXIT_FAILURE; } + + rewinddir(dir); } + + closedir(dir); + return EXIT_SUCCESS; }