Bumping manifests a=b2g-bump
[gecko.git] / xpcom / io / nsLocalFileUnix.h
blobcacf716694e2ef450072ea0887d296e9cde6e73a
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 /*
8 * Implementation of nsIFile for ``Unixy'' systems.
9 */
11 #ifndef _nsLocalFileUNIX_H_
12 #define _nsLocalFileUNIX_H_
14 #include <sys/stat.h>
15 #include <sys/types.h>
16 #include <unistd.h>
18 #include "nscore.h"
19 #include "nsString.h"
20 #include "nsReadableUtils.h"
21 #include "nsIHashable.h"
22 #include "nsIClassInfoImpl.h"
23 #include "mozilla/Attributes.h"
24 #ifdef MOZ_WIDGET_COCOA
25 #include "nsILocalFileMac.h"
26 #endif
28 /**
29 * we need these for statfs()
31 #ifdef HAVE_SYS_STATVFS_H
32 #if defined(__osf__) && defined(__DECCXX)
33 extern "C" int statvfs(const char *, struct statvfs *);
34 #endif
35 #include <sys/statvfs.h>
36 #endif
38 #ifdef HAVE_SYS_STATFS_H
39 #include <sys/statfs.h>
40 #endif
42 #ifdef HAVE_SYS_VFS_H
43 #include <sys/vfs.h>
44 #endif
46 #ifdef HAVE_SYS_MOUNT_H
47 #include <sys/param.h>
48 #include <sys/mount.h>
49 #endif
51 #if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__))
52 #define STATFS statvfs64
53 #define F_BSIZE f_frsize
54 #elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__))
55 #define STATFS statvfs
56 #define F_BSIZE f_frsize
57 #elif defined(HAVE_STATFS64)
58 #define STATFS statfs64
59 #define F_BSIZE f_bsize
60 #elif defined(HAVE_STATFS)
61 #define STATFS statfs
62 #define F_BSIZE f_bsize
63 #endif
65 // stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are
66 // 64-bit by default on OS X 10.6+.
67 #if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_MACOSX)
68 #if defined (AIX)
69 #if defined STAT
70 #undef STAT
71 #endif
72 #endif
73 #define STAT stat64
74 #define LSTAT lstat64
75 #define HAVE_STATS64 1
76 #else
77 #define STAT stat
78 #define LSTAT lstat
79 #endif
82 class nsLocalFile MOZ_FINAL
83 #ifdef MOZ_WIDGET_COCOA
84 : public nsILocalFileMac
85 #else
86 : public nsILocalFile
87 #endif
88 , public nsIHashable
90 public:
91 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
93 nsLocalFile();
95 static nsresult nsLocalFileConstructor(nsISupports* aOuter,
96 const nsIID& aIID,
97 void** aInstancePtr);
99 NS_DECL_THREADSAFE_ISUPPORTS
100 NS_DECL_NSIFILE
101 NS_DECL_NSILOCALFILE
102 #ifdef MOZ_WIDGET_COCOA
103 NS_DECL_NSILOCALFILEMAC
104 #endif
105 NS_DECL_NSIHASHABLE
107 public:
108 static void GlobalInit();
109 static void GlobalShutdown();
111 private:
112 nsLocalFile(const nsLocalFile& aOther);
113 ~nsLocalFile()
117 protected:
118 // This stat cache holds the *last stat* - it does not invalidate.
119 // Call "FillStatCache" whenever you want to stat our file.
120 struct STAT mCachedStat;
121 nsCString mPath;
123 void LocateNativeLeafName(nsACString::const_iterator&,
124 nsACString::const_iterator&);
126 nsresult CopyDirectoryTo(nsIFile* aNewParent);
127 nsresult CreateAllAncestors(uint32_t aPermissions);
128 nsresult GetNativeTargetPathName(nsIFile* aNewParent,
129 const nsACString& aNewName,
130 nsACString& aResult);
132 bool FillStatCache();
134 nsresult CreateAndKeepOpen(uint32_t aType, int aFlags,
135 uint32_t aPermissions, PRFileDesc** aResult);
138 #endif /* _nsLocalFileUNIX_H_ */