Introduce xbps_binpkg_get_file_into_fd() and use it for xbps-query(8) --cat.

This allows you to print to stdout any file stored in a binary package,
locally or remotely!

$ xbps-query -R --cat=/usr/bin/ls coreutils > ls
$ file ls
ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=7a195fc46d1d5cdca32bfccd3b30f81784e342ed, stripped
$
This commit is contained in:
Juan RP
2014-11-17 18:43:08 +01:00
parent db14524cf3
commit 77c6c3e504
3 changed files with 52 additions and 9 deletions

View File

@@ -48,7 +48,7 @@
*
* This header documents the full API for the XBPS Library.
*/
#define XBPS_API_VERSION "20141117"
#define XBPS_API_VERSION "20141117-1"
#ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET"
@@ -1141,6 +1141,20 @@ int xbps_transaction_commit(struct xbps_handle *xhp);
* and errno is set appropiately.
*/
char *xbps_binpkg_get_file(const char *url, const char *fname);
/**
* Returns a file stored in a binary package locally or
* remotely as specified in the url \a url and stores it into the
* file descriptor \a fd.
*
* @param[in] url Full URL to binary package file (local or remote path).
* @param[in] fname File name to match.
* @param[in] fd An open file descriptor to put the file into.
*
* @return 0 on success, an errno value otherwise.
*/
int xbps_binpkg_get_file_into_fd(const char *url, const char *fname, int fd);
/**
* Internalizes a plist file in a binary package file stored locally or
* remotely as specified in the url \a url.