Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/io/nsLocalFileUnix.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
/*
8
 * Implementation of nsIFile for ``Unixy'' systems.
9
 */
10
11
#ifndef _nsLocalFileUNIX_H_
12
#define _nsLocalFileUNIX_H_
13
14
#include <sys/stat.h>
15
#include <sys/types.h>
16
#include <unistd.h>
17
18
#include "nscore.h"
19
#include "nsString.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"
26
#endif
27
28
/**
29
 *  we need these for statfs()
30
 */
31
#ifdef HAVE_SYS_STATVFS_H
32
  #if defined(__osf__) && defined(__DECCXX)
33
    extern "C" int statvfs(const char *, struct statvfs *);
34
  #endif
35
  #include <sys/statvfs.h>
36
#endif
37
38
#ifdef HAVE_SYS_STATFS_H
39
  #include <sys/statfs.h>
40
#endif
41
42
#ifdef HAVE_SYS_VFS_H
43
  #include <sys/vfs.h>
44
#endif
45
46
#ifdef HAVE_SYS_MOUNT_H
47
  #include <sys/param.h>
48
  #include <sys/mount.h>
49
#endif
50
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
0
  #define STATFS statfs64
59
0
  #define F_BSIZE f_bsize
60
#elif defined(HAVE_STATFS)
61
  #define STATFS statfs
62
  #define F_BSIZE f_bsize
63
#endif
64
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_DARWIN)
68
  #if defined (AIX)
69
    #if defined STAT
70
      #undef STAT
71
    #endif
72
  #endif
73
6
  #define STAT stat64
74
0
  #define LSTAT lstat64
75
  #define HAVE_STATS64 1
76
#else
77
  #define STAT stat
78
  #define LSTAT lstat
79
#endif
80
81
82
class nsLocalFile final
83
#ifdef MOZ_WIDGET_COCOA
84
  : public nsILocalFileMac
85
#else
86
  : public nsIFile
87
#endif
88
  , public nsIHashable
89
{
90
public:
91
  NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
92
93
  nsLocalFile();
94
  explicit nsLocalFile(const nsACString& aFilePath);
95
96
  static nsresult nsLocalFileConstructor(nsISupports* aOuter,
97
                                         const nsIID& aIID,
98
                                         void** aInstancePtr);
99
100
  NS_DECL_THREADSAFE_ISUPPORTS
101
  NS_DECL_NSIFILE
102
#ifdef MOZ_WIDGET_COCOA
103
  NS_DECL_NSILOCALFILEMAC
104
#endif
105
  NS_DECL_NSIHASHABLE
106
107
private:
108
  nsLocalFile(const nsLocalFile& aOther);
109
  ~nsLocalFile()
110
115
  {
111
115
  }
112
113
protected:
114
  // This stat cache holds the *last stat* - it does not invalidate.
115
  // Call "FillStatCache" whenever you want to stat our file.
116
  struct STAT  mCachedStat;
117
  nsCString    mPath;
118
119
  void LocateNativeLeafName(nsACString::const_iterator&,
120
                            nsACString::const_iterator&);
121
122
  nsresult CopyDirectoryTo(nsIFile* aNewParent);
123
  nsresult CreateAllAncestors(uint32_t aPermissions);
124
  nsresult GetNativeTargetPathName(nsIFile* aNewParent,
125
                                   const nsACString& aNewName,
126
                                   nsACString& aResult);
127
128
  bool FillStatCache();
129
130
  nsresult CreateAndKeepOpen(uint32_t aType, int aFlags,
131
                             uint32_t aPermissions, PRFileDesc** aResult);
132
};
133
134
#endif /* _nsLocalFileUNIX_H_ */