LCOV - code coverage report
Current view: top level - libreoffice/sal/osl/unx - file_error_transl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 98 13.3 %
Date: 2012-12-27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10