Use xbps_get_root() directly where appropiate.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091027111547-tb38qz51ejakn3jc
This commit is contained in:
Juan RP
2009-10-27 12:15:47 +01:00
parent ac897c8383
commit dc258f4e20
11 changed files with 31 additions and 61 deletions

View File

@@ -101,7 +101,6 @@ xbps_prepare_repolist_data(void)
prop_object_t obj;
prop_object_iterator_t iter;
struct repository_data *rdata;
const char *rootdir;
char *plist;
int rv = 0;
static bool repodata_initialized;
@@ -111,11 +110,7 @@ xbps_prepare_repolist_data(void)
SIMPLEQ_INIT(&repodata_queue);
rootdir = xbps_get_rootdir();
if (rootdir == NULL)
rootdir = "";
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REPOLIST);
if (plist == NULL) {
rv = EINVAL;

View File

@@ -71,14 +71,12 @@ xbps_callback_array_iter_in_repolist(int (*fn)(prop_object_t, void *, bool *),
void *arg)
{
prop_dictionary_t repolistd;
const char *rootdir;
char *plist;
int rv = 0;
assert(fn != NULL);
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REPOLIST);
if (plist == NULL)
return EINVAL;
@@ -244,12 +242,10 @@ xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
prop_dictionary_t SYMEXPORT
xbps_prepare_regpkgdb_dict(void)
{
const char *rootdir;
char *plist;
if (regpkgdb_initialized == false) {
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return NULL;

View File

@@ -78,13 +78,12 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
prop_array_t array;
prop_object_t obj;
prop_object_iterator_t iter;
const char *rootdir, *file, *sha256;
const char *file, *sha256;
char *path;
int rv = 0, flags;
pkg_state_t state = 0;
assert(pkgname != NULL);
rootdir = xbps_get_rootdir();
flags = xbps_get_flags();
if (check_state) {
@@ -102,8 +101,8 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
* Iterate over the pkg file list dictionary and remove all
* unmodified configuration files.
*/
path = xbps_xasprintf("%s/%s/metadata/%s/%s",
rootdir, XBPS_META_PATH, pkgname, XBPS_PKGFILES);
path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
if (path == NULL)
return errno;
@@ -134,7 +133,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
prop_object_release(dict);
return EINVAL;
}
path = xbps_xasprintf("%s/%s", rootdir, file);
path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file);
if (path == NULL) {
prop_object_iterator_release(iter);
prop_object_release(dict);
@@ -191,16 +190,14 @@ remove_pkg_metadata(const char *pkgname)
{
struct dirent *dp;
DIR *dirp;
const char *rootdir;
char *metadir, *path;
int flags = 0, rv = 0;
assert(pkgname != NULL);
rootdir = xbps_get_rootdir();
flags = xbps_get_flags();
metadir = xbps_xasprintf("%s/%s/metadata/%s", rootdir,
metadir = xbps_xasprintf("%s/%s/metadata/%s", xbps_get_rootdir(),
XBPS_META_PATH, pkgname);
if (metadir == NULL)
return errno;

View File

@@ -35,12 +35,11 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
{
prop_dictionary_t dict, pkgd;
prop_array_t array;
const char *pkgname, *version, *desc, *rootdir;
const char *pkgname, *version, *desc;
char *plist;
int rv = 0;
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return EINVAL;
@@ -95,14 +94,12 @@ out:
int SYMEXPORT
xbps_unregister_pkg(const char *pkgname)
{
const char *rootdir;
char *plist;
int rv = 0;
assert(pkgname != NULL);
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return EINVAL;

View File

@@ -41,11 +41,10 @@ remove_pkg_files(prop_dictionary_t dict)
prop_object_iterator_t iter;
prop_object_t obj;
prop_bool_t bobj;
const char *file, *rootdir, *sha256;
const char *file, *sha256;
char *path = NULL;
int flags = 0, rv = 0;
rootdir = xbps_get_rootdir();
flags = xbps_get_flags();
/* Links */
@@ -62,7 +61,7 @@ remove_pkg_files(prop_dictionary_t dict)
prop_object_iterator_release(iter);
return EINVAL;
}
path = xbps_xasprintf("%s/%s", rootdir, file);
path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file);
if (path == NULL) {
prop_object_iterator_release(iter);
return EINVAL;
@@ -97,7 +96,7 @@ files:
prop_object_iterator_release(iter);
return EINVAL;
}
path = xbps_xasprintf("%s/%s", rootdir, file);
path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file);
if (path == NULL) {
prop_object_iterator_release(iter);
return EINVAL;
@@ -155,7 +154,7 @@ dirs:
prop_object_iterator_release(iter);
return EINVAL;
}
path = xbps_xasprintf("%s/%s", rootdir, file);
path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file);
if (path == NULL) {
prop_object_iterator_release(iter);
return EINVAL;

View File

@@ -36,14 +36,12 @@ xbps_register_repository(const char *uri)
prop_dictionary_t dict;
prop_array_t array;
prop_object_t obj = NULL;
const char *rootdir;
char *plist;
int rv = 0;
assert(uri != NULL);
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REPOLIST);
if (plist == NULL)
return errno;
@@ -113,14 +111,12 @@ xbps_unregister_repository(const char *uri)
{
prop_dictionary_t dict;
prop_array_t array;
const char *rootdir;
char *plist;
int rv = 0;
assert(uri != NULL);
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REPOLIST);
if (plist == NULL)
return errno;

View File

@@ -120,12 +120,10 @@ int SYMEXPORT
xbps_requiredby_pkg_remove(const char *pkgname)
{
prop_dictionary_t dict;
const char *rootdir;
char *plist;
int rv = 0;
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return EINVAL;

View File

@@ -96,12 +96,10 @@ int SYMEXPORT
xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state)
{
prop_dictionary_t dict, pkgd;
const char *rootdir;
char *plist;
assert(pkgname != NULL);
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return errno;
@@ -152,13 +150,11 @@ xbps_set_pkg_state_installed(const char *pkgname, pkg_state_t state)
{
prop_dictionary_t dict, pkgd;
prop_array_t array;
const char *rootdir;
char *plist;
int rv = 0;
bool newpkg = false;
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return EINVAL;