1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is Mozilla Communicator client code, released
|
---|
16 | * March 31, 1998.
|
---|
17 | *
|
---|
18 | * The Initial Developer of the Original Code is
|
---|
19 | * Netscape Communications Corporation.
|
---|
20 | * Portions created by the Initial Developer are Copyright (C) 1998-1999
|
---|
21 | * the Initial Developer. All Rights Reserved.
|
---|
22 | *
|
---|
23 | * Contributor(s):
|
---|
24 | * Mike Shaver <[email protected]>
|
---|
25 | *
|
---|
26 | * Alternatively, the contents of this file may be used under the terms of
|
---|
27 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
28 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
29 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
30 | * of those above. If you wish to allow use of your version of this file only
|
---|
31 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
32 | * use your version of this file under the terms of the MPL, indicate your
|
---|
33 | * decision by deleting the provisions above and replace them with the notice
|
---|
34 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
35 | * the provisions above, a recipient may use your version of this file under
|
---|
36 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
37 | *
|
---|
38 | * ***** END LICENSE BLOCK ***** */
|
---|
39 |
|
---|
40 | /*
|
---|
41 | * Implementation of nsIFile for ``Unixy'' systems.
|
---|
42 | */
|
---|
43 |
|
---|
44 | #ifndef _nsLocalFileUNIX_H_
|
---|
45 | #define _nsLocalFileUNIX_H_
|
---|
46 |
|
---|
47 | #include <sys/stat.h>
|
---|
48 | #include <sys/types.h>
|
---|
49 | #include <unistd.h>
|
---|
50 |
|
---|
51 | #include "nscore.h"
|
---|
52 | #include "nsString.h"
|
---|
53 | #include "nsReadableUtils.h"
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * we need these for statfs()
|
---|
57 | */
|
---|
58 | #ifdef HAVE_SYS_STATVFS_H
|
---|
59 | #if defined(__osf__) && defined(__DECCXX)
|
---|
60 | extern "C" int statvfs(const char *, struct statvfs *);
|
---|
61 | #endif
|
---|
62 | #include <sys/statvfs.h>
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | #ifdef HAVE_SYS_STATFS_H
|
---|
66 | #include <sys/statfs.h>
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | #ifdef HAVE_STATVFS
|
---|
70 | #define STATFS statvfs
|
---|
71 | #else
|
---|
72 | #define STATFS statfs
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | // so we can statfs on freebsd
|
---|
76 | #if defined(__FreeBSD__)
|
---|
77 | #define HAVE_SYS_STATFS_H
|
---|
78 | #define STATFS statfs
|
---|
79 | #include <sys/param.h>
|
---|
80 | #include <sys/mount.h>
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | class NS_COM nsLocalFile : public nsILocalFile
|
---|
84 | {
|
---|
85 | public:
|
---|
86 | NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
|
---|
87 |
|
---|
88 | nsLocalFile();
|
---|
89 |
|
---|
90 | static NS_METHOD nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
---|
91 |
|
---|
92 | // nsISupports
|
---|
93 | NS_DECL_ISUPPORTS
|
---|
94 |
|
---|
95 | // nsIFile
|
---|
96 | NS_DECL_NSIFILE
|
---|
97 |
|
---|
98 | // nsILocalFile
|
---|
99 | NS_DECL_NSILOCALFILE
|
---|
100 |
|
---|
101 | public:
|
---|
102 | static void GlobalInit();
|
---|
103 | static void GlobalShutdown();
|
---|
104 |
|
---|
105 | private:
|
---|
106 | nsLocalFile(const nsLocalFile& other);
|
---|
107 | ~nsLocalFile() {}
|
---|
108 |
|
---|
109 | protected:
|
---|
110 | struct stat mCachedStat;
|
---|
111 | nsCString mPath;
|
---|
112 | PRPackedBool mHaveCachedStat;
|
---|
113 |
|
---|
114 | void LocateNativeLeafName(nsACString::const_iterator &,
|
---|
115 | nsACString::const_iterator &);
|
---|
116 |
|
---|
117 | nsresult CopyDirectoryTo(nsIFile *newParent);
|
---|
118 | nsresult CreateAllAncestors(PRUint32 permissions);
|
---|
119 | nsresult GetNativeTargetPathName(nsIFile *newParent,
|
---|
120 | const nsACString &newName,
|
---|
121 | nsACString &_retval);
|
---|
122 |
|
---|
123 | void InvalidateCache() {
|
---|
124 | mHaveCachedStat = PR_FALSE;
|
---|
125 | }
|
---|
126 | nsresult FillStatCache();
|
---|
127 |
|
---|
128 | nsresult CreateAndKeepOpen(PRUint32 type, PRIntn flags,
|
---|
129 | PRUint32 permissions, PRFileDesc **_retval);
|
---|
130 | };
|
---|
131 |
|
---|
132 | #endif /* _nsLocalFileUNIX_H_ */
|
---|