2 * libdpkg - Debian packaging suite library routines
3 * dbdir.c - on-disk database directory functions
5 * Copyright © 2011 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 #include <sys/types.h>
28 #include <dpkg/dpkg.h>
29 #include <dpkg/dpkg-db.h>
31 static const char *db_dir
= ADMINDIR
;
34 * Set current on-disk database directory.
36 * The directory is initially set to ADMINDIR, this function can be used to
37 * set the directory to a new value, or to set it to a default value if dir
38 * is NULL. For the latter the order is, value from environment variable
39 * DPKG_ADMINDIR, and then the built-in default ADMINDIR,
41 * @param dir The new database directory, or NULL to set to default.
43 * @return The new database directory.
46 dpkg_db_set_dir(const char *dir
)
51 env
= getenv("DPKG_ADMINDIR");
64 * Get current on-disk database directory.
66 * @return The current database directory.
75 * Get a pathname to the current on-disk database directory.
77 * This function returns an allocated string, which should be freed with
80 * @param pathpart The pathpart to append to the new pathname.
82 * @return The newly allocated pathname.
85 dpkg_db_get_path(const char *pathpart
)
87 return str_fmt("%s/%s", db_dir
, pathpart
);