return r;
}
-static int pakfire_archive_try_open(struct pakfire_archive* archive) {
- int r;
-
- CTX_DEBUG(archive->ctx, "Opening archive %s\n", archive->path);
-
- // Open the file (and keep the file descriptor open)
- archive->f = fopen(archive->path, "r");
- if (!archive->f)
- return -errno;
-
- // Let the kernel know, that we will read the file sequentially
- r = posix_fadvise(fileno(archive->f), 0, 0, POSIX_FADV_SEQUENTIAL);
- if (r)
- CTX_DEBUG(archive->ctx, "posix_fadvise() failed. Ignoring: %m\n");
-
- // Call stat() on f
- r = fstat(fileno(archive->f), &archive->stat);
- if (r) {
- CTX_ERROR(archive->ctx, "Could not stat archive: %m\n");
- return -errno;
- }
-
- // Read all package metadata
- return pakfire_archive_read_metadata(archive);
-}
-
PAKFIRE_EXPORT int pakfire_archive_open(struct pakfire_archive** archive,
struct pakfire* pakfire, const char* path) {
struct pakfire_archive* a = NULL;
if (r < 0)
goto ERROR;
- // Try to open the archive
- r = pakfire_archive_try_open(a);
+ CTX_DEBUG(a->ctx, "Opening archive %s\n", a->path);
+
+ // Open the file (and keep the file descriptor open)
+ a->f = fopen(a->path, "r");
+ if (!a->f) {
+ CTX_ERROR(a->ctx, "Could not open archive %s: %m\n", a->path);
+ r = -errno;
+ goto ERROR;
+ }
+
+ // Call stat() on f
+ r = fstat(fileno(a->f), &a->stat);
+ if (r < 0) {
+ CTX_ERROR(a->ctx, "Could not stat archive %s: %m\n", a->path);
+ r = -errno;
+ goto ERROR;
+ }
+
+ // Read all package metadata
+ r = pakfire_archive_read_metadata(a);
if (r < 0)
goto ERROR;