1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsLocalFileUnix.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,133 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * Implementation of nsIFile for ``Unixy'' systems. 1.11 + */ 1.12 + 1.13 +#ifndef _nsLocalFileUNIX_H_ 1.14 +#define _nsLocalFileUNIX_H_ 1.15 + 1.16 +#include <sys/stat.h> 1.17 +#include <sys/types.h> 1.18 +#include <unistd.h> 1.19 + 1.20 +#include "nscore.h" 1.21 +#include "nsString.h" 1.22 +#include "nsReadableUtils.h" 1.23 +#include "nsIHashable.h" 1.24 +#include "nsIClassInfoImpl.h" 1.25 +#include "mozilla/Attributes.h" 1.26 +#ifdef MOZ_WIDGET_COCOA 1.27 +#include "nsILocalFileMac.h" 1.28 +#endif 1.29 + 1.30 +/** 1.31 + * we need these for statfs() 1.32 + */ 1.33 +#ifdef HAVE_SYS_STATVFS_H 1.34 + #if defined(__osf__) && defined(__DECCXX) 1.35 + extern "C" int statvfs(const char *, struct statvfs *); 1.36 + #endif 1.37 + #include <sys/statvfs.h> 1.38 +#endif 1.39 + 1.40 +#ifdef HAVE_SYS_STATFS_H 1.41 + #include <sys/statfs.h> 1.42 +#endif 1.43 + 1.44 +#ifdef HAVE_SYS_VFS_H 1.45 + #include <sys/vfs.h> 1.46 +#endif 1.47 + 1.48 +#ifdef HAVE_SYS_MOUNT_H 1.49 + #include <sys/param.h> 1.50 + #include <sys/mount.h> 1.51 +#endif 1.52 + 1.53 +#if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__)) 1.54 + #define STATFS statvfs64 1.55 + #define F_BSIZE f_frsize 1.56 +#elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__)) 1.57 + #define STATFS statvfs 1.58 + #define F_BSIZE f_frsize 1.59 +#elif defined(HAVE_STATFS64) 1.60 + #define STATFS statfs64 1.61 + #define F_BSIZE f_bsize 1.62 +#elif defined(HAVE_STATFS) 1.63 + #define STATFS statfs 1.64 + #define F_BSIZE f_bsize 1.65 +#endif 1.66 + 1.67 +// stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are 1.68 +// 64-bit by default on OS X 10.6+. 1.69 +#if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_MACOSX) 1.70 + #if defined (AIX) 1.71 + #if defined STAT 1.72 + #undef STAT 1.73 + #endif 1.74 + #endif 1.75 + #define STAT stat64 1.76 + #define LSTAT lstat64 1.77 + #define HAVE_STATS64 1 1.78 +#else 1.79 + #define STAT stat 1.80 + #define LSTAT lstat 1.81 +#endif 1.82 + 1.83 + 1.84 +class nsLocalFile MOZ_FINAL : 1.85 +#ifdef MOZ_WIDGET_COCOA 1.86 + public nsILocalFileMac, 1.87 +#else 1.88 + public nsILocalFile, 1.89 +#endif 1.90 + public nsIHashable 1.91 +{ 1.92 +public: 1.93 + NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID) 1.94 + 1.95 + nsLocalFile(); 1.96 + 1.97 + static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); 1.98 + 1.99 + NS_DECL_THREADSAFE_ISUPPORTS 1.100 + NS_DECL_NSIFILE 1.101 + NS_DECL_NSILOCALFILE 1.102 +#ifdef MOZ_WIDGET_COCOA 1.103 + NS_DECL_NSILOCALFILEMAC 1.104 +#endif 1.105 + NS_DECL_NSIHASHABLE 1.106 + 1.107 +public: 1.108 + static void GlobalInit(); 1.109 + static void GlobalShutdown(); 1.110 + 1.111 +private: 1.112 + nsLocalFile(const nsLocalFile& other); 1.113 + ~nsLocalFile() {} 1.114 + 1.115 +protected: 1.116 + // This stat cache holds the *last stat* - it does not invalidate. 1.117 + // Call "FillStatCache" whenever you want to stat our file. 1.118 + struct STAT mCachedStat; 1.119 + nsCString mPath; 1.120 + 1.121 + void LocateNativeLeafName(nsACString::const_iterator &, 1.122 + nsACString::const_iterator &); 1.123 + 1.124 + nsresult CopyDirectoryTo(nsIFile *newParent); 1.125 + nsresult CreateAllAncestors(uint32_t permissions); 1.126 + nsresult GetNativeTargetPathName(nsIFile *newParent, 1.127 + const nsACString &newName, 1.128 + nsACString &_retval); 1.129 + 1.130 + bool FillStatCache(); 1.131 + 1.132 + nsresult CreateAndKeepOpen(uint32_t type, int flags, 1.133 + uint32_t permissions, PRFileDesc **_retval); 1.134 +}; 1.135 + 1.136 +#endif /* _nsLocalFileUNIX_H_ */