Backed out 2 changesets (bug 1908320) for causing wr failures on align-items-baseline...
[gecko.git] / xpcom / io / nsLocalFileUnix.h
blob3a0f033350704f5c00db8f70e00eeb0fc6afc896
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>
16 #include "nscore.h"
17 #include "nsString.h"
18 #ifdef MOZ_WIDGET_COCOA
19 # include "nsILocalFileMac.h"
20 #endif
22 // stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are
23 // 64-bit by default on OS X 10.6+.
24 #if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_DARWIN)
25 # define STAT stat64
26 # define LSTAT lstat64
27 # define HAVE_STATS64 1
28 #else
29 # define STAT stat
30 # define LSTAT lstat
31 #endif
33 #if defined(HAVE_SYS_QUOTA_H) && defined(HAVE_LINUX_QUOTA_H)
34 # define USE_LINUX_QUOTACTL
35 #endif
37 class nsLocalFile final
38 #ifdef MOZ_WIDGET_COCOA
39 : public nsILocalFileMac
40 #else
41 : public nsIFile
42 #endif
44 public:
45 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
47 nsLocalFile();
48 explicit nsLocalFile(const nsACString& aFilePath);
50 static nsresult nsLocalFileConstructor(const nsIID& aIID,
51 void** aInstancePtr);
53 NS_DECL_THREADSAFE_ISUPPORTS
54 NS_DECL_NSIFILE
55 #ifdef MOZ_WIDGET_COCOA
56 NS_DECL_NSILOCALFILEMAC
57 #endif
59 private:
60 nsLocalFile(const nsLocalFile& aOther);
61 ~nsLocalFile() = default;
63 protected:
64 // This stat cache holds the *last stat* - it does not invalidate.
65 // Call "FillStatCache" whenever you want to stat our file.
66 struct STAT mCachedStat;
67 nsCString mPath;
69 void LocateNativeLeafName(nsACString::const_iterator&,
70 nsACString::const_iterator&);
72 nsresult CopyDirectoryTo(nsIFile* aNewParent);
73 nsresult CreateAllAncestors(uint32_t aPermissions);
74 nsresult GetNativeTargetPathName(nsIFile* aNewParent,
75 const nsACString& aNewName,
76 nsACString& aResult);
78 bool FillStatCache();
80 nsresult CreateAndKeepOpen(uint32_t aType, int aFlags, uint32_t aPermissions,
81 bool aSkipAncestors, PRFileDesc** aResult);
83 enum class TimeField { AccessedTime, ModifiedTime };
84 nsresult SetTimeImpl(PRTime aTime, TimeField aTimeField, bool aFollowLinks);
85 nsresult GetTimeImpl(PRTime* aTime, TimeField aTimeField, bool aFollowLinks);
87 nsresult GetCreationTimeImpl(PRTime* aCreationTime, bool aFollowLinks);
89 #if defined(USE_LINUX_QUOTACTL)
90 template <typename StatInfoFunc, typename QuotaInfoFunc>
91 nsresult GetDiskInfo(StatInfoFunc&& aStatInfoFunc,
92 QuotaInfoFunc&& aQuotaInfoFunc, int64_t* aResult);
93 #else
94 template <typename StatInfoFunc>
95 nsresult GetDiskInfo(StatInfoFunc&& aStatInfoFunc, int64_t* aResult);
96 #endif
99 #endif /* _nsLocalFileUNIX_H_ */