1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sal.hxx" 30 31 #ifndef _ERRNO_H 32 #include <errno.h> 33 #endif 34 35 #ifndef _FILE_ERROR_TRANSL_H_ 36 #include "file_error_transl.h" 37 #endif 38 39 #ifndef _OSL_DIAGNOSE_H_ 40 #include <osl/diagnose.h> 41 #endif 42 43 44 /******************************************** 45 * oslTranslateFileError 46 *******************************************/ 47 48 oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno) 49 { 50 oslFileError osl_error = osl_File_E_invalidError; 51 52 OSL_ENSURE((bIsError && (0 != Errno)) || (!bIsError && (0 == Errno)), "oslTranslateFileError strange input combination!"); 53 54 /* Have a look at file_error_transl.h for 55 the reason that we do this here */ 56 if (bIsError && (0 == Errno)) 57 return osl_error; 58 59 switch(Errno) 60 { 61 case 0: 62 osl_error = osl_File_E_None; 63 break; 64 65 case EPERM: 66 osl_error = osl_File_E_PERM; 67 break; 68 69 case ENOENT: 70 osl_error = osl_File_E_NOENT; 71 break; 72 73 case ESRCH: 74 osl_error = osl_File_E_SRCH; 75 break; 76 77 case EINTR: 78 osl_error = osl_File_E_INTR; 79 break; 80 81 case EIO: 82 osl_error = osl_File_E_IO; 83 break; 84 85 case ENXIO: 86 osl_error = osl_File_E_IO; 87 break; 88 89 case E2BIG: 90 osl_error = osl_File_E_2BIG; 91 break; 92 93 case ENOEXEC: 94 osl_error = osl_File_E_NOEXEC; 95 break; 96 97 case EBADF: 98 osl_error = osl_File_E_BADF; 99 break; 100 101 case ECHILD: 102 osl_error = osl_File_E_CHILD; 103 break; 104 105 case EAGAIN: 106 osl_error = osl_File_E_AGAIN; 107 break; 108 109 case ENOMEM: 110 osl_error = osl_File_E_NOMEM; 111 break; 112 113 case EACCES: 114 osl_error = osl_File_E_ACCES; 115 break; 116 117 case EFAULT: 118 osl_error = osl_File_E_FAULT; 119 break; 120 121 case EBUSY: 122 osl_error = osl_File_E_BUSY; 123 break; 124 125 case EEXIST: 126 osl_error = osl_File_E_EXIST; 127 break; 128 129 case EXDEV: 130 osl_error = osl_File_E_XDEV; 131 break; 132 133 case ENODEV: 134 osl_error = osl_File_E_NODEV; 135 break; 136 137 case ENOTDIR: 138 osl_error = osl_File_E_NOTDIR; 139 break; 140 141 case EISDIR: 142 osl_error = osl_File_E_ISDIR; 143 break; 144 145 case EINVAL: 146 osl_error = osl_File_E_INVAL; 147 break; 148 149 case ENFILE: 150 osl_error = osl_File_E_NFILE; 151 break; 152 153 case EMFILE: 154 osl_error = osl_File_E_MFILE; 155 break; 156 157 case ENOTTY: 158 osl_error = osl_File_E_NOTTY; 159 break; 160 161 case EFBIG: 162 osl_error = osl_File_E_FBIG; 163 break; 164 165 case ENOSPC: 166 osl_error = osl_File_E_NOSPC; 167 break; 168 169 case ESPIPE: 170 osl_error = osl_File_E_SPIPE; 171 break; 172 173 case EROFS: 174 osl_error = osl_File_E_ROFS; 175 break; 176 177 case EMLINK: 178 osl_error = osl_File_E_MLINK; 179 break; 180 181 case EPIPE: 182 osl_error = osl_File_E_PIPE; 183 break; 184 185 case EDOM: 186 osl_error = osl_File_E_DOM; 187 break; 188 189 case ERANGE: 190 osl_error = osl_File_E_RANGE; 191 break; 192 193 case EDEADLK: 194 osl_error = osl_File_E_DEADLK; 195 break; 196 197 case ENAMETOOLONG: 198 osl_error = osl_File_E_NAMETOOLONG; 199 break; 200 201 case ENOLCK: 202 osl_error = osl_File_E_NOLCK; 203 break; 204 205 case ENOSYS: 206 osl_error = osl_File_E_NOSYS; 207 break; 208 209 case ENOTEMPTY: 210 osl_error = osl_File_E_NOTEMPTY; 211 break; 212 213 case ELOOP: 214 osl_error = osl_File_E_LOOP; 215 break; 216 217 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) 218 case EILSEQ: 219 osl_error = osl_File_E_ILSEQ; 220 break; 221 #endif /* MACOSX */ 222 223 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) 224 case ENOLINK: 225 osl_error = osl_File_E_NOLINK; 226 break; 227 #endif /* MACOSX */ 228 229 #if !(defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) 230 case EMULTIHOP: 231 osl_error = osl_File_E_MULTIHOP; 232 break; 233 #endif /* MACOSX */ 234 235 case EUSERS: 236 osl_error = osl_File_E_USERS; 237 break; 238 239 case EOVERFLOW: 240 osl_error = osl_File_E_OVERFLOW; 241 break; 242 243 case ETIMEDOUT: 244 osl_error = osl_File_E_TIMEDOUT; 245 break; 246 247 default: 248 /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */ 249 osl_error = osl_File_E_invalidError; 250 break; 251 } 252 253 return osl_error; 254 } 255 256