LCOV - code coverage report
Current view: top level - xpcom/io - nsLocalFile.h (source / functions) Hit Total Coverage
Test: output.info Lines: 5 17 29.4 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       6             :  *
       7             :  * This Original Code has been modified by IBM Corporation. Modifications made by IBM
       8             :  * described herein are Copyright (c) International Business Machines Corporation, 2000.
       9             :  * Modifications to Mozilla code or documentation identified per MPL Section 3.3
      10             :  *
      11             :  * Date             Modified by     Description of modification
      12             :  * 04/20/2000       IBM Corp.      OS/2 build.
      13             :  */
      14             : 
      15             : #ifndef _NS_LOCAL_FILE_H_
      16             : #define _NS_LOCAL_FILE_H_
      17             : 
      18             : #include "nscore.h"
      19             : 
      20             : #define NS_LOCAL_FILE_CID {0x2e23e220, 0x60be, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
      21             : 
      22             : #define NS_DECL_NSLOCALFILE_UNICODE_METHODS                                                      \
      23             :   nsresult AppendUnicode(const char16_t *aNode);                                              \
      24             :   nsresult GetUnicodeLeafName(char16_t **aLeafName);                                          \
      25             :   nsresult SetUnicodeLeafName(const char16_t *aLeafName);                                     \
      26             :   nsresult CopyToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName);               \
      27             :   nsresult CopyToFollowingLinksUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName); \
      28             :   nsresult MoveToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName);               \
      29             :   nsresult GetUnicodeTarget(char16_t **aTarget);                                              \
      30             :   nsresult GetUnicodePath(char16_t **aPath);                                                  \
      31             :   nsresult InitWithUnicodePath(const char16_t *aPath);                                        \
      32             :   nsresult AppendRelativeUnicodePath(const char16_t *aRelativePath);
      33             : 
      34             : // XPCOMInit needs to know about how we are implemented,
      35             : // so here we will export it.  Other users should not depend
      36             : // on this.
      37             : 
      38             : #include <errno.h>
      39             : #include "nsILocalFile.h"
      40             : 
      41             : #ifdef XP_WIN
      42             : #include "nsLocalFileWin.h"
      43             : #elif defined(XP_UNIX)
      44             : #include "nsLocalFileUnix.h"
      45             : #else
      46             : #error NOT_IMPLEMENTED
      47             : #endif
      48             : 
      49             : #define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
      50             : 
      51             : inline nsresult
      52          85 : nsresultForErrno(int aErr)
      53             : {
      54          85 :   switch (aErr) {
      55             :     case 0:
      56          17 :       return NS_OK;
      57             : #ifdef EDQUOT
      58             :     case EDQUOT: /* Quota exceeded */
      59             :       // FALLTHROUGH to return NS_ERROR_FILE_DISK_FULL
      60             : #endif
      61             :     case ENOSPC:
      62           0 :       return NS_ERROR_FILE_DISK_FULL;
      63             : #ifdef EISDIR
      64             :     case EISDIR:    /*      Is a directory. */
      65           0 :       return NS_ERROR_FILE_IS_DIRECTORY;
      66             : #endif
      67             :     case ENAMETOOLONG:
      68           0 :       return NS_ERROR_FILE_NAME_TOO_LONG;
      69             :     case ENOEXEC:  /*     Executable file format error. */
      70           0 :       return NS_ERROR_FILE_EXECUTION_FAILED;
      71             :     case ENOENT:
      72          39 :       return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
      73             :     case ENOTDIR:
      74           0 :       return NS_ERROR_FILE_DESTINATION_NOT_DIR;
      75             : #ifdef ELOOP
      76             :     case ELOOP:
      77           0 :       return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
      78             : #endif /* ELOOP */
      79             : #ifdef ENOLINK
      80             :     case ENOLINK:
      81           0 :       return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
      82             : #endif /* ENOLINK */
      83             :     case EEXIST:
      84          29 :       return NS_ERROR_FILE_ALREADY_EXISTS;
      85             : #ifdef EPERM
      86             :     case EPERM:
      87             : #endif /* EPERM */
      88             :     case EACCES:
      89           0 :       return NS_ERROR_FILE_ACCESS_DENIED;
      90             : #ifdef EROFS
      91             :     case EROFS: /*     Read-only file system. */
      92           0 :       return NS_ERROR_FILE_READ_ONLY;
      93             : #endif
      94             :     /*
      95             :      * On AIX 4.3, ENOTEMPTY is defined as EEXIST,
      96             :      * so there can't be cases for both without
      97             :      * preprocessing.
      98             :      */
      99             : #if ENOTEMPTY != EEXIST
     100             :     case ENOTEMPTY:
     101           0 :       return NS_ERROR_FILE_DIR_NOT_EMPTY;
     102             : #endif /* ENOTEMPTY != EEXIST */
     103             :     /* Note that nsIFile.createUnique() returns
     104             :        NS_ERROR_FILE_TOO_BIG when it cannot create a temporary
     105             :        file with a unique filename.
     106             :        See https://developer.mozilla.org/en-US/docs/Table_Of_Errors
     107             :        Other usages of NS_ERROR_FILE_TOO_BIG in the source tree
     108             :        are in line with the POSIX semantics of EFBIG.
     109             :        So this is a reasonably good approximation.
     110             :     */
     111             :     case EFBIG: /*     File too large. */
     112           0 :       return NS_ERROR_FILE_TOO_BIG;
     113             : 
     114             :     default:
     115           0 :       return NS_ERROR_FAILURE;
     116             :   }
     117             : }
     118             : 
     119             : #define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
     120             : 
     121             : void NS_StartupLocalFile();
     122             : void NS_ShutdownLocalFile();
     123             : 
     124             : #endif

Generated by: LCOV version 1.13