merged tag ooo/DEV300_m102
[LibreOffice.git] / sal / osl / os2 / file_error_transl.cxx
blobfd296d9dd3d20e53ffb33f8764a53aa8bcd22d15
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _ERRNO_H
29 #include <errno.h>
30 #endif
32 #ifndef _FILE_ERROR_TRANSL_H_
33 #include "file_error_transl.h"
34 #endif
36 #ifndef _OSL_DIAGNOSE_H_
37 #include <osl/diagnose.h>
38 #endif
41 /********************************************
42 * oslTranslateFileError
43 *******************************************/
45 oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
47 oslFileError osl_error = osl_File_E_invalidError;
49 OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
51 /* Have a look at file_error_transl.h for
52 the reason that we do this here */
53 if (bIsError && (0 == Errno))
54 return osl_error;
56 switch(Errno)
58 case 0:
59 osl_error = osl_File_E_None;
60 break;
62 case EPERM:
63 osl_error = osl_File_E_PERM;
64 break;
66 case ENOENT:
67 osl_error = osl_File_E_NOENT;
68 break;
70 case ESRCH:
71 osl_error = osl_File_E_SRCH;
72 break;
74 case EINTR:
75 osl_error = osl_File_E_INTR;
76 break;
78 case EIO:
79 osl_error = osl_File_E_IO;
80 break;
82 case ENXIO:
83 osl_error = osl_File_E_IO;
84 break;
86 case E2BIG:
87 osl_error = osl_File_E_2BIG;
88 break;
90 case ENOEXEC:
91 osl_error = osl_File_E_NOEXEC;
92 break;
94 case EBADF:
95 osl_error = osl_File_E_BADF;
96 break;
98 case ECHILD:
99 osl_error = osl_File_E_CHILD;
100 break;
102 case EAGAIN:
103 osl_error = osl_File_E_AGAIN;
104 break;
106 case ENOMEM:
107 osl_error = osl_File_E_NOMEM;
108 break;
110 case EACCES:
111 osl_error = osl_File_E_ACCES;
112 break;
114 case EFAULT:
115 osl_error = osl_File_E_FAULT;
116 break;
118 case EBUSY:
119 osl_error = osl_File_E_BUSY;
120 break;
122 case EEXIST:
123 osl_error = osl_File_E_EXIST;
124 break;
126 case EXDEV:
127 osl_error = osl_File_E_XDEV;
128 break;
130 case ENODEV:
131 osl_error = osl_File_E_NODEV;
132 break;
134 case ENOTDIR:
135 osl_error = osl_File_E_NOTDIR;
136 break;
138 case EISDIR:
139 osl_error = osl_File_E_ISDIR;
140 break;
142 case EINVAL:
143 osl_error = osl_File_E_INVAL;
144 break;
146 case ENFILE:
147 osl_error = osl_File_E_NFILE;
148 break;
150 case EMFILE:
151 osl_error = osl_File_E_MFILE;
152 break;
154 case ENOTTY:
155 osl_error = osl_File_E_NOTTY;
156 break;
158 case EFBIG:
159 osl_error = osl_File_E_FBIG;
160 break;
162 case ENOSPC:
163 osl_error = osl_File_E_NOSPC;
164 break;
166 case ESPIPE:
167 osl_error = osl_File_E_SPIPE;
168 break;
170 case EROFS:
171 osl_error = osl_File_E_ROFS;
172 break;
174 case EMLINK:
175 osl_error = osl_File_E_MLINK;
176 break;
178 case EPIPE:
179 osl_error = osl_File_E_PIPE;
180 break;
182 case EDOM:
183 osl_error = osl_File_E_DOM;
184 break;
186 case ERANGE:
187 osl_error = osl_File_E_RANGE;
188 break;
190 case EDEADLK:
191 osl_error = osl_File_E_DEADLK;
192 break;
194 case ENAMETOOLONG:
195 osl_error = osl_File_E_NAMETOOLONG;
196 break;
198 case ENOLCK:
199 osl_error = osl_File_E_NOLCK;
200 break;
202 case ENOSYS:
203 osl_error = osl_File_E_NOSYS;
204 break;
206 case ENOTEMPTY:
207 osl_error = osl_File_E_NOTEMPTY;
208 break;
210 case ELOOP:
211 osl_error = osl_File_E_LOOP;
212 break;
214 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
215 case EILSEQ:
216 osl_error = osl_File_E_ILSEQ;
217 break;
218 #endif /* MACOSX */
220 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
221 case ENOLINK:
222 osl_error = osl_File_E_NOLINK;
223 break;
224 #endif /* MACOSX */
226 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
227 case EMULTIHOP:
228 osl_error = osl_File_E_MULTIHOP;
229 break;
230 #endif /* MACOSX */
232 case EUSERS:
233 osl_error = osl_File_E_USERS;
234 break;
236 case EOVERFLOW:
237 osl_error = osl_File_E_OVERFLOW;
238 break;
240 case ETIMEDOUT:
241 osl_error = osl_File_E_TIMEDOUT;
242 break;
244 default:
245 /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
246 osl_error = osl_File_E_invalidError;
247 break;
250 return osl_error;