summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-27 21:06:45 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-27 21:06:45 +0200
commita96572fba84573e81f6b363f1aee0243c7829729 (patch)
treee43c0e8729b0ab3c5625b9a96fca35839974b65c /src
parentf0609951b9fd2938c0f30853e0aa6b08b8698a88 (diff)
downloadapk-tools-a96572fba84573e81f6b363f1aee0243c7829729.tar.gz
apk-tools-a96572fba84573e81f6b363f1aee0243c7829729.tar.bz2
apk-tools-a96572fba84573e81f6b363f1aee0243c7829729.tar.xz
apk-tools-a96572fba84573e81f6b363f1aee0243c7829729.zip
db: compressed index file
Diffstat (limited to 'src')
-rw-r--r--src/apk_archive.h1
-rw-r--r--src/apk_io.h4
-rw-r--r--src/database.c4
-rw-r--r--src/io.c12
4 files changed, 18 insertions, 3 deletions
diff --git a/src/apk_archive.h b/src/apk_archive.h
index ac2387f..0b280fc 100644
--- a/src/apk_archive.h
+++ b/src/apk_archive.h
@@ -21,7 +21,6 @@ typedef int (*apk_archive_entry_parser)(void *ctx,
struct apk_istream *istream);
int apk_file_get_info(const char *filename, struct apk_file_info *fi);
-struct apk_istream *apk_gunzip_bstream(struct apk_bstream *);
int apk_parse_tar(struct apk_istream *, apk_archive_entry_parser parser, void *ctx);
int apk_parse_tar_gz(struct apk_bstream *, apk_archive_entry_parser parser, void *ctx);
diff --git a/src/apk_io.h b/src/apk_io.h
index f0b06e1..96dc7c9 100644
--- a/src/apk_io.h
+++ b/src/apk_io.h
@@ -38,6 +38,8 @@ struct apk_bstream {
void (*close)(void *stream, csum_p csum);
};
+struct apk_istream *apk_gunzip_bstream(struct apk_bstream *);
+
struct apk_istream *apk_istream_from_fd(int fd);
struct apk_istream *apk_istream_from_file(const char *file);
size_t apk_istream_skip(struct apk_istream *istream, size_t size);
@@ -46,6 +48,8 @@ size_t apk_istream_splice(void *stream, int fd, size_t size);
struct apk_bstream *apk_bstream_from_istream(struct apk_istream *istream);
struct apk_bstream *apk_bstream_from_fd(int fd);
+struct apk_istream *apk_istream_from_file_gz(const char *file);
+
apk_blob_t apk_blob_from_istream(struct apk_istream *istream, size_t size);
apk_blob_t apk_blob_from_file(const char *file);
diff --git a/src/database.c b/src/database.c
index 0795a0b..13fc7b9 100644
--- a/src/database.c
+++ b/src/database.c
@@ -670,8 +670,8 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
.url = apk_blob_cstr(repository)
};
- snprintf(tmp, sizeof(tmp), "%s/APK_INDEX", db->repos[r].url);
- is = apk_istream_from_file(tmp);
+ snprintf(tmp, sizeof(tmp), "%s/APK_INDEX.gz", db->repos[r].url);
+ is = apk_istream_from_file_gz(tmp);
if (is == NULL) {
apk_error("Failed to open index file %s", tmp);
return -1;
diff --git a/src/io.c b/src/io.c
index 84b556b..e4dfd33 100644
--- a/src/io.c
+++ b/src/io.c
@@ -362,3 +362,15 @@ int apk_file_get_info(const char *filename, struct apk_file_info *fi)
return 0;
}
+
+struct apk_istream *apk_istream_from_file_gz(const char *file)
+{
+ int fd;
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+
+ return apk_gunzip_bstream(apk_bstream_from_fd(fd));
+}
+