summaryrefslogtreecommitdiffstats
path: root/src/libs/xpcom18a4/xpcom/obsolete/nsIFileSpec.idl
blob: 78abd9e751cb46645cc03d47df00b1db6ef76ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
    THIS INTERFACE IS DEPRECATED AND UNSUPPORTED!  USE |nsIFile| and |nsILocalFile|.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


// This is the only correct cross-platform way to specify a file.
// Strings are not such a way. If you grew up on windows or unix, you
// may think they are. Welcome to reality.

#include "nsISupports.idl"

%{C++
#include "nsFileSpec.h" // for factory method
%}

interface nsIFileURL;
interface nsIFilePath;
interface nsIOutputStream;
interface nsIInputStream;

// Define Contractid and CID
%{C++

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
    THIS INTERFACE IS DEPRECATED AND UNSUPPORTED!  USE |nsIFile| and |nsILocalFile|.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

// {A5740FA2-146E-11d3-B00D-00C04FC2E79B} 
#define NS_FILESPEC_CID \
{ 0xa5740fa2, 0x146e, 0x11d3, { 0xb0, 0xd, 0x0, 0xc0, 0x4f, 0xc2, 0xe7, 0x9b } }

#define NS_FILESPEC_CONTRACTID "@mozilla.org/filespec;1"
#define NS_FILESPEC_CLASSNAME "File Spec"

%}

      native nsFileSpec(nsFileSpec);
[ref] native nsFileSpecRef(nsFileSpec);
[ptr] native nsFileSpecPtr(nsFileSpec);

[scriptable, uuid(d8c0a080-0868-11d3-915f-d9d889d48e3c)]
interface nsIFileSpec : nsISupports
{
	void fromFileSpec([const] in nsIFileSpec original);

	attribute string URLString;
	attribute string unixStyleFilePath;
	attribute string persistentDescriptorString;
	attribute string nativePath;

	readonly attribute string NSPRPath;

	void error();

	boolean isValid();
	boolean failed();

	attribute string leafName;

	readonly attribute nsIFileSpec parent;
	readonly attribute nsIInputStream inputStream;
	readonly attribute nsIOutputStream outputStream;
    boolean isChildOf(in nsIFileSpec possibleParent);
	[noscript] readonly attribute nsFileSpec fileSpec;
	[noscript] void setFromFileSpec([const] in nsFileSpecRef spec);
	
	attribute string fileContents;

	void makeUnique();
	void makeUniqueWithSuggestedName(in string suggestedName);

	readonly attribute unsigned long modDate;
	boolean modDateChanged(in unsigned long oldStamp);

	boolean isDirectory();
	boolean isFile();
	boolean exists();
	boolean isHidden();

	boolean equals(in nsIFileSpec spec);

	readonly attribute unsigned long fileSize;
	readonly attribute long long diskSpaceAvailable;

	void appendRelativeUnixPath(in string relativePath);

	void createDir();
	void touch();
    
	boolean isSymlink();
	void resolveSymlink();

	void delete(in boolean recursive);
    void truncate(in long aNewLength);
	void rename([const] in string newLeafName);
	void copyToDir([const] in nsIFileSpec newParentDir);
	void moveToDir([const] in nsIFileSpec newParentDir);
	void execute([const] in string args);
	
	void openStreamForReading();
	void openStreamForWriting();
	void openStreamForReadingAndWriting();
	void closeStream();
	boolean isStreamOpen();
	
	boolean eof();
	long read(inout string buffer, in long requestedCount);
	void readLine(inout string line, in long bufferSize, out boolean wasTruncated);

    /** Check eof() before each call.
     * CAUTION: false result only indicates line was truncated
     * to fit buffer, or an error occurred (OTHER THAN eof).
     */
	long write(in string data, in long requestedCount);
	void flush();
	
	void seek(in long offset);
	long tell();
	void endLine();
	attribute AString unicodePath;
	
};
	
// Define Contractid and CID
%{C++
// {a3020981-2018-11d3-915f-a957795b7ebc}
#define NS_DIRECTORYITERATOR_CID \
{ 0xa3020981, 0x2018, 0x11d3, { 0x91, 0x5f, 0xa9, 0x57, 0x79, 0x5b, 0x7e, 0xbc } }

#define NS_DIRECTORYITERATOR_CONTRACTID "@mozilla.org/directoryiterator;1"
#define NS_DIRECTORYITERATOR_CLASSNAME "nsIDirectoryIterator"
%}

[scriptable, uuid(d8c0a083-0868-11d3-915f-d9d889d48e3c)]
interface nsIDirectoryIterator : nsISupports
{
	void init(in nsIFileSpec parent, in boolean resolveSymlink);
	boolean exists();
	void next();
	readonly attribute nsIFileSpec currentSpec;
};

%{C++
// Factory methods if you link with xpcom
NS_COM_OBSOLETE nsresult NS_NewFileSpecWithSpec(const nsFileSpec& aSrcFileSpec, nsIFileSpec **result);
NS_COM_OBSOLETE nsresult NS_NewFileSpec(nsIFileSpec** result);
NS_COM_OBSOLETE nsresult NS_NewDirectoryIterator(nsIDirectoryIterator** result);

// Convert from nsIFile to nsIFileSpec
//
// XXX This function is here only to assist with the migration from nsIFileSpec
// to nsIFile.  This function will dissappear in future mozilla releases.
//
// ...ripped from nsPrefService.cpp:
//
//   "So discouraged is the use of nsIFileSpec, nobody wanted to have this routine be
//    public - It might lead to continued use of nsIFileSpec. Right now, [mozilla] has
//    such a need for it, here it is. Let's stop having to use it though."
//
NS_COM_OBSOLETE nsresult NS_NewFileSpecFromIFile(nsIFile *aFile, nsIFileSpec **result);

#define NS_BOOL_ACCESSOR(_method) { PRBool yes; return NS_SUCCEEDED(f->_method(&yes)) && yes; }
inline PRBool Exists(nsIFileSpec* f) NS_BOOL_ACCESSOR(Exists)
inline PRBool Exists(nsIDirectoryIterator* f) NS_BOOL_ACCESSOR(Exists)
inline PRBool IsDirectory(nsIFileSpec* f) NS_BOOL_ACCESSOR(IsDirectory)

%}