Bumping manifests a=b2g-bump
[gecko.git] / xpcom / io / nsLocalFile.h
blobefe0e51d755c5c354240720fe3ff5a0a24e13cda
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_
18 #include "nscore.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
36 // on this.
38 #include <errno.h>
39 #include "nsILocalFile.h"
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
49 #define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
51 inline nsresult
52 nsresultForErrno(int aErr)
54 switch (aErr) {
55 case 0:
56 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 return NS_ERROR_FILE_DISK_FULL;
63 #ifdef EISDIR
64 case EISDIR: /* Is a directory. */
65 return NS_ERROR_FILE_IS_DIRECTORY;
66 #endif
67 case ENAMETOOLONG:
68 return NS_ERROR_FILE_NAME_TOO_LONG;
69 case ENOEXEC: /* Executable file format error. */
70 return NS_ERROR_FILE_EXECUTION_FAILED;
71 case ENOENT:
72 return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
73 case ENOTDIR:
74 return NS_ERROR_FILE_DESTINATION_NOT_DIR;
75 #ifdef ELOOP
76 case ELOOP:
77 return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
78 #endif /* ELOOP */
79 #ifdef ENOLINK
80 case ENOLINK:
81 return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
82 #endif /* ENOLINK */
83 case EEXIST:
84 return NS_ERROR_FILE_ALREADY_EXISTS;
85 #ifdef EPERM
86 case EPERM:
87 #endif /* EPERM */
88 case EACCES:
89 return NS_ERROR_FILE_ACCESS_DENIED;
90 #ifdef EROFS
91 case EROFS: /* Read-only file system. */
92 return NS_ERROR_FILE_READ_ONLY;
93 #endif
95 * On AIX 4.3, ENOTEMPTY is defined as EEXIST,
96 * so there can't be cases for both without
97 * preprocessing.
99 #if ENOTEMPTY != EEXIST
100 case ENOTEMPTY:
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;
114 default:
115 return NS_ERROR_FAILURE;
119 #define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
121 void NS_StartupLocalFile();
122 void NS_ShutdownLocalFile();
124 #endif