xpcom/io/nsLocalFileUnix.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * Implementation of nsIFile for ``Unixy'' systems.
michael@0 8 */
michael@0 9
michael@0 10 #ifndef _nsLocalFileUNIX_H_
michael@0 11 #define _nsLocalFileUNIX_H_
michael@0 12
michael@0 13 #include <sys/stat.h>
michael@0 14 #include <sys/types.h>
michael@0 15 #include <unistd.h>
michael@0 16
michael@0 17 #include "nscore.h"
michael@0 18 #include "nsString.h"
michael@0 19 #include "nsReadableUtils.h"
michael@0 20 #include "nsIHashable.h"
michael@0 21 #include "nsIClassInfoImpl.h"
michael@0 22 #include "mozilla/Attributes.h"
michael@0 23 #ifdef MOZ_WIDGET_COCOA
michael@0 24 #include "nsILocalFileMac.h"
michael@0 25 #endif
michael@0 26
michael@0 27 /**
michael@0 28 * we need these for statfs()
michael@0 29 */
michael@0 30 #ifdef HAVE_SYS_STATVFS_H
michael@0 31 #if defined(__osf__) && defined(__DECCXX)
michael@0 32 extern "C" int statvfs(const char *, struct statvfs *);
michael@0 33 #endif
michael@0 34 #include <sys/statvfs.h>
michael@0 35 #endif
michael@0 36
michael@0 37 #ifdef HAVE_SYS_STATFS_H
michael@0 38 #include <sys/statfs.h>
michael@0 39 #endif
michael@0 40
michael@0 41 #ifdef HAVE_SYS_VFS_H
michael@0 42 #include <sys/vfs.h>
michael@0 43 #endif
michael@0 44
michael@0 45 #ifdef HAVE_SYS_MOUNT_H
michael@0 46 #include <sys/param.h>
michael@0 47 #include <sys/mount.h>
michael@0 48 #endif
michael@0 49
michael@0 50 #if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__))
michael@0 51 #define STATFS statvfs64
michael@0 52 #define F_BSIZE f_frsize
michael@0 53 #elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__))
michael@0 54 #define STATFS statvfs
michael@0 55 #define F_BSIZE f_frsize
michael@0 56 #elif defined(HAVE_STATFS64)
michael@0 57 #define STATFS statfs64
michael@0 58 #define F_BSIZE f_bsize
michael@0 59 #elif defined(HAVE_STATFS)
michael@0 60 #define STATFS statfs
michael@0 61 #define F_BSIZE f_bsize
michael@0 62 #endif
michael@0 63
michael@0 64 // stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are
michael@0 65 // 64-bit by default on OS X 10.6+.
michael@0 66 #if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_MACOSX)
michael@0 67 #if defined (AIX)
michael@0 68 #if defined STAT
michael@0 69 #undef STAT
michael@0 70 #endif
michael@0 71 #endif
michael@0 72 #define STAT stat64
michael@0 73 #define LSTAT lstat64
michael@0 74 #define HAVE_STATS64 1
michael@0 75 #else
michael@0 76 #define STAT stat
michael@0 77 #define LSTAT lstat
michael@0 78 #endif
michael@0 79
michael@0 80
michael@0 81 class nsLocalFile MOZ_FINAL :
michael@0 82 #ifdef MOZ_WIDGET_COCOA
michael@0 83 public nsILocalFileMac,
michael@0 84 #else
michael@0 85 public nsILocalFile,
michael@0 86 #endif
michael@0 87 public nsIHashable
michael@0 88 {
michael@0 89 public:
michael@0 90 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
michael@0 91
michael@0 92 nsLocalFile();
michael@0 93
michael@0 94 static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
michael@0 95
michael@0 96 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 97 NS_DECL_NSIFILE
michael@0 98 NS_DECL_NSILOCALFILE
michael@0 99 #ifdef MOZ_WIDGET_COCOA
michael@0 100 NS_DECL_NSILOCALFILEMAC
michael@0 101 #endif
michael@0 102 NS_DECL_NSIHASHABLE
michael@0 103
michael@0 104 public:
michael@0 105 static void GlobalInit();
michael@0 106 static void GlobalShutdown();
michael@0 107
michael@0 108 private:
michael@0 109 nsLocalFile(const nsLocalFile& other);
michael@0 110 ~nsLocalFile() {}
michael@0 111
michael@0 112 protected:
michael@0 113 // This stat cache holds the *last stat* - it does not invalidate.
michael@0 114 // Call "FillStatCache" whenever you want to stat our file.
michael@0 115 struct STAT mCachedStat;
michael@0 116 nsCString mPath;
michael@0 117
michael@0 118 void LocateNativeLeafName(nsACString::const_iterator &,
michael@0 119 nsACString::const_iterator &);
michael@0 120
michael@0 121 nsresult CopyDirectoryTo(nsIFile *newParent);
michael@0 122 nsresult CreateAllAncestors(uint32_t permissions);
michael@0 123 nsresult GetNativeTargetPathName(nsIFile *newParent,
michael@0 124 const nsACString &newName,
michael@0 125 nsACString &_retval);
michael@0 126
michael@0 127 bool FillStatCache();
michael@0 128
michael@0 129 nsresult CreateAndKeepOpen(uint32_t type, int flags,
michael@0 130 uint32_t permissions, PRFileDesc **_retval);
michael@0 131 };
michael@0 132
michael@0 133 #endif /* _nsLocalFileUNIX_H_ */

mercurial