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)
26 # define LSTAT lstat64
27 # define HAVE_STATS64 1
33 #if defined(HAVE_SYS_QUOTA_H) && defined(HAVE_LINUX_QUOTA_H)
34 # define USE_LINUX_QUOTACTL
37 class nsLocalFile final
38 #ifdef MOZ_WIDGET_COCOA
39 : public nsILocalFileMac
45 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID
)
48 explicit nsLocalFile(const nsACString
& aFilePath
);
50 static nsresult
nsLocalFileConstructor(const nsIID
& aIID
,
53 NS_DECL_THREADSAFE_ISUPPORTS
55 #ifdef MOZ_WIDGET_COCOA
56 NS_DECL_NSILOCALFILEMAC
60 nsLocalFile(const nsLocalFile
& aOther
);
61 ~nsLocalFile() = default;
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
;
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
,
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
);
94 template <typename StatInfoFunc
>
95 nsresult
GetDiskInfo(StatInfoFunc
&& aStatInfoFunc
, int64_t* aResult
);
99 #endif /* _nsLocalFileUNIX_H_ */