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_
15 #include <sys/types.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"
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
*);
35 #include <sys/statvfs.h>
38 #ifdef HAVE_SYS_STATFS_H
39 #include <sys/statfs.h>
46 #ifdef HAVE_SYS_MOUNT_H
47 #include <sys/param.h>
48 #include <sys/mount.h>
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)
62 #define F_BSIZE f_bsize
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)
75 #define HAVE_STATS64 1
82 class nsLocalFile final
83 #ifdef MOZ_WIDGET_COCOA
84 : public nsILocalFileMac
91 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID
)
95 static nsresult
nsLocalFileConstructor(nsISupports
* aOuter
,
99 NS_DECL_THREADSAFE_ISUPPORTS
102 #ifdef MOZ_WIDGET_COCOA
103 NS_DECL_NSILOCALFILEMAC
108 static void GlobalInit();
109 static void GlobalShutdown();
112 nsLocalFile(const nsLocalFile
& aOther
);
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
;
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_ */