aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-01-03 07:22:22 +0000
committerEric Wong <normalperson@yhbt.net>2008-01-03 07:22:22 +0000
commit790e70cf25ade17e7412b153c440ef4999fe72fd (patch)
tree4ce5ce8047a91c4105796e6bbc9abb9c9e3ce085 /src
parentb1cdf8dadf7487d81262f2c4ab76abb378648381 (diff)
downloadmpd-790e70cf25ade17e7412b153c440ef4999fe72fd.tar.gz
mpd-790e70cf25ade17e7412b153c440ef4999fe72fd.tar.xz
mpd-790e70cf25ade17e7412b153c440ef4999fe72fd.zip
directory.c: get rid of the horrid dirname(3) and libgen.h dependency
Ok, so basename(3) is even more brain-damaged, inconsistent and/or broken than dirname(3) on most systems, but there are broken implementations of it out there. Just use our already existing internal parent_path() function instead and get rid of the only place where we look for libgen.h. git-svn-id: https://svn.musicpd.org/mpd/trunk@7129 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/directory.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/directory.c b/src/directory.c
index b706b4208..45e583d2d 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -41,7 +41,6 @@
#include <dirent.h>
#include <errno.h>
#include <assert.h>
-#include <libgen.h>
#define DIRECTORY_DIR "directory: "
#define DIRECTORY_MTIME "mtime: "
@@ -988,32 +987,26 @@ static void sortDirectory(Directory * directory)
int checkDirectoryDB(void)
{
struct stat st;
- char *dbFile;
- char *dirPath;
- char *dbPath;
-
- dbFile = getDbFile();
+ char *dbFile = getDbFile();
/* Check if the file exists */
if (access(dbFile, F_OK)) {
/* If the file doesn't exist, we can't check if we can write
* it, so we are going to try to get the directory path, and
* see if we can write a file in that */
- dbPath = xstrdup(dbFile);
- dirPath = dirname(dbPath);
+ char dirPath[MPD_PATH_MAX];
+ parent_path(dirPath, dbFile);
/* Check that the parent part of the path is a directory */
if (stat(dirPath, &st) < 0) {
ERROR("Couldn't stat parent directory of db file "
"\"%s\": %s\n", dbFile, strerror(errno));
- free(dbPath);
return -1;
}
if (!S_ISDIR(st.st_mode)) {
ERROR("Couldn't create db file \"%s\" because the "
"parent path is not a directory\n", dbFile);
- free(dbPath);
return -1;
}
@@ -1021,12 +1014,9 @@ int checkDirectoryDB(void)
if (access(dirPath, R_OK | W_OK)) {
ERROR("Can't create db file in \"%s\": %s\n", dirPath,
strerror(errno));
- free(dbPath);
return -1;
-
}
- free(dbPath);
return 0;
}