1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsLocalFile.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,123 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + * 1.9 + * This Original Code has been modified by IBM Corporation. Modifications made by IBM 1.10 + * described herein are Copyright (c) International Business Machines Corporation, 2000. 1.11 + * Modifications to Mozilla code or documentation identified per MPL Section 3.3 1.12 + * 1.13 + * Date Modified by Description of modification 1.14 + * 04/20/2000 IBM Corp. OS/2 build. 1.15 + */ 1.16 + 1.17 +#ifndef _NS_LOCAL_FILE_H_ 1.18 +#define _NS_LOCAL_FILE_H_ 1.19 + 1.20 +#include "nscore.h" 1.21 + 1.22 +#define NS_LOCAL_FILE_CID {0x2e23e220, 0x60be, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}} 1.23 + 1.24 +#define NS_DECL_NSLOCALFILE_UNICODE_METHODS \ 1.25 + nsresult AppendUnicode(const char16_t *aNode); \ 1.26 + nsresult GetUnicodeLeafName(char16_t **aLeafName); \ 1.27 + nsresult SetUnicodeLeafName(const char16_t *aLeafName); \ 1.28 + nsresult CopyToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName); \ 1.29 + nsresult CopyToFollowingLinksUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName); \ 1.30 + nsresult MoveToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName); \ 1.31 + nsresult GetUnicodeTarget(char16_t **aTarget); \ 1.32 + nsresult GetUnicodePath(char16_t **aPath); \ 1.33 + nsresult InitWithUnicodePath(const char16_t *aPath); \ 1.34 + nsresult AppendRelativeUnicodePath(const char16_t *aRelativePath); 1.35 + 1.36 +// nsXPComInit needs to know about how we are implemented, 1.37 +// so here we will export it. Other users should not depend 1.38 +// on this. 1.39 + 1.40 +#include <errno.h> 1.41 +#include "nsILocalFile.h" 1.42 + 1.43 +#ifdef XP_WIN 1.44 +#include "nsLocalFileWin.h" 1.45 +#elif defined(XP_UNIX) 1.46 +#include "nsLocalFileUnix.h" 1.47 +#else 1.48 +#error NOT_IMPLEMENTED 1.49 +#endif 1.50 + 1.51 +#define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK) 1.52 + 1.53 +inline nsresult 1.54 +nsresultForErrno(int err) 1.55 +{ 1.56 + switch (err) { 1.57 + case 0: 1.58 + return NS_OK; 1.59 +#ifdef EDQUOT 1.60 + case EDQUOT: /* Quota exceeded */ 1.61 + // FALLTHROUGH to return NS_ERROR_FILE_DISK_FULL 1.62 +#endif 1.63 + case ENOSPC: 1.64 + return NS_ERROR_FILE_DISK_FULL; 1.65 +#ifdef EISDIR 1.66 + case EISDIR: /* Is a directory. */ 1.67 + return NS_ERROR_FILE_IS_DIRECTORY; 1.68 +#endif 1.69 + case ENAMETOOLONG: 1.70 + return NS_ERROR_FILE_NAME_TOO_LONG; 1.71 + case ENOEXEC: /* Executable file format error. */ 1.72 + return NS_ERROR_FILE_EXECUTION_FAILED; 1.73 + case ENOENT: 1.74 + return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; 1.75 + case ENOTDIR: 1.76 + return NS_ERROR_FILE_DESTINATION_NOT_DIR; 1.77 +#ifdef ELOOP 1.78 + case ELOOP: 1.79 + return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK; 1.80 +#endif /* ELOOP */ 1.81 +#ifdef ENOLINK 1.82 + case ENOLINK: 1.83 + return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK; 1.84 +#endif /* ENOLINK */ 1.85 + case EEXIST: 1.86 + return NS_ERROR_FILE_ALREADY_EXISTS; 1.87 +#ifdef EPERM 1.88 + case EPERM: 1.89 +#endif /* EPERM */ 1.90 + case EACCES: 1.91 + return NS_ERROR_FILE_ACCESS_DENIED; 1.92 +#ifdef EROFS 1.93 + case EROFS: /* Read-only file system. */ 1.94 + return NS_ERROR_FILE_READ_ONLY; 1.95 +#endif 1.96 + /* 1.97 + * On AIX 4.3, ENOTEMPTY is defined as EEXIST, 1.98 + * so there can't be cases for both without 1.99 + * preprocessing. 1.100 + */ 1.101 +#if ENOTEMPTY != EEXIST 1.102 + case ENOTEMPTY: 1.103 + return NS_ERROR_FILE_DIR_NOT_EMPTY; 1.104 +#endif /* ENOTEMPTY != EEXIST */ 1.105 + /* Note that nsIFile.createUnique() returns 1.106 + NS_ERROR_FILE_TOO_BIG when it cannot create a temporary 1.107 + file with a unique filename. 1.108 + See https://developer.mozilla.org/en-US/docs/Table_Of_Errors 1.109 + Other usages of NS_ERROR_FILE_TOO_BIG in the source tree 1.110 + are in line with the POSIX semantics of EFBIG. 1.111 + So this is a reasonably good approximation. 1.112 + */ 1.113 + case EFBIG: /* File too large. */ 1.114 + return NS_ERROR_FILE_TOO_BIG; 1.115 + 1.116 + default: 1.117 + return NS_ERROR_FAILURE; 1.118 + } 1.119 +} 1.120 + 1.121 +#define NSRESULT_FOR_ERRNO() nsresultForErrno(errno) 1.122 + 1.123 +void NS_StartupLocalFile(); 1.124 +void NS_ShutdownLocalFile(); 1.125 + 1.126 +#endif