update dev300-m58
[ooovba.git] / sal / osl / os2 / file_error_transl.cxx
blob094748ae28a4886eb47a7a12d4057407b8dc3ce3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: file_error_transl.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _ERRNO_H
32 #include <errno.h>
33 #endif
35 #ifndef _FILE_ERROR_TRANSL_H_
36 #include "file_error_transl.h"
37 #endif
39 #ifndef _OSL_DIAGNOSE_H_
40 #include <osl/diagnose.h>
41 #endif
44 /********************************************
45 * oslTranslateFileError
46 *******************************************/
48 oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
50 oslFileError osl_error = osl_File_E_invalidError;
52 OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
54 /* Have a look at file_error_transl.h for
55 the reason that we do this here */
56 if (bIsError && (0 == Errno))
57 return osl_error;
59 switch(Errno)
61 case 0:
62 osl_error = osl_File_E_None;
63 break;
65 case EPERM:
66 osl_error = osl_File_E_PERM;
67 break;
69 case ENOENT:
70 osl_error = osl_File_E_NOENT;
71 break;
73 case ESRCH:
74 osl_error = osl_File_E_SRCH;
75 break;
77 case EINTR:
78 osl_error = osl_File_E_INTR;
79 break;
81 case EIO:
82 osl_error = osl_File_E_IO;
83 break;
85 case ENXIO:
86 osl_error = osl_File_E_IO;
87 break;
89 case E2BIG:
90 osl_error = osl_File_E_2BIG;
91 break;
93 case ENOEXEC:
94 osl_error = osl_File_E_NOEXEC;
95 break;
97 case EBADF:
98 osl_error = osl_File_E_BADF;
99 break;
101 case ECHILD:
102 osl_error = osl_File_E_CHILD;
103 break;
105 case EAGAIN:
106 osl_error = osl_File_E_AGAIN;
107 break;
109 case ENOMEM:
110 osl_error = osl_File_E_NOMEM;
111 break;
113 case EACCES:
114 osl_error = osl_File_E_ACCES;
115 break;
117 case EFAULT:
118 osl_error = osl_File_E_FAULT;
119 break;
121 case EBUSY:
122 osl_error = osl_File_E_BUSY;
123 break;
125 case EEXIST:
126 osl_error = osl_File_E_EXIST;
127 break;
129 case EXDEV:
130 osl_error = osl_File_E_XDEV;
131 break;
133 case ENODEV:
134 osl_error = osl_File_E_NODEV;
135 break;
137 case ENOTDIR:
138 osl_error = osl_File_E_NOTDIR;
139 break;
141 case EISDIR:
142 osl_error = osl_File_E_ISDIR;
143 break;
145 case EINVAL:
146 osl_error = osl_File_E_INVAL;
147 break;
149 case ENFILE:
150 osl_error = osl_File_E_NFILE;
151 break;
153 case EMFILE:
154 osl_error = osl_File_E_MFILE;
155 break;
157 case ENOTTY:
158 osl_error = osl_File_E_NOTTY;
159 break;
161 case EFBIG:
162 osl_error = osl_File_E_FBIG;
163 break;
165 case ENOSPC:
166 osl_error = osl_File_E_NOSPC;
167 break;
169 case ESPIPE:
170 osl_error = osl_File_E_SPIPE;
171 break;
173 case EROFS:
174 osl_error = osl_File_E_ROFS;
175 break;
177 case EMLINK:
178 osl_error = osl_File_E_MLINK;
179 break;
181 case EPIPE:
182 osl_error = osl_File_E_PIPE;
183 break;
185 case EDOM:
186 osl_error = osl_File_E_DOM;
187 break;
189 case ERANGE:
190 osl_error = osl_File_E_RANGE;
191 break;
193 case EDEADLK:
194 osl_error = osl_File_E_DEADLK;
195 break;
197 case ENAMETOOLONG:
198 osl_error = osl_File_E_NAMETOOLONG;
199 break;
201 case ENOLCK:
202 osl_error = osl_File_E_NOLCK;
203 break;
205 case ENOSYS:
206 osl_error = osl_File_E_NOSYS;
207 break;
209 case ENOTEMPTY:
210 osl_error = osl_File_E_NOTEMPTY;
211 break;
213 case ELOOP:
214 osl_error = osl_File_E_LOOP;
215 break;
217 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
218 case EILSEQ:
219 osl_error = osl_File_E_ILSEQ;
220 break;
221 #endif /* MACOSX */
223 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
224 case ENOLINK:
225 osl_error = osl_File_E_NOLINK;
226 break;
227 #endif /* MACOSX */
229 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
230 case EMULTIHOP:
231 osl_error = osl_File_E_MULTIHOP;
232 break;
233 #endif /* MACOSX */
235 case EUSERS:
236 osl_error = osl_File_E_USERS;
237 break;
239 case EOVERFLOW:
240 osl_error = osl_File_E_OVERFLOW;
241 break;
243 case ETIMEDOUT:
244 osl_error = osl_File_E_TIMEDOUT;
245 break;
247 default:
248 /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
249 osl_error = osl_File_E_invalidError;
250 break;
253 return osl_error;