Back to index

lightning-sunbird  0.9+nobinonly
nsIFileSpec.idl
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00039     THIS INTERFACE IS DEPRECATED AND UNSUPPORTED!  USE |nsIFile| and |nsILocalFile|.
00040  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00041 
00042 
00043 // This is the only correct cross-platform way to specify a file.
00044 // Strings are not such a way. If you grew up on windows or unix, you
00045 // may think they are. Welcome to reality.
00046 
00047 #include "nsISupports.idl"
00048 
00049 %{C++
00050 #include "nsFileSpec.h" // for factory method
00051 %}
00052 
00053 interface nsIFileURL;
00054 interface nsIFilePath;
00055 interface nsIOutputStream;
00056 interface nsIInputStream;
00057 
00058 // Define Contractid and CID
00059 %{C++
00060 
00061 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00062     THIS INTERFACE IS DEPRECATED AND UNSUPPORTED!  USE |nsIFile| and |nsILocalFile|.
00063  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00064 
00065 // {A5740FA2-146E-11d3-B00D-00C04FC2E79B} 
00066 #define NS_FILESPEC_CID \
00067 { 0xa5740fa2, 0x146e, 0x11d3, { 0xb0, 0xd, 0x0, 0xc0, 0x4f, 0xc2, 0xe7, 0x9b } }
00068 
00069 #define NS_FILESPEC_CONTRACTID "@mozilla.org/filespec;1"
00070 #define NS_FILESPEC_CLASSNAME "File Spec"
00071 
00072 %}
00073 
00074       native nsFileSpec(nsFileSpec);
00075 [ref] native nsFileSpecRef(nsFileSpec);
00076 [ptr] native nsFileSpecPtr(nsFileSpec);
00077 
00078 [scriptable, uuid(37ef2e71-edef-46c7-acd9-f0b6e0b15083)]
00079 interface nsIFileSpec : nsISupports
00080 {
00081        void fromFileSpec([const] in nsIFileSpec original);
00082 
00083        attribute string URLString;
00084        attribute string unixStyleFilePath;
00085        attribute string persistentDescriptorString;
00086        attribute string nativePath;
00087 
00088        readonly attribute string NSPRPath;
00089 
00090        void error();
00091 
00092        boolean isValid();
00093        boolean failed();
00094 
00095        attribute string leafName;
00096 
00097        readonly attribute nsIFileSpec parent;
00098        readonly attribute nsIInputStream inputStream;
00099        readonly attribute nsIOutputStream outputStream;
00100     boolean isChildOf(in nsIFileSpec possibleParent);
00101        [noscript] readonly attribute nsFileSpec fileSpec;
00102        [noscript] void setFromFileSpec([const] in nsFileSpecRef spec);
00103        
00104        attribute string fileContents;
00105 
00106        void makeUnique();
00107        void makeUniqueWithSuggestedName(in string suggestedName);
00108 
00109        void makeUniqueDir();
00110        void makeUniqueDirWithSuggestedName(in string suggestedName);
00111 
00112        readonly attribute unsigned long modDate;
00113        boolean modDateChanged(in unsigned long oldStamp);
00114 
00115        boolean isDirectory();
00116        boolean isFile();
00117        boolean exists();
00118        boolean isHidden();
00119 
00120        boolean equals(in nsIFileSpec spec);
00121 
00122        readonly attribute unsigned long fileSize;
00123        readonly attribute long long diskSpaceAvailable;
00124 
00125        void appendRelativeUnixPath(in string relativePath);
00126 
00127        void createDir();
00128        void touch();
00129     
00130        boolean isSymlink();
00131        void resolveSymlink();
00132 
00133        void delete(in boolean recursive);
00134     void truncate(in long aNewLength);
00135        void rename([const] in string newLeafName);
00136        void copyToDir([const] in nsIFileSpec newParentDir);
00137        void moveToDir([const] in nsIFileSpec newParentDir);
00138        void execute([const] in string args);
00139        
00140        void openStreamForReading();
00141        void openStreamForWriting();
00142        void openStreamForReadingAndWriting();
00143        void closeStream();
00144        boolean isStreamOpen();
00145        
00146        boolean eof();
00147        long read(inout string buffer, in long requestedCount);
00148        void readLine(inout string line, in long bufferSize, out boolean wasTruncated);
00149 
00154        long write(in string data, in long requestedCount);
00155        void flush();
00156        
00157        void seek(in long offset);
00158        long tell();
00159        void endLine();
00160        attribute AString unicodePath;
00161        
00162 };
00163        
00164 // Define Contractid and CID
00165 %{C++
00166 // {a3020981-2018-11d3-915f-a957795b7ebc}
00167 #define NS_DIRECTORYITERATOR_CID \
00168 { 0xa3020981, 0x2018, 0x11d3, { 0x91, 0x5f, 0xa9, 0x57, 0x79, 0x5b, 0x7e, 0xbc } }
00169 
00170 #define NS_DIRECTORYITERATOR_CONTRACTID "@mozilla.org/directoryiterator;1"
00171 #define NS_DIRECTORYITERATOR_CLASSNAME "nsIDirectoryIterator"
00172 %}
00173 
00174 [scriptable, uuid(d8c0a083-0868-11d3-915f-d9d889d48e3c)]
00175 interface nsIDirectoryIterator : nsISupports
00176 {
00177        void init(in nsIFileSpec parent, in boolean resolveSymlink);
00178        boolean exists();
00179        void next();
00180        readonly attribute nsIFileSpec currentSpec;
00181 };
00182 
00183 %{C++
00184 // Factory methods if you link with xpcom
00185 NS_COM_OBSOLETE nsresult NS_NewFileSpecWithSpec(const nsFileSpec& aSrcFileSpec, nsIFileSpec **result);
00186 NS_COM_OBSOLETE nsresult NS_NewFileSpec(nsIFileSpec** result);
00187 NS_COM_OBSOLETE nsresult NS_NewDirectoryIterator(nsIDirectoryIterator** result);
00188 
00189 // Convert from nsIFile to nsIFileSpec
00190 //
00191 // XXX This function is here only to assist with the migration from nsIFileSpec
00192 // to nsIFile.  This function will dissappear in future mozilla releases.
00193 //
00194 // ...ripped from nsPrefService.cpp:
00195 //
00196 //   "So discouraged is the use of nsIFileSpec, nobody wanted to have this routine be
00197 //    public - It might lead to continued use of nsIFileSpec. Right now, [mozilla] has
00198 //    such a need for it, here it is. Let's stop having to use it though."
00199 //
00200 NS_COM_OBSOLETE nsresult NS_NewFileSpecFromIFile(nsIFile *aFile, nsIFileSpec **result);
00201 
00202 #define NS_BOOL_ACCESSOR(_method) { PRBool yes; return NS_SUCCEEDED(f->_method(&yes)) && yes; }
00203 inline PRBool Exists(nsIFileSpec* f) NS_BOOL_ACCESSOR(Exists)
00204 inline PRBool Exists(nsIDirectoryIterator* f) NS_BOOL_ACCESSOR(Exists)
00205 inline PRBool IsDirectory(nsIFileSpec* f) NS_BOOL_ACCESSOR(IsDirectory)
00206 
00207 %}