Commit efbf184f authored by Max Kellermann's avatar Max Kellermann

PlaylistFile, client_file, tag_id3: don't use g_file_error_quark()

g_file_error_quark() is meant to be used with the GFileError enum which does not correspond with errno, but must be converted with g_file_error_from_errno(). At the same time, this removes g_strerror() use for g_file_error_quark().
parent dd577fb8
......@@ -295,6 +295,7 @@ src_mpd_SOURCES = \
src/listen.c \
src/log.c \
src/ls.c \
src/io_error.h \
src/io_thread.c src/io_thread.h \
src/Main.cxx src/Main.hxx \
src/Win32Main.cxx \
......
......@@ -20,6 +20,7 @@
#include "config.h"
#include "CommandError.hxx"
#include "db_error.h"
#include "io_error.h"
extern "C" {
#include "protocol/result.h"
......@@ -119,11 +120,15 @@ print_error(struct client *client, GError *error)
command_error(client, ACK_ERROR_NO_EXIST, "Not found");
return COMMAND_RETURN_ERROR;
}
} else if (error->domain == g_file_error_quark()) {
} else if (error->domain == errno_quark()) {
command_error(client, ACK_ERROR_SYSTEM, "%s",
g_strerror(error->code));
g_error_free(error);
return COMMAND_RETURN_ERROR;
} else if (error->domain == g_file_error_quark()) {
command_error(client, ACK_ERROR_SYSTEM, "%s", error->message);
g_error_free(error);
return COMMAND_RETURN_ERROR;
}
g_error_free(error);
......
......@@ -21,6 +21,7 @@
#include "PlaylistFile.hxx"
#include "PlaylistSave.hxx"
#include "song.h"
#include "io_error.h"
extern "C" {
#include "text_file.h"
......@@ -132,8 +133,7 @@ playlist_errno(GError **error_r)
break;
default:
g_set_error_literal(error_r, g_file_error_quark(), errno,
g_strerror(errno));
set_error_errno(error_r);
break;
}
}
......@@ -181,8 +181,7 @@ ListPlaylistFiles(GError **error_r)
DIR *dir = opendir(parent_path_fs);
if (dir == NULL) {
g_set_error_literal(error_r, g_file_error_quark(), errno,
g_strerror(errno));
set_error_errno(error_r);
return list;
}
......
......@@ -20,6 +20,7 @@
#include "client_file.h"
#include "client.h"
#include "ack.h"
#include "io_error.h"
#include <sys/stat.h>
#include <sys/types.h>
......@@ -53,8 +54,7 @@ client_allow_file(const struct client *client, const char *path_fs,
struct stat st;
if (stat(path_fs, &st) < 0) {
g_set_error(error_r, g_file_error_quark(), errno,
"%s", g_strerror(errno));
set_error_errno(error_r);
return false;
}
......
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_IO_ERROR_H
#define MPD_IO_ERROR_H
#include <glib.h>
#include <errno.h>
/**
* A GQuark for GError for I/O errors. The code is an errno value.
*/
G_GNUC_CONST
static inline GQuark
errno_quark(void)
{
return g_quark_from_static_string("errno");
}
static inline void
set_error_errno(GError **error_r)
{
g_set_error_literal(error_r, errno_quark(), errno,
g_strerror(errno));
}
#endif
......@@ -25,6 +25,7 @@
#include "riff.h"
#include "aiff.h"
#include "conf.h"
#include "io_error.h"
#include <glib.h>
#include <id3tag.h>
......@@ -546,7 +547,7 @@ tag_id3_load(const char *path_fs, GError **error_r)
{
FILE *file = fopen(path_fs, "rb");
if (file == NULL) {
g_set_error(error_r, g_file_error_quark(), errno,
g_set_error(error_r, errno_quark(), errno,
"Failed to open file %s: %s",
path_fs, g_strerror(errno));
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment