xpcom/io/nsLocalFile.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial