diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2006-07-23 23:10:31 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2006-07-23 23:10:31 +0000 |
commit | af153d343b7267e97965d2954e70a8bb99284c97 (patch) | |
tree | 219b5f002ae43089a7363afdae0f492e6256184b | |
parent | 14eea124f690516c6f07b40f0fa33a23eacfa9ca (diff) | |
download | mpd-af153d343b7267e97965d2954e70a8bb99284c97.tar.gz mpd-af153d343b7267e97965d2954e70a8bb99284c97.tar.xz mpd-af153d343b7267e97965d2954e70a8bb99284c97.zip |
Tidying up code in checkDirectoryDB
git-svn-id: https://svn.musicpd.org/mpd/trunk@4434 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/directory.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/directory.c b/src/directory.c index c30fd23e2..b05428ac2 100644 --- a/src/directory.c +++ b/src/directory.c @@ -1021,39 +1021,37 @@ static void sortDirectory(Directory * directory) int checkDirectoryDB() { - char *dbFile = getDbFile(); - /** - * Check if the file exists - */ + char *dbFile; + char *dirPath; + char *dbPath; + + dbFile = getDbFile(); + + /* Check if the file exists */ if (access(dbFile, F_OK)) { - char *dirPath = NULL; - char *dbPath = strdup(dbFile); + dbPath = strdup(dbFile); - /** - * If the file doesn't exits, 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 - */ + /* 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 */ dirPath = dirname(dbPath); - /** - * Check if we can write to the directory - */ + /* Check if we can write to the directory */ if (access(dirPath, R_OK | W_OK)) { - ERROR("Can't create db file in \"%s\": %s", dirPath, + ERROR("Can't create db file in \"%s\": %s\n", dirPath, strerror(errno)); free(dbPath); return -1; } + free(dbPath); return 0; - } - /** - * File exists, now check if we can write it - */ + + /* File exists, now check if we can write it */ if (access(dbFile, R_OK | W_OK)) { - ERROR("db file \"%s\" cannot be opened for reading/writing: %s", + ERROR("Can't open db file \"%s\" for reading/writing: %s\n", dbFile, strerror(errno)); return -1; } |