michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Implementation of nsIFile for ``Unixy'' systems. michael@0: */ michael@0: michael@0: #ifndef _nsLocalFileUNIX_H_ michael@0: #define _nsLocalFileUNIX_H_ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "nscore.h" michael@0: #include "nsString.h" michael@0: #include "nsReadableUtils.h" michael@0: #include "nsIHashable.h" michael@0: #include "nsIClassInfoImpl.h" michael@0: #include "mozilla/Attributes.h" michael@0: #ifdef MOZ_WIDGET_COCOA michael@0: #include "nsILocalFileMac.h" michael@0: #endif michael@0: michael@0: /** michael@0: * we need these for statfs() michael@0: */ michael@0: #ifdef HAVE_SYS_STATVFS_H michael@0: #if defined(__osf__) && defined(__DECCXX) michael@0: extern "C" int statvfs(const char *, struct statvfs *); michael@0: #endif michael@0: #include michael@0: #endif michael@0: michael@0: #ifdef HAVE_SYS_STATFS_H michael@0: #include michael@0: #endif michael@0: michael@0: #ifdef HAVE_SYS_VFS_H michael@0: #include michael@0: #endif michael@0: michael@0: #ifdef HAVE_SYS_MOUNT_H michael@0: #include michael@0: #include michael@0: #endif michael@0: michael@0: #if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__)) michael@0: #define STATFS statvfs64 michael@0: #define F_BSIZE f_frsize michael@0: #elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__)) michael@0: #define STATFS statvfs michael@0: #define F_BSIZE f_frsize michael@0: #elif defined(HAVE_STATFS64) michael@0: #define STATFS statfs64 michael@0: #define F_BSIZE f_bsize michael@0: #elif defined(HAVE_STATFS) michael@0: #define STATFS statfs michael@0: #define F_BSIZE f_bsize michael@0: #endif michael@0: michael@0: // stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are michael@0: // 64-bit by default on OS X 10.6+. michael@0: #if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_MACOSX) michael@0: #if defined (AIX) michael@0: #if defined STAT michael@0: #undef STAT michael@0: #endif michael@0: #endif michael@0: #define STAT stat64 michael@0: #define LSTAT lstat64 michael@0: #define HAVE_STATS64 1 michael@0: #else michael@0: #define STAT stat michael@0: #define LSTAT lstat michael@0: #endif michael@0: michael@0: michael@0: class nsLocalFile MOZ_FINAL : michael@0: #ifdef MOZ_WIDGET_COCOA michael@0: public nsILocalFileMac, michael@0: #else michael@0: public nsILocalFile, michael@0: #endif michael@0: public nsIHashable michael@0: { michael@0: public: michael@0: NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID) michael@0: michael@0: nsLocalFile(); michael@0: michael@0: static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIFILE michael@0: NS_DECL_NSILOCALFILE michael@0: #ifdef MOZ_WIDGET_COCOA michael@0: NS_DECL_NSILOCALFILEMAC michael@0: #endif michael@0: NS_DECL_NSIHASHABLE michael@0: michael@0: public: michael@0: static void GlobalInit(); michael@0: static void GlobalShutdown(); michael@0: michael@0: private: michael@0: nsLocalFile(const nsLocalFile& other); michael@0: ~nsLocalFile() {} michael@0: michael@0: protected: michael@0: // This stat cache holds the *last stat* - it does not invalidate. michael@0: // Call "FillStatCache" whenever you want to stat our file. michael@0: struct STAT mCachedStat; michael@0: nsCString mPath; michael@0: michael@0: void LocateNativeLeafName(nsACString::const_iterator &, michael@0: nsACString::const_iterator &); michael@0: michael@0: nsresult CopyDirectoryTo(nsIFile *newParent); michael@0: nsresult CreateAllAncestors(uint32_t permissions); michael@0: nsresult GetNativeTargetPathName(nsIFile *newParent, michael@0: const nsACString &newName, michael@0: nsACString &_retval); michael@0: michael@0: bool FillStatCache(); michael@0: michael@0: nsresult CreateAndKeepOpen(uint32_t type, int flags, michael@0: uint32_t permissions, PRFileDesc **_retval); michael@0: }; michael@0: michael@0: #endif /* _nsLocalFileUNIX_H_ */