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
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/
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
15 * The Original Code is mozilla.org code.
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.
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.
36 * ***** END LICENSE BLOCK ***** */
38 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
39 THIS INTERFACE IS DEPRECATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|.
40 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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.
47 #include
"nsISupports.idl"
50 #include
"nsFileSpec.h" // for factory method
54 interface nsIFilePath
;
55 interface nsIOutputStream
;
56 interface nsIInputStream
;
58 // Define Contractid and CID
61 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
62 THIS INTERFACE IS DEPRECATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|.
63 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
65 // {A5740FA2-146E-11d3-B00D-00C04FC2E79B}
66 #define NS_FILESPEC_CID \
67 { 0xa5740fa2, 0x146e, 0x11d3, { 0xb0, 0xd, 0x0, 0xc0, 0x4f, 0xc2, 0xe7, 0x9b } }
69 #define NS_FILESPEC_CONTRACTID
"@mozilla.org/filespec;1"
70 #define NS_FILESPEC_CLASSNAME
"File Spec"
74 native nsFileSpec
(nsFileSpec
);
75 [ref] native nsFileSpecRef
(nsFileSpec
);
76 [ptr] native nsFileSpecPtr
(nsFileSpec
);
78 [scriptable
, uuid(37ef2e71
-edef
-46c7
-acd9
-f0b6e0b15083
)]
79 interface nsIFileSpec
: nsISupports
81 void fromFileSpec
([const] in nsIFileSpec original
);
83 attribute
string URLString
;
84 attribute
string unixStyleFilePath
;
85 attribute
string persistentDescriptorString
;
86 attribute
string nativePath
;
88 readonly attribute
string NSPRPath
;
95 attribute
string leafName
;
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
);
104 attribute
string fileContents
;
107 void makeUniqueWithSuggestedName
(in string suggestedName
);
109 void makeUniqueDir
();
110 void makeUniqueDirWithSuggestedName
(in string suggestedName
);
112 readonly attribute
unsigned long modDate
;
113 boolean modDateChanged
(in unsigned long oldStamp
);
115 boolean isDirectory
();
120 boolean equals
(in nsIFileSpec spec
);
122 readonly attribute
unsigned long fileSize
;
123 readonly attribute
long long diskSpaceAvailable
;
125 void appendRelativeUnixPath
(in string relativePath
);
131 void resolveSymlink
();
133 void delete
(in boolean recursive
);
134 void truncate
(in long aNewLength
);
135 void rename
([const] in string newLeafName
);
136 void copyToDir
([const] in nsIFileSpec newParentDir
);
137 void moveToDir
([const] in nsIFileSpec newParentDir
);
138 void execute
([const] in string args
);
140 void openStreamForReading
();
141 void openStreamForWriting
();
142 void openStreamForReadingAndWriting
();
144 boolean isStreamOpen
();
147 long read
(inout
string buffer
, in long requestedCount
);
148 void readLine
(inout
string line
, in long bufferSize
, out boolean wasTruncated
);
150 /** Check eof() before each call.
151 * CAUTION: false result only indicates line was truncated
152 * to fit buffer, or an error occurred (OTHER THAN eof).
154 long write
(in string data
, in long requestedCount
);
157 void seek
(in long offset
);
160 attribute AString unicodePath
;
164 // Define Contractid and CID
166 // {a3020981-2018-11d3-915f-a957795b7ebc}
167 #define NS_DIRECTORYITERATOR_CID \
168 { 0xa3020981, 0x2018, 0x11d3, { 0x91, 0x5f, 0xa9, 0x57, 0x79, 0x5b, 0x7e, 0xbc } }
170 #define NS_DIRECTORYITERATOR_CONTRACTID
"@mozilla.org/directoryiterator;1"
171 #define NS_DIRECTORYITERATOR_CLASSNAME
"nsIDirectoryIterator"
174 [scriptable
, uuid(d8c0a083
-0868-11d3
-915f
-d9d889d48e3c
)]
175 interface nsIDirectoryIterator
: nsISupports
177 void init
(in nsIFileSpec parent
, in boolean resolveSymlink
);
180 readonly attribute nsIFileSpec currentSpec
;
184 // Factory methods if you link with xpcom
185 NS_COM_OBSOLETE nsresult NS_NewFileSpecWithSpec
(const nsFileSpec
& aSrcFileSpec
, nsIFileSpec
**result
);
186 NS_COM_OBSOLETE nsresult NS_NewFileSpec
(nsIFileSpec
** result
);
187 NS_COM_OBSOLETE nsresult NS_NewDirectoryIterator
(nsIDirectoryIterator
** result
);
189 // Convert from nsIFile to nsIFileSpec
191 // XXX This function is here only to assist with the migration from nsIFileSpec
192 // to nsIFile. This function will dissappear in future mozilla releases.
194 // ...ripped from nsPrefService.cpp:
196 // "So discouraged is the use of nsIFileSpec, nobody wanted to have this routine be
197 // public - It might lead to continued use of nsIFileSpec. Right now, [mozilla] has
198 // such a need for it, here it is. Let's stop having to use it though."
200 NS_COM_OBSOLETE nsresult NS_NewFileSpecFromIFile
(nsIFile
*aFile
, nsIFileSpec
**result
);
202 #define NS_BOOL_ACCESSOR
(_method
) { PRBool yes
; return NS_SUCCEEDED
(f
->_method
(&yes
)) && yes
; }
203 inline PRBool Exists
(nsIFileSpec
* f
) NS_BOOL_ACCESSOR
(Exists
)
204 inline PRBool Exists
(nsIDirectoryIterator
* f
) NS_BOOL_ACCESSOR
(Exists
)
205 inline PRBool IsDirectory
(nsIFileSpec
* f
) NS_BOOL_ACCESSOR
(IsDirectory
)