Another round of trivial doc fixes
[platform/upstream/glib.git] / gio / gioerror.c
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #include <config.h>
24 #include <errno.h>
25 #include "gioerror.h"
26
27 /**
28  * SECTION:gioerror
29  * @short_description: Error helper functions
30  *
31  **/
32
33 /**
34  * g_io_error_quark:
35  * 
36  * Gets the GIO Error Quark.
37  *
38  * Return value: a #GQuark.
39  **/
40 GQuark
41 g_io_error_quark (void)
42 {
43   return g_quark_from_static_string ("g-io-error-quark");
44 }
45
46 /**
47  * g_io_error_from_errno:
48  * @err_no: Error number as defined in errno.h.
49  *
50  * Converts errno.h error codes into GIO error codes.
51  *
52  * Returns: #GIOErrorEnum value for the given errno.h error number.
53  **/
54 GIOErrorEnum
55 g_io_error_from_errno (gint err_no)
56 {
57   switch (err_no)
58     {
59 #ifdef EEXIST
60     case EEXIST:
61       return G_IO_ERROR_EXISTS;
62       break;
63 #endif
64
65 #ifdef EISDIR
66     case EISDIR:
67       return G_IO_ERROR_IS_DIRECTORY;
68       break;
69 #endif
70
71 #ifdef EACCES
72     case EACCES:
73       return G_IO_ERROR_PERMISSION_DENIED;
74       break;
75 #endif
76
77 #ifdef ENAMETOOLONG
78     case ENAMETOOLONG:
79       return G_IO_ERROR_FILENAME_TOO_LONG;
80       break;
81 #endif
82
83 #ifdef ENOENT
84     case ENOENT:
85       return G_IO_ERROR_NOT_FOUND;
86       break;
87 #endif
88
89 #ifdef ENOTDIR
90     case ENOTDIR:
91       return G_IO_ERROR_NOT_DIRECTORY;
92       break;
93 #endif
94
95 #ifdef EROFS
96     case EROFS:
97       return G_IO_ERROR_READ_ONLY;
98       break;
99 #endif
100
101 #ifdef ELOOP
102     case ELOOP:
103       return G_IO_ERROR_TOO_MANY_LINKS;
104       break;
105 #endif
106
107 #ifdef ENOSPC
108     case ENOSPC:
109       return G_IO_ERROR_NO_SPACE;
110       break;
111 #endif
112
113 #ifdef ENOMEM
114     case ENOMEM:
115       return G_IO_ERROR_NO_SPACE;
116       break;
117 #endif
118       
119 #ifdef EINVAL
120     case EINVAL:
121       return G_IO_ERROR_INVALID_ARGUMENT;
122       break;
123 #endif
124
125 #ifdef EPERM
126     case EPERM:
127       return G_IO_ERROR_PERMISSION_DENIED;
128       break;
129 #endif
130
131 #ifdef ECANCELED
132     case ECANCELED:
133       return G_IO_ERROR_CANCELLED;
134       break;
135 #endif
136
137 #ifdef ENOTEMPTY
138     case ENOTEMPTY:
139       return G_IO_ERROR_NOT_EMPTY;
140       break;
141 #endif
142
143 #ifdef ENOTSUP
144     case ENOTSUP:
145       return G_IO_ERROR_NOT_SUPPORTED;
146       break;
147 #endif
148
149 #ifdef ETIMEDOUT
150     case ETIMEDOUT:
151       return G_IO_ERROR_TIMED_OUT;
152       break;
153 #endif
154
155 #ifdef EBUSY
156     case EBUSY:
157       return G_IO_ERROR_BUSY;
158       break;
159 #endif
160
161 #ifdef EWOULDBLOCK
162     case EWOULDBLOCK:
163       return G_IO_ERROR_WOULD_BLOCK;
164       break;
165 #endif
166       
167     default:
168       return G_IO_ERROR_FAILED;
169       break;
170     }
171 }