1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
30 * @short_description: Error helper functions
33 * Contains helper functions for reporting errors to the user.
39 * Gets the GIO Error Quark.
41 * Return value: a #GQuark.
44 g_io_error_quark (void)
46 return g_quark_from_static_string ("g-io-error-quark");
50 * g_io_error_from_errno:
51 * @err_no: Error number as defined in errno.h.
53 * Converts errno.h error codes into GIO error codes.
55 * Returns: #GIOErrorEnum value for the given errno.h error number.
58 g_io_error_from_errno (gint err_no)
64 return G_IO_ERROR_EXISTS;
70 return G_IO_ERROR_IS_DIRECTORY;
76 return G_IO_ERROR_PERMISSION_DENIED;
82 return G_IO_ERROR_FILENAME_TOO_LONG;
88 return G_IO_ERROR_NOT_FOUND;
94 return G_IO_ERROR_NOT_DIRECTORY;
100 return G_IO_ERROR_READ_ONLY;
106 return G_IO_ERROR_TOO_MANY_LINKS;
112 return G_IO_ERROR_NO_SPACE;
118 return G_IO_ERROR_NO_SPACE;
124 return G_IO_ERROR_INVALID_ARGUMENT;
130 return G_IO_ERROR_PERMISSION_DENIED;
136 return G_IO_ERROR_CANCELLED;
140 #if defined(ENOTEMPTY) && (!defined (EEXIST) || (ENOTEMPTY != EEXIST))
142 return G_IO_ERROR_NOT_EMPTY;
148 return G_IO_ERROR_NOT_SUPPORTED;
154 return G_IO_ERROR_TIMED_OUT;
160 return G_IO_ERROR_BUSY;
164 /* some magic to deal with EWOULDBLOCK and EAGAIN.
165 * apparently on HP-UX these are actually defined to different values,
166 * but on Linux, for example, they are the same.
168 #if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK == EAGAIN
169 /* we have both and they are the same: only emit one case. */
171 return G_IO_ERROR_WOULD_BLOCK;
174 /* else: consider each of them separately. this handles both the
175 * case of having only one and the case where they are different values.
179 return G_IO_ERROR_WOULD_BLOCK;
185 return G_IO_ERROR_WOULD_BLOCK;
192 return G_IO_ERROR_TOO_MANY_OPEN_FILES;
198 return G_IO_ERROR_ADDRESS_IN_USE;
204 return G_IO_ERROR_HOST_UNREACHABLE;
210 return G_IO_ERROR_NETWORK_UNREACHABLE;
216 return G_IO_ERROR_CONNECTION_REFUSED;
221 return G_IO_ERROR_FAILED;
229 * g_io_error_from_win32_error:
230 * @error_code: Windows error number.
232 * Converts some common error codes into GIO error codes. The
233 * fallback value G_IO_ERROR_FAILED is returned for error codes not
236 * Returns: #GIOErrorEnum value for the given error number.
241 g_io_error_from_win32_error (gint error_code)
246 return G_IO_ERROR_FAILED;