xbps_init() now sets rootdir, cachedir and flags.

That means that the following functions were removed:
	- xbps_set_{cachedir,flags,rootdir}.
	- xbps_get_{cachedir,flags,rootdir}.

With this change fixed an obvious typo that made -c argument to not work,
and now the cache directory is an absolute path not relative to rootdir.
This commit is contained in:
Juan RP
2011-02-21 17:42:47 +01:00
parent 8d5a1ad0a3
commit 870ad18d58
30 changed files with 195 additions and 227 deletions

View File

@ -37,15 +37,20 @@
#include <sys/stat.h>
#include <xbps_api.h>
#include "xbps_api_impl.h"
int
xbps_mkpath(char *path, mode_t mode)
xbps_mkpath(const char *path, mode_t mode)
{
struct stat sb;
char *slash = path;
char *ppath, *slash;
int done = 0, rv;
mode_t dir_mode;
if ((ppath = strdup(path)) == NULL)
return -1;
slash = ppath;
/*
* The default file mode is a=rwx (0777) with selected permissions
* removed in accordance with the file mode creation mask. For
@ -64,7 +69,7 @@ xbps_mkpath(char *path, mode_t mode)
done = (*slash == '\0');
*slash = '\0';
rv = mkdir(path, done ? mode : dir_mode);
rv = mkdir(ppath, done ? mode : dir_mode);
if (rv < 0) {
/*
* Can't create; path exists or no perms.
@ -73,14 +78,16 @@ xbps_mkpath(char *path, mode_t mode)
int sverrno;
sverrno = errno;
if (stat(path, &sb) < 0) {
if (stat(ppath, &sb) < 0) {
/* Not there; use mkdir()s error */
errno = sverrno;
free(ppath);
return -1;
}
if (!S_ISDIR(sb.st_mode)) {
/* Is there, but isn't a directory */
errno = ENOTDIR;
free(ppath);
return -1;
}
}
@ -89,6 +96,7 @@ xbps_mkpath(char *path, mode_t mode)
*slash = '/';
}
free(ppath);
return 0;
}