Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / sal / osl / unx / file_error_transl.cxx
blob59700b995b2767b60510924a9f9c74e82a314be6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <errno.h>
21 #include "file_error_transl.h"
22 #include <osl/diagnose.h>
24 oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
26 oslFileError osl_error = osl_File_E_invalidError;
28 OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
30 /* Have a look at file_error_transl.h for
31 the reason that we do this here */
32 if (bIsError && (0 == Errno))
33 return osl_error;
35 switch(Errno)
37 case 0:
38 osl_error = osl_File_E_None;
39 break;
41 case EPERM:
42 osl_error = osl_File_E_PERM;
43 break;
45 case ENOENT:
46 osl_error = osl_File_E_NOENT;
47 break;
49 case ESRCH:
50 osl_error = osl_File_E_SRCH;
51 break;
53 case EINTR:
54 osl_error = osl_File_E_INTR;
55 break;
57 case EIO:
58 osl_error = osl_File_E_IO;
59 break;
61 case ENXIO:
62 osl_error = osl_File_E_IO;
63 break;
65 case E2BIG:
66 osl_error = osl_File_E_2BIG;
67 break;
69 case ENOEXEC:
70 osl_error = osl_File_E_NOEXEC;
71 break;
73 case EBADF:
74 osl_error = osl_File_E_BADF;
75 break;
77 case ECHILD:
78 osl_error = osl_File_E_CHILD;
79 break;
81 case EAGAIN:
82 osl_error = osl_File_E_AGAIN;
83 break;
85 case ENOMEM:
86 osl_error = osl_File_E_NOMEM;
87 break;
89 case EACCES:
90 osl_error = osl_File_E_ACCES;
91 break;
93 case EFAULT:
94 osl_error = osl_File_E_FAULT;
95 break;
97 case EBUSY:
98 osl_error = osl_File_E_BUSY;
99 break;
101 case EEXIST:
102 osl_error = osl_File_E_EXIST;
103 break;
105 case EXDEV:
106 osl_error = osl_File_E_XDEV;
107 break;
109 case ENODEV:
110 osl_error = osl_File_E_NODEV;
111 break;
113 case ENOTDIR:
114 osl_error = osl_File_E_NOTDIR;
115 break;
117 case EISDIR:
118 osl_error = osl_File_E_ISDIR;
119 break;
121 case EINVAL:
122 osl_error = osl_File_E_INVAL;
123 break;
125 case ENFILE:
126 osl_error = osl_File_E_NFILE;
127 break;
129 case EMFILE:
130 osl_error = osl_File_E_MFILE;
131 break;
133 case ENOTTY:
134 osl_error = osl_File_E_NOTTY;
135 break;
137 case EFBIG:
138 osl_error = osl_File_E_FBIG;
139 break;
141 case ENOSPC:
142 osl_error = osl_File_E_NOSPC;
143 break;
145 case ESPIPE:
146 osl_error = osl_File_E_SPIPE;
147 break;
149 case EROFS:
150 osl_error = osl_File_E_ROFS;
151 break;
153 case EMLINK:
154 osl_error = osl_File_E_MLINK;
155 break;
157 case EPIPE:
158 osl_error = osl_File_E_PIPE;
159 break;
161 case EDOM:
162 osl_error = osl_File_E_DOM;
163 break;
165 case ERANGE:
166 osl_error = osl_File_E_RANGE;
167 break;
169 case EDEADLK:
170 osl_error = osl_File_E_DEADLK;
171 break;
173 case ENAMETOOLONG:
174 osl_error = osl_File_E_NAMETOOLONG;
175 break;
177 case ENOLCK:
178 osl_error = osl_File_E_NOLCK;
179 break;
181 case ENOSYS:
182 osl_error = osl_File_E_NOSYS;
183 break;
185 #if !defined(AIX) || !(defined(_ALL_SOURCE) && !defined(_LINUX_SOURCE_COMPAT))
186 case ENOTEMPTY:
187 osl_error = osl_File_E_NOTEMPTY;
188 break;
189 #endif
191 case ELOOP:
192 osl_error = osl_File_E_LOOP;
193 break;
195 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OPENBSD) || defined(DRAGONFLY))
196 case EILSEQ:
197 osl_error = osl_File_E_ILSEQ;
198 break;
200 case ENOLINK:
201 osl_error = osl_File_E_NOLINK;
202 break;
204 case EMULTIHOP:
205 osl_error = osl_File_E_MULTIHOP;
206 break;
207 #endif /* MACOSX */
209 case EUSERS:
210 osl_error = osl_File_E_USERS;
211 break;
213 case EOVERFLOW:
214 osl_error = osl_File_E_OVERFLOW;
215 break;
217 case ETIMEDOUT:
218 osl_error = osl_File_E_TIMEDOUT;
219 break;
221 default:
222 /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
223 osl_error = osl_File_E_invalidError;
224 break;
227 return osl_error;
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */