xref: /aoo4110/main/sal/osl/os2/file_error_transl.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24  #ifndef _ERRNO_H
25  #include <errno.h>
26  #endif
27 
28  #ifndef _FILE_ERROR_TRANSL_H_
29  #include "file_error_transl.h"
30  #endif
31 
32  #ifndef _OSL_DIAGNOSE_H_
33  #include <osl/diagnose.h>
34  #endif
35 
36 
37 /********************************************
38  * oslTranslateFileError
39  *******************************************/
40 
oslTranslateFileError(sal_Bool bIsError,int Errno)41 oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
42 {
43     oslFileError osl_error = osl_File_E_invalidError;
44 
45 	OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
46 
47 	/* Have a look at file_error_transl.h for
48 	   the reason that we do this here */
49 	if (bIsError && (0 == Errno))
50 		return osl_error;
51 
52     switch(Errno)
53     {
54         case 0:
55             osl_error = osl_File_E_None;
56             break;
57 
58         case EPERM:
59             osl_error = osl_File_E_PERM;
60             break;
61 
62         case ENOENT:
63             osl_error = osl_File_E_NOENT;
64             break;
65 
66         case ESRCH:
67             osl_error = osl_File_E_SRCH;
68             break;
69 
70         case EINTR:
71             osl_error = osl_File_E_INTR;
72             break;
73 
74         case EIO:
75             osl_error = osl_File_E_IO;
76             break;
77 
78         case ENXIO:
79             osl_error = osl_File_E_IO;
80             break;
81 
82         case E2BIG:
83             osl_error = osl_File_E_2BIG;
84             break;
85 
86         case ENOEXEC:
87             osl_error = osl_File_E_NOEXEC;
88             break;
89 
90         case EBADF:
91             osl_error = osl_File_E_BADF;
92             break;
93 
94         case ECHILD:
95             osl_error = osl_File_E_CHILD;
96             break;
97 
98         case EAGAIN:
99             osl_error = osl_File_E_AGAIN;
100             break;
101 
102         case ENOMEM:
103             osl_error = osl_File_E_NOMEM;
104             break;
105 
106         case EACCES:
107             osl_error = osl_File_E_ACCES;
108             break;
109 
110         case EFAULT:
111             osl_error = osl_File_E_FAULT;
112             break;
113 
114         case EBUSY:
115             osl_error = osl_File_E_BUSY;
116             break;
117 
118         case EEXIST:
119             osl_error = osl_File_E_EXIST;
120             break;
121 
122         case EXDEV:
123             osl_error = osl_File_E_XDEV;
124             break;
125 
126         case ENODEV:
127             osl_error = osl_File_E_NODEV;
128             break;
129 
130         case ENOTDIR:
131             osl_error = osl_File_E_NOTDIR;
132             break;
133 
134         case EISDIR:
135             osl_error = osl_File_E_ISDIR;
136             break;
137 
138         case EINVAL:
139             osl_error = osl_File_E_INVAL;
140             break;
141 
142         case ENFILE:
143             osl_error = osl_File_E_NFILE;
144             break;
145 
146         case EMFILE:
147             osl_error = osl_File_E_MFILE;
148             break;
149 
150         case ENOTTY:
151             osl_error = osl_File_E_NOTTY;
152             break;
153 
154         case EFBIG:
155             osl_error = osl_File_E_FBIG;
156             break;
157 
158         case ENOSPC:
159             osl_error = osl_File_E_NOSPC;
160             break;
161 
162         case ESPIPE:
163             osl_error = osl_File_E_SPIPE;
164             break;
165 
166         case EROFS:
167             osl_error = osl_File_E_ROFS;
168             break;
169 
170         case EMLINK:
171             osl_error = osl_File_E_MLINK;
172             break;
173 
174         case EPIPE:
175             osl_error = osl_File_E_PIPE;
176             break;
177 
178         case EDOM:
179             osl_error = osl_File_E_DOM;
180             break;
181 
182         case ERANGE:
183             osl_error = osl_File_E_RANGE;
184             break;
185 
186         case EDEADLK:
187             osl_error = osl_File_E_DEADLK;
188             break;
189 
190         case ENAMETOOLONG:
191             osl_error = osl_File_E_NAMETOOLONG;
192             break;
193 
194         case ENOLCK:
195             osl_error = osl_File_E_NOLCK;
196             break;
197 
198         case ENOSYS:
199            osl_error = osl_File_E_NOSYS;
200             break;
201 
202         case ENOTEMPTY:
203             osl_error = osl_File_E_NOTEMPTY;
204             break;
205 
206         case ELOOP:
207             osl_error = osl_File_E_LOOP;
208             break;
209 
210 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
211         case EILSEQ:
212             osl_error = osl_File_E_ILSEQ;
213             break;
214 #endif /* MACOSX */
215 
216 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
217         case ENOLINK:
218             osl_error = osl_File_E_NOLINK;
219             break;
220 #endif /* MACOSX */
221 
222 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
223         case EMULTIHOP:
224             osl_error = osl_File_E_MULTIHOP;
225             break;
226 #endif /* MACOSX */
227 
228         case EUSERS:
229             osl_error = osl_File_E_USERS;
230             break;
231 
232         case EOVERFLOW:
233             osl_error = osl_File_E_OVERFLOW;
234             break;
235 
236         case ETIMEDOUT:
237             osl_error = osl_File_E_TIMEDOUT;
238             break;
239 
240         default:
241             /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
242             osl_error = osl_File_E_invalidError;
243             break;
244     }
245 
246     return osl_error;
247 }
248 
249