xref: /aoo41x/main/sal/osl/os2/file_error_transl.cxx (revision 87d2adbc)
1*87d2adbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*87d2adbcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*87d2adbcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*87d2adbcSAndrew Rist  * distributed with this work for additional information
6*87d2adbcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*87d2adbcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*87d2adbcSAndrew Rist  * "License"); you may not use this file except in compliance
9*87d2adbcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*87d2adbcSAndrew Rist  *
11*87d2adbcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*87d2adbcSAndrew Rist  *
13*87d2adbcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*87d2adbcSAndrew Rist  * software distributed under the License is distributed on an
15*87d2adbcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*87d2adbcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*87d2adbcSAndrew Rist  * specific language governing permissions and limitations
18*87d2adbcSAndrew Rist  * under the License.
19*87d2adbcSAndrew Rist  *
20*87d2adbcSAndrew Rist  *************************************************************/
21*87d2adbcSAndrew Rist 
22*87d2adbcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir  #ifndef _ERRNO_H
25cdf0e10cSrcweir  #include <errno.h>
26cdf0e10cSrcweir  #endif
27cdf0e10cSrcweir 
28cdf0e10cSrcweir  #ifndef _FILE_ERROR_TRANSL_H_
29cdf0e10cSrcweir  #include "file_error_transl.h"
30cdf0e10cSrcweir  #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir  #ifndef _OSL_DIAGNOSE_H_
33cdf0e10cSrcweir  #include <osl/diagnose.h>
34cdf0e10cSrcweir  #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /********************************************
38cdf0e10cSrcweir  * oslTranslateFileError
39cdf0e10cSrcweir  *******************************************/
40cdf0e10cSrcweir 
oslTranslateFileError(sal_Bool bIsError,int Errno)41cdf0e10cSrcweir oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     oslFileError osl_error = osl_File_E_invalidError;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 	OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!");
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	/* Have a look at file_error_transl.h for
48cdf0e10cSrcweir 	   the reason that we do this here */
49cdf0e10cSrcweir 	if (bIsError && (0 == Errno))
50cdf0e10cSrcweir 		return osl_error;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     switch(Errno)
53cdf0e10cSrcweir     {
54cdf0e10cSrcweir         case 0:
55cdf0e10cSrcweir             osl_error = osl_File_E_None;
56cdf0e10cSrcweir             break;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir         case EPERM:
59cdf0e10cSrcweir             osl_error = osl_File_E_PERM;
60cdf0e10cSrcweir             break;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         case ENOENT:
63cdf0e10cSrcweir             osl_error = osl_File_E_NOENT;
64cdf0e10cSrcweir             break;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         case ESRCH:
67cdf0e10cSrcweir             osl_error = osl_File_E_SRCH;
68cdf0e10cSrcweir             break;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         case EINTR:
71cdf0e10cSrcweir             osl_error = osl_File_E_INTR;
72cdf0e10cSrcweir             break;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         case EIO:
75cdf0e10cSrcweir             osl_error = osl_File_E_IO;
76cdf0e10cSrcweir             break;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         case ENXIO:
79cdf0e10cSrcweir             osl_error = osl_File_E_IO;
80cdf0e10cSrcweir             break;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         case E2BIG:
83cdf0e10cSrcweir             osl_error = osl_File_E_2BIG;
84cdf0e10cSrcweir             break;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         case ENOEXEC:
87cdf0e10cSrcweir             osl_error = osl_File_E_NOEXEC;
88cdf0e10cSrcweir             break;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         case EBADF:
91cdf0e10cSrcweir             osl_error = osl_File_E_BADF;
92cdf0e10cSrcweir             break;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         case ECHILD:
95cdf0e10cSrcweir             osl_error = osl_File_E_CHILD;
96cdf0e10cSrcweir             break;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         case EAGAIN:
99cdf0e10cSrcweir             osl_error = osl_File_E_AGAIN;
100cdf0e10cSrcweir             break;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         case ENOMEM:
103cdf0e10cSrcweir             osl_error = osl_File_E_NOMEM;
104cdf0e10cSrcweir             break;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         case EACCES:
107cdf0e10cSrcweir             osl_error = osl_File_E_ACCES;
108cdf0e10cSrcweir             break;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         case EFAULT:
111cdf0e10cSrcweir             osl_error = osl_File_E_FAULT;
112cdf0e10cSrcweir             break;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         case EBUSY:
115cdf0e10cSrcweir             osl_error = osl_File_E_BUSY;
116cdf0e10cSrcweir             break;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         case EEXIST:
119cdf0e10cSrcweir             osl_error = osl_File_E_EXIST;
120cdf0e10cSrcweir             break;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         case EXDEV:
123cdf0e10cSrcweir             osl_error = osl_File_E_XDEV;
124cdf0e10cSrcweir             break;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         case ENODEV:
127cdf0e10cSrcweir             osl_error = osl_File_E_NODEV;
128cdf0e10cSrcweir             break;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         case ENOTDIR:
131cdf0e10cSrcweir             osl_error = osl_File_E_NOTDIR;
132cdf0e10cSrcweir             break;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         case EISDIR:
135cdf0e10cSrcweir             osl_error = osl_File_E_ISDIR;
136cdf0e10cSrcweir             break;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         case EINVAL:
139cdf0e10cSrcweir             osl_error = osl_File_E_INVAL;
140cdf0e10cSrcweir             break;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         case ENFILE:
143cdf0e10cSrcweir             osl_error = osl_File_E_NFILE;
144cdf0e10cSrcweir             break;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         case EMFILE:
147cdf0e10cSrcweir             osl_error = osl_File_E_MFILE;
148cdf0e10cSrcweir             break;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         case ENOTTY:
151cdf0e10cSrcweir             osl_error = osl_File_E_NOTTY;
152cdf0e10cSrcweir             break;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         case EFBIG:
155cdf0e10cSrcweir             osl_error = osl_File_E_FBIG;
156cdf0e10cSrcweir             break;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         case ENOSPC:
159cdf0e10cSrcweir             osl_error = osl_File_E_NOSPC;
160cdf0e10cSrcweir             break;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir         case ESPIPE:
163cdf0e10cSrcweir             osl_error = osl_File_E_SPIPE;
164cdf0e10cSrcweir             break;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         case EROFS:
167cdf0e10cSrcweir             osl_error = osl_File_E_ROFS;
168cdf0e10cSrcweir             break;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         case EMLINK:
171cdf0e10cSrcweir             osl_error = osl_File_E_MLINK;
172cdf0e10cSrcweir             break;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         case EPIPE:
175cdf0e10cSrcweir             osl_error = osl_File_E_PIPE;
176cdf0e10cSrcweir             break;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         case EDOM:
179cdf0e10cSrcweir             osl_error = osl_File_E_DOM;
180cdf0e10cSrcweir             break;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         case ERANGE:
183cdf0e10cSrcweir             osl_error = osl_File_E_RANGE;
184cdf0e10cSrcweir             break;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         case EDEADLK:
187cdf0e10cSrcweir             osl_error = osl_File_E_DEADLK;
188cdf0e10cSrcweir             break;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         case ENAMETOOLONG:
191cdf0e10cSrcweir             osl_error = osl_File_E_NAMETOOLONG;
192cdf0e10cSrcweir             break;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         case ENOLCK:
195cdf0e10cSrcweir             osl_error = osl_File_E_NOLCK;
196cdf0e10cSrcweir             break;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir         case ENOSYS:
199cdf0e10cSrcweir            osl_error = osl_File_E_NOSYS;
200cdf0e10cSrcweir             break;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir         case ENOTEMPTY:
203cdf0e10cSrcweir             osl_error = osl_File_E_NOTEMPTY;
204cdf0e10cSrcweir             break;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir         case ELOOP:
207cdf0e10cSrcweir             osl_error = osl_File_E_LOOP;
208cdf0e10cSrcweir             break;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
211cdf0e10cSrcweir         case EILSEQ:
212cdf0e10cSrcweir             osl_error = osl_File_E_ILSEQ;
213cdf0e10cSrcweir             break;
214cdf0e10cSrcweir #endif /* MACOSX */
215cdf0e10cSrcweir 
216cdf0e10cSrcweir #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
217cdf0e10cSrcweir         case ENOLINK:
218cdf0e10cSrcweir             osl_error = osl_File_E_NOLINK;
219cdf0e10cSrcweir             break;
220cdf0e10cSrcweir #endif /* MACOSX */
221cdf0e10cSrcweir 
222cdf0e10cSrcweir #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2))
223cdf0e10cSrcweir         case EMULTIHOP:
224cdf0e10cSrcweir             osl_error = osl_File_E_MULTIHOP;
225cdf0e10cSrcweir             break;
226cdf0e10cSrcweir #endif /* MACOSX */
227cdf0e10cSrcweir 
228cdf0e10cSrcweir         case EUSERS:
229cdf0e10cSrcweir             osl_error = osl_File_E_USERS;
230cdf0e10cSrcweir             break;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         case EOVERFLOW:
233cdf0e10cSrcweir             osl_error = osl_File_E_OVERFLOW;
234cdf0e10cSrcweir             break;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir         case ETIMEDOUT:
237cdf0e10cSrcweir             osl_error = osl_File_E_TIMEDOUT;
238cdf0e10cSrcweir             break;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir         default:
241cdf0e10cSrcweir             /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
242cdf0e10cSrcweir             osl_error = osl_File_E_invalidError;
243cdf0e10cSrcweir             break;
244cdf0e10cSrcweir     }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     return osl_error;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249