Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <errno.h>
21 : #include "file_error_transl.h"
22 : #include <osl/diagnose.h>
23 :
24 129151 : oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
25 : {
26 129151 : oslFileError osl_error = osl_File_E_invalidError;
27 :
28 : OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
29 :
30 : /* Have a look at file_error_transl.h for
31 : the reason that we do this here */
32 129151 : if (bIsError && (0 == Errno))
33 0 : return osl_error;
34 :
35 129151 : switch(Errno)
36 : {
37 : case 0:
38 0 : osl_error = osl_File_E_None;
39 0 : break;
40 :
41 : case EPERM:
42 0 : osl_error = osl_File_E_PERM;
43 0 : break;
44 :
45 : case ENOENT:
46 129148 : osl_error = osl_File_E_NOENT;
47 129148 : break;
48 :
49 : case ESRCH:
50 0 : osl_error = osl_File_E_SRCH;
51 0 : break;
52 :
53 : case EINTR:
54 0 : osl_error = osl_File_E_INTR;
55 0 : break;
56 :
57 : case EIO:
58 0 : osl_error = osl_File_E_IO;
59 0 : break;
60 :
61 : case ENXIO:
62 0 : osl_error = osl_File_E_IO;
63 0 : break;
64 :
65 : case E2BIG:
66 0 : osl_error = osl_File_E_2BIG;
67 0 : break;
68 :
69 : case ENOEXEC:
70 0 : osl_error = osl_File_E_NOEXEC;
71 0 : break;
72 :
73 : case EBADF:
74 0 : osl_error = osl_File_E_BADF;
75 0 : break;
76 :
77 : case ECHILD:
78 0 : osl_error = osl_File_E_CHILD;
79 0 : break;
80 :
81 : case EAGAIN:
82 0 : osl_error = osl_File_E_AGAIN;
83 0 : break;
84 :
85 : case ENOMEM:
86 0 : osl_error = osl_File_E_NOMEM;
87 0 : break;
88 :
89 : case EACCES:
90 0 : osl_error = osl_File_E_ACCES;
91 0 : break;
92 :
93 : case EFAULT:
94 0 : osl_error = osl_File_E_FAULT;
95 0 : break;
96 :
97 : case EBUSY:
98 0 : osl_error = osl_File_E_BUSY;
99 0 : break;
100 :
101 : case EEXIST:
102 1 : osl_error = osl_File_E_EXIST;
103 1 : break;
104 :
105 : case EXDEV:
106 0 : osl_error = osl_File_E_XDEV;
107 0 : break;
108 :
109 : case ENODEV:
110 0 : osl_error = osl_File_E_NODEV;
111 0 : break;
112 :
113 : case ENOTDIR:
114 2 : osl_error = osl_File_E_NOTDIR;
115 2 : break;
116 :
117 : case EISDIR:
118 0 : osl_error = osl_File_E_ISDIR;
119 0 : break;
120 :
121 : case EINVAL:
122 0 : osl_error = osl_File_E_INVAL;
123 0 : break;
124 :
125 : case ENFILE:
126 0 : osl_error = osl_File_E_NFILE;
127 0 : break;
128 :
129 : case EMFILE:
130 0 : osl_error = osl_File_E_MFILE;
131 0 : break;
132 :
133 : case ENOTTY:
134 0 : osl_error = osl_File_E_NOTTY;
135 0 : break;
136 :
137 : case EFBIG:
138 0 : osl_error = osl_File_E_FBIG;
139 0 : break;
140 :
141 : case ENOSPC:
142 0 : osl_error = osl_File_E_NOSPC;
143 0 : break;
144 :
145 : case ESPIPE:
146 0 : osl_error = osl_File_E_SPIPE;
147 0 : break;
148 :
149 : case EROFS:
150 0 : osl_error = osl_File_E_ROFS;
151 0 : break;
152 :
153 : case EMLINK:
154 0 : osl_error = osl_File_E_MLINK;
155 0 : break;
156 :
157 : case EPIPE:
158 0 : osl_error = osl_File_E_PIPE;
159 0 : break;
160 :
161 : case EDOM:
162 0 : osl_error = osl_File_E_DOM;
163 0 : break;
164 :
165 : case ERANGE:
166 0 : osl_error = osl_File_E_RANGE;
167 0 : break;
168 :
169 : case EDEADLK:
170 0 : osl_error = osl_File_E_DEADLK;
171 0 : break;
172 :
173 : case ENAMETOOLONG:
174 0 : osl_error = osl_File_E_NAMETOOLONG;
175 0 : break;
176 :
177 : case ENOLCK:
178 0 : osl_error = osl_File_E_NOLCK;
179 0 : break;
180 :
181 : case ENOSYS:
182 0 : osl_error = osl_File_E_NOSYS;
183 0 : break;
184 :
185 : #if !defined(AIX) || !(defined(_ALL_SOURCE) && !defined(_LINUX_SOURCE_COMPAT))
186 : case ENOTEMPTY:
187 0 : osl_error = osl_File_E_NOTEMPTY;
188 0 : break;
189 : #endif
190 :
191 : case ELOOP:
192 0 : osl_error = osl_File_E_LOOP;
193 0 : break;
194 :
195 : #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OPENBSD) || defined(DRAGONFLY))
196 : case EILSEQ:
197 0 : osl_error = osl_File_E_ILSEQ;
198 0 : break;
199 :
200 : case ENOLINK:
201 0 : osl_error = osl_File_E_NOLINK;
202 0 : break;
203 :
204 : case EMULTIHOP:
205 0 : osl_error = osl_File_E_MULTIHOP;
206 0 : break;
207 : #endif /* MACOSX */
208 :
209 : case EUSERS:
210 0 : osl_error = osl_File_E_USERS;
211 0 : break;
212 :
213 : case EOVERFLOW:
214 0 : osl_error = osl_File_E_OVERFLOW;
215 0 : break;
216 :
217 : case ETIMEDOUT:
218 0 : osl_error = osl_File_E_TIMEDOUT;
219 0 : break;
220 :
221 : default:
222 : /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
223 0 : osl_error = osl_File_E_invalidError;
224 0 : break;
225 : }
226 :
227 129151 : return osl_error;
228 : }
229 :
230 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|