1 | /* -*- Mode: C++; tab-width: 4; 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.org code.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
26 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
---|
39 | THIS INTERFACE IS DEPRECATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|.
|
---|
40 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
---|
41 |
|
---|
42 |
|
---|
43 | // This is the only correct cross-platform way to specify a file.
|
---|
44 | // Strings are not such a way. If you grew up on windows or unix, you
|
---|
45 | // may think they are. Welcome to reality.
|
---|
46 |
|
---|
47 | #include "nsISupports.idl"
|
---|
48 |
|
---|
49 | %{C++
|
---|
50 | #include "nsFileSpec.h" // for factory method
|
---|
51 | %}
|
---|
52 |
|
---|
53 | interface nsIFileURL;
|
---|
54 | interface nsIFilePath;
|
---|
55 | interface nsIOutputStream;
|
---|
56 | interface nsIInputStream;
|
---|
57 |
|
---|
58 | // Define Contractid and CID
|
---|
59 | %{C++
|
---|
60 |
|
---|
61 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
---|
62 | THIS INTERFACE IS DEPRECATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|.
|
---|
63 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
---|
64 |
|
---|
65 | // {A5740FA2-146E-11d3-B00D-00C04FC2E79B}
|
---|
66 | #define NS_FILESPEC_CID \
|
---|
67 | { 0xa5740fa2, 0x146e, 0x11d3, { 0xb0, 0xd, 0x0, 0xc0, 0x4f, 0xc2, 0xe7, 0x9b } }
|
---|
68 |
|
---|
69 | #define NS_FILESPEC_CONTRACTID "@mozilla.org/filespec;1"
|
---|
70 | #define NS_FILESPEC_CLASSNAME "File Spec"
|
---|
71 |
|
---|
72 | %}
|
---|
73 |
|
---|
74 | native nsFileSpec(nsFileSpec);
|
---|
75 | [ref] native nsFileSpecRef(nsFileSpec);
|
---|
76 | [ptr] native nsFileSpecPtr(nsFileSpec);
|
---|
77 |
|
---|
78 | [scriptable, uuid(d8c0a080-0868-11d3-915f-d9d889d48e3c)]
|
---|
79 | interface nsIFileSpec : nsISupports
|
---|
80 | {
|
---|
81 | void fromFileSpec([const] in nsIFileSpec original);
|
---|
82 |
|
---|
83 | attribute string URLString;
|
---|
84 | attribute string unixStyleFilePath;
|
---|
85 | attribute string persistentDescriptorString;
|
---|
86 | attribute string nativePath;
|
---|
87 |
|
---|
88 | readonly attribute string NSPRPath;
|
---|
89 |
|
---|
90 | void error();
|
---|
91 |
|
---|
92 | boolean isValid();
|
---|
93 | boolean failed();
|
---|
94 |
|
---|
95 | attribute string leafName;
|
---|
96 |
|
---|
97 | readonly attribute nsIFileSpec parent;
|
---|
98 | readonly attribute nsIInputStream inputStream;
|
---|
99 | readonly attribute nsIOutputStream outputStream;
|
---|
100 | boolean isChildOf(in nsIFileSpec possibleParent);
|
---|
101 | [noscript] readonly attribute nsFileSpec fileSpec;
|
---|
102 | [noscript] void setFromFileSpec([const] in nsFileSpecRef spec);
|
---|
103 |
|
---|
104 | attribute string fileContents;
|
---|
105 |
|
---|
106 | void makeUnique();
|
---|
107 | void makeUniqueWithSuggestedName(in string suggestedName);
|
---|
108 |
|
---|
109 | readonly attribute unsigned long modDate;
|
---|
110 | boolean modDateChanged(in unsigned long oldStamp);
|
---|
111 |
|
---|
112 | boolean isDirectory();
|
---|
113 | boolean isFile();
|
---|
114 | boolean exists();
|
---|
115 | boolean isHidden();
|
---|
116 |
|
---|
117 | boolean equals(in nsIFileSpec spec);
|
---|
118 |
|
---|
119 | readonly attribute unsigned long fileSize;
|
---|
120 | readonly attribute long long diskSpaceAvailable;
|
---|
121 |
|
---|
122 | void appendRelativeUnixPath(in string relativePath);
|
---|
123 |
|
---|
124 | void createDir();
|
---|
125 | void touch();
|
---|
126 |
|
---|
127 | boolean isSymlink();
|
---|
128 | void resolveSymlink();
|
---|
129 |
|
---|
130 | void delete(in boolean recursive);
|
---|
131 | void truncate(in long aNewLength);
|
---|
132 | void rename([const] in string newLeafName);
|
---|
133 | void copyToDir([const] in nsIFileSpec newParentDir);
|
---|
134 | void moveToDir([const] in nsIFileSpec newParentDir);
|
---|
135 | void execute([const] in string args);
|
---|
136 |
|
---|
137 | void openStreamForReading();
|
---|
138 | void openStreamForWriting();
|
---|
139 | void openStreamForReadingAndWriting();
|
---|
140 | void closeStream();
|
---|
141 | boolean isStreamOpen();
|
---|
142 |
|
---|
143 | boolean eof();
|
---|
144 | long read(inout string buffer, in long requestedCount);
|
---|
145 | void readLine(inout string line, in long bufferSize, out boolean wasTruncated);
|
---|
146 |
|
---|
147 | /** Check eof() before each call.
|
---|
148 | * CAUTION: false result only indicates line was truncated
|
---|
149 | * to fit buffer, or an error occurred (OTHER THAN eof).
|
---|
150 | */
|
---|
151 | long write(in string data, in long requestedCount);
|
---|
152 | void flush();
|
---|
153 |
|
---|
154 | void seek(in long offset);
|
---|
155 | long tell();
|
---|
156 | void endLine();
|
---|
157 | attribute AString unicodePath;
|
---|
158 |
|
---|
159 | };
|
---|
160 |
|
---|
161 | // Define Contractid and CID
|
---|
162 | %{C++
|
---|
163 | // {a3020981-2018-11d3-915f-a957795b7ebc}
|
---|
164 | #define NS_DIRECTORYITERATOR_CID \
|
---|
165 | { 0xa3020981, 0x2018, 0x11d3, { 0x91, 0x5f, 0xa9, 0x57, 0x79, 0x5b, 0x7e, 0xbc } }
|
---|
166 |
|
---|
167 | #define NS_DIRECTORYITERATOR_CONTRACTID "@mozilla.org/directoryiterator;1"
|
---|
168 | #define NS_DIRECTORYITERATOR_CLASSNAME "nsIDirectoryIterator"
|
---|
169 | %}
|
---|
170 |
|
---|
171 | [scriptable, uuid(d8c0a083-0868-11d3-915f-d9d889d48e3c)]
|
---|
172 | interface nsIDirectoryIterator : nsISupports
|
---|
173 | {
|
---|
174 | void init(in nsIFileSpec parent, in boolean resolveSymlink);
|
---|
175 | boolean exists();
|
---|
176 | void next();
|
---|
177 | readonly attribute nsIFileSpec currentSpec;
|
---|
178 | };
|
---|
179 |
|
---|
180 | %{C++
|
---|
181 | // Factory methods if you link with xpcom
|
---|
182 | NS_COM_OBSOLETE nsresult NS_NewFileSpecWithSpec(const nsFileSpec& aSrcFileSpec, nsIFileSpec **result);
|
---|
183 | NS_COM_OBSOLETE nsresult NS_NewFileSpec(nsIFileSpec** result);
|
---|
184 | NS_COM_OBSOLETE nsresult NS_NewDirectoryIterator(nsIDirectoryIterator** result);
|
---|
185 |
|
---|
186 | // Convert from nsIFile to nsIFileSpec
|
---|
187 | //
|
---|
188 | // XXX This function is here only to assist with the migration from nsIFileSpec
|
---|
189 | // to nsIFile. This function will dissappear in future mozilla releases.
|
---|
190 | //
|
---|
191 | // ...ripped from nsPrefService.cpp:
|
---|
192 | //
|
---|
193 | // "So discouraged is the use of nsIFileSpec, nobody wanted to have this routine be
|
---|
194 | // public - It might lead to continued use of nsIFileSpec. Right now, [mozilla] has
|
---|
195 | // such a need for it, here it is. Let's stop having to use it though."
|
---|
196 | //
|
---|
197 | NS_COM_OBSOLETE nsresult NS_NewFileSpecFromIFile(nsIFile *aFile, nsIFileSpec **result);
|
---|
198 |
|
---|
199 | #define NS_BOOL_ACCESSOR(_method) { PRBool yes; return NS_SUCCEEDED(f->_method(&yes)) && yes; }
|
---|
200 | inline PRBool Exists(nsIFileSpec* f) NS_BOOL_ACCESSOR(Exists)
|
---|
201 | inline PRBool Exists(nsIDirectoryIterator* f) NS_BOOL_ACCESSOR(Exists)
|
---|
202 | inline PRBool IsDirectory(nsIFileSpec* f) NS_BOOL_ACCESSOR(IsDirectory)
|
---|
203 |
|
---|
204 | %}
|
---|