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/. */
8 * Implementation of nsIFile for ``Unixy'' systems.
11 #ifndef _nsLocalFileUNIX_H_
12 #define _nsLocalFileUNIX_H_
18 #ifdef MOZ_WIDGET_COCOA
19 # include "nsILocalFileMac.h"
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)
31 # define LSTAT lstat64
32 # define HAVE_STATS64 1
38 #if defined(HAVE_SYS_QUOTA_H) && defined(HAVE_LINUX_QUOTA_H)
39 # define USE_LINUX_QUOTACTL
42 class nsLocalFile final
43 #ifdef MOZ_WIDGET_COCOA
44 : public nsILocalFileMac
50 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID
)
53 explicit nsLocalFile(const nsACString
& aFilePath
);
55 static nsresult
nsLocalFileConstructor(const nsIID
& aIID
,
58 NS_DECL_THREADSAFE_ISUPPORTS
60 #ifdef MOZ_WIDGET_COCOA
61 NS_DECL_NSILOCALFILEMAC
65 nsLocalFile(const nsLocalFile
& aOther
);
66 ~nsLocalFile() = default;
69 // This stat cache holds the *last stat* - it does not invalidate.
70 // Call "FillStatCache" whenever you want to stat our file.
71 struct STAT mCachedStat
;
74 void LocateNativeLeafName(nsACString::const_iterator
&,
75 nsACString::const_iterator
&);
77 nsresult
CopyDirectoryTo(nsIFile
* aNewParent
);
78 nsresult
CreateAllAncestors(uint32_t aPermissions
);
79 nsresult
GetNativeTargetPathName(nsIFile
* aNewParent
,
80 const nsACString
& aNewName
,
85 nsresult
CreateAndKeepOpen(uint32_t aType
, int aFlags
, uint32_t aPermissions
,
86 bool aSkipAncestors
, PRFileDesc
** aResult
);
88 enum class TimeField
{ AccessedTime
, ModifiedTime
};
89 nsresult
SetTimeImpl(PRTime aTime
, TimeField aTimeField
, bool aFollowLinks
);
90 nsresult
GetTimeImpl(PRTime
* aTime
, TimeField aTimeField
, bool aFollowLinks
);
92 nsresult
GetCreationTimeImpl(PRTime
* aCreationTime
, bool aFollowLinks
);
94 #if defined(USE_LINUX_QUOTACTL)
95 template <typename StatInfoFunc
, typename QuotaInfoFunc
>
96 nsresult
GetDiskInfo(StatInfoFunc
&& aStatInfoFunc
,
97 QuotaInfoFunc
&& aQuotaInfoFunc
, int64_t* aResult
);
99 template <typename StatInfoFunc
>
100 nsresult
GetDiskInfo(StatInfoFunc
&& aStatInfoFunc
, int64_t* aResult
);
104 #endif /* _nsLocalFileUNIX_H_ */