gio/ docs/reference/gio Merged gio-standalone into glib.
[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  * g_io_error_quark:
29  *
30  * Return value: The quark used as %G_IO_ERROR
31  **/
32 GQuark
33 g_io_error_quark (void)
34 {
35   return g_quark_from_static_string ("g-io-error-quark");
36 }
37
38 GIOErrorEnum
39 g_io_error_from_errno (gint err_no)
40 {
41   switch (err_no)
42     {
43 #ifdef EEXIST
44     case EEXIST:
45       return G_IO_ERROR_EXISTS;
46       break;
47 #endif
48
49 #ifdef EISDIR
50     case EISDIR:
51       return G_IO_ERROR_IS_DIRECTORY;
52       break;
53 #endif
54
55 #ifdef EACCES
56     case EACCES:
57       return G_IO_ERROR_PERMISSION_DENIED;
58       break;
59 #endif
60
61 #ifdef ENAMETOOLONG
62     case ENAMETOOLONG:
63       return G_IO_ERROR_FILENAME_TOO_LONG;
64       break;
65 #endif
66
67 #ifdef ENOENT
68     case ENOENT:
69       return G_IO_ERROR_NOT_FOUND;
70       break;
71 #endif
72
73 #ifdef ENOTDIR
74     case ENOTDIR:
75       return G_IO_ERROR_NOT_DIRECTORY;
76       break;
77 #endif
78
79 #ifdef EROFS
80     case EROFS:
81       return G_IO_ERROR_READ_ONLY;
82       break;
83 #endif
84
85 #ifdef ELOOP
86     case ELOOP:
87       return G_IO_ERROR_TOO_MANY_LINKS;
88       break;
89 #endif
90
91 #ifdef ENOSPC
92     case ENOSPC:
93       return G_IO_ERROR_NO_SPACE;
94       break;
95 #endif
96
97 #ifdef ENOMEM
98     case ENOMEM:
99       return G_IO_ERROR_NO_SPACE;
100       break;
101 #endif
102       
103 #ifdef EINVAL
104     case EINVAL:
105       return G_IO_ERROR_INVALID_ARGUMENT;
106       break;
107 #endif
108
109 #ifdef EPERM
110     case EPERM:
111       return G_IO_ERROR_PERMISSION_DENIED;
112       break;
113 #endif
114
115 #ifdef ECANCELED
116     case ECANCELED:
117       return G_IO_ERROR_CANCELLED;
118       break;
119 #endif
120
121 #ifdef ENOTEMPTY
122     case ENOTEMPTY:
123       return G_IO_ERROR_NOT_EMPTY;
124       break;
125 #endif
126
127 #ifdef ENOTSUP
128     case ENOTSUP:
129       return G_IO_ERROR_NOT_SUPPORTED;
130       break;
131 #endif
132
133 #ifdef ETIMEDOUT
134     case ETIMEDOUT:
135       return G_IO_ERROR_TIMED_OUT;
136       break;
137 #endif
138
139 #ifdef EBUSY
140     case EBUSY:
141       return G_IO_ERROR_BUSY;
142       break;
143 #endif
144
145 #ifdef EWOULDBLOCK
146     case EWOULDBLOCK:
147       return G_IO_ERROR_WOULD_BLOCK;
148       break;
149 #endif
150       
151     default:
152       return G_IO_ERROR_FAILED;
153       break;
154     }
155 }