update dev300-m58
[ooovba.git] / sal / osl / unx / file_error_transl.cxx
blob649b296b84402a244b9d27e3505b2c34d64b4c6d
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.5 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 #ifndef _ERRNO_H
35 #include <errno.h>
36 #endif
38 #ifndef _FILE_ERROR_TRANSL_H_
39 #include "file_error_transl.h"
40 #endif
42 #ifndef _OSL_DIAGNOSE_H_
43 #include <osl/diagnose.h>
44 #endif
47 /********************************************
48 * oslTranslateFileError
49 *******************************************/
51 oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
53 oslFileError osl_error = osl_File_E_invalidError;
55 OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
57 /* Have a look at file_error_transl.h for
58 the reason that we do this here */
59 if (bIsError && (0 == Errno))
60 return osl_error;
62 switch(Errno)
64 case 0:
65 osl_error = osl_File_E_None;
66 break;
68 case EPERM:
69 osl_error = osl_File_E_PERM;
70 break;
72 case ENOENT:
73 osl_error = osl_File_E_NOENT;
74 break;
76 case ESRCH:
77 osl_error = osl_File_E_SRCH;
78 break;
80 case EINTR:
81 osl_error = osl_File_E_INTR;
82 break;
84 case EIO:
85 osl_error = osl_File_E_IO;
86 break;
88 case ENXIO:
89 osl_error = osl_File_E_IO;
90 break;
92 case E2BIG:
93 osl_error = osl_File_E_2BIG;
94 break;
96 case ENOEXEC:
97 osl_error = osl_File_E_NOEXEC;
98 break;
100 case EBADF:
101 osl_error = osl_File_E_BADF;
102 break;
104 case ECHILD:
105 osl_error = osl_File_E_CHILD;
106 break;
108 case EAGAIN:
109 osl_error = osl_File_E_AGAIN;
110 break;
112 case ENOMEM:
113 osl_error = osl_File_E_NOMEM;
114 break;
116 case EACCES:
117 osl_error = osl_File_E_ACCES;
118 break;
120 case EFAULT:
121 osl_error = osl_File_E_FAULT;
122 break;
124 case EBUSY:
125 osl_error = osl_File_E_BUSY;
126 break;
128 case EEXIST:
129 osl_error = osl_File_E_EXIST;
130 break;
132 case EXDEV:
133 osl_error = osl_File_E_XDEV;
134 break;
136 case ENODEV:
137 osl_error = osl_File_E_NODEV;
138 break;
140 case ENOTDIR:
141 osl_error = osl_File_E_NOTDIR;
142 break;
144 case EISDIR:
145 osl_error = osl_File_E_ISDIR;
146 break;
148 case EINVAL:
149 osl_error = osl_File_E_INVAL;
150 break;
152 case ENFILE:
153 osl_error = osl_File_E_NFILE;
154 break;
156 case EMFILE:
157 osl_error = osl_File_E_MFILE;
158 break;
160 case ENOTTY:
161 osl_error = osl_File_E_NOTTY;
162 break;
164 case EFBIG:
165 osl_error = osl_File_E_FBIG;
166 break;
168 case ENOSPC:
169 osl_error = osl_File_E_NOSPC;
170 break;
172 case ESPIPE:
173 osl_error = osl_File_E_SPIPE;
174 break;
176 case EROFS:
177 osl_error = osl_File_E_ROFS;
178 break;
180 case EMLINK:
181 osl_error = osl_File_E_MLINK;
182 break;
184 case EPIPE:
185 osl_error = osl_File_E_PIPE;
186 break;
188 case EDOM:
189 osl_error = osl_File_E_DOM;
190 break;
192 case ERANGE:
193 osl_error = osl_File_E_RANGE;
194 break;
196 case EDEADLK:
197 osl_error = osl_File_E_DEADLK;
198 break;
200 case ENAMETOOLONG:
201 osl_error = osl_File_E_NAMETOOLONG;
202 break;
204 case ENOLCK:
205 osl_error = osl_File_E_NOLCK;
206 break;
208 case ENOSYS:
209 osl_error = osl_File_E_NOSYS;
210 break;
212 case ENOTEMPTY:
213 osl_error = osl_File_E_NOTEMPTY;
214 break;
216 case ELOOP:
217 osl_error = osl_File_E_LOOP;
218 break;
220 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
221 case EILSEQ:
222 osl_error = osl_File_E_ILSEQ;
223 break;
224 #endif /* MACOSX */
226 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
227 case ENOLINK:
228 osl_error = osl_File_E_NOLINK;
229 break;
230 #endif /* MACOSX */
232 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
233 case EMULTIHOP:
234 osl_error = osl_File_E_MULTIHOP;
235 break;
236 #endif /* MACOSX */
238 case EUSERS:
239 osl_error = osl_File_E_USERS;
240 break;
242 case EOVERFLOW:
243 osl_error = osl_File_E_OVERFLOW;
244 break;
246 case ETIMEDOUT:
247 osl_error = osl_File_E_TIMEDOUT;
248 break;
250 case ETXTBSY:
251 osl_error = osl_File_E_TXTBSY;
252 break;
254 default:
255 /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
256 osl_error = osl_File_E_invalidError;
257 break;
260 return osl_error;