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/.
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
11 * Date Modified by Description of modification
12 * 04/20/2000 IBM Corp. OS/2 build.
15 #ifndef _NS_LOCAL_FILE_H_
16 #define _NS_LOCAL_FILE_H_
20 #define NS_LOCAL_FILE_CID {0x2e23e220, 0x60be, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
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);
34 // nsXPComInit needs to know about how we are implemented,
35 // so here we will export it. Other users should not depend
39 #include "nsILocalFile.h"
42 #include "nsLocalFileWin.h"
43 #elif defined(XP_UNIX)
44 #include "nsLocalFileUnix.h"
46 #error NOT_IMPLEMENTED
49 #define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
52 nsresultForErrno(int aErr
)
58 case EDQUOT
: /* Quota exceeded */
59 // FALLTHROUGH to return NS_ERROR_FILE_DISK_FULL
62 return NS_ERROR_FILE_DISK_FULL
;
64 case EISDIR
: /* Is a directory. */
65 return NS_ERROR_FILE_IS_DIRECTORY
;
68 return NS_ERROR_FILE_NAME_TOO_LONG
;
69 case ENOEXEC
: /* Executable file format error. */
70 return NS_ERROR_FILE_EXECUTION_FAILED
;
72 return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST
;
74 return NS_ERROR_FILE_DESTINATION_NOT_DIR
;
77 return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK
;
81 return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK
;
84 return NS_ERROR_FILE_ALREADY_EXISTS
;
89 return NS_ERROR_FILE_ACCESS_DENIED
;
91 case EROFS
: /* Read-only file system. */
92 return NS_ERROR_FILE_READ_ONLY
;
95 * On AIX 4.3, ENOTEMPTY is defined as EEXIST,
96 * so there can't be cases for both without
99 #if ENOTEMPTY != EEXIST
101 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.
111 case EFBIG
: /* File too large. */
112 return NS_ERROR_FILE_TOO_BIG
;
115 return NS_ERROR_FAILURE
;
119 #define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
121 void NS_StartupLocalFile();
122 void NS_ShutdownLocalFile();