Bug 376959, follow symlinks when doing Repack verification, r=preed
[mozilla-1.9.git] / xpcom / obsolete / nsIFileStream.h
blob8fd45f6fa5e1b666dd1e5aaec9cd4f39ce854c59
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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
13 * License.
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.
22 * Contributor(s):
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 ***** */
37 #ifndef nsIFileStream_h___
38 #define nsIFileStream_h___
40 #include "xpcomobsolete.h"
41 #include "nsIInputStream.h"
42 #include "nsIOutputStream.h"
43 #include "nsISeekableStream.h"
44 #include "prio.h"
46 class nsFileSpec;
48 /* a6cf90e8-15b3-11d2-932e-00805f8add32 */
49 #define NS_IOPENFILE_IID \
50 { 0xa6cf90e8, 0x15b3, 0x11d2, \
51 {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
53 //========================================================================================
54 class nsIOpenFile
55 // Represents a file, and supports Open.
56 //========================================================================================
57 : public nsISupports
59 public:
60 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOPENFILE_IID)
62 NS_IMETHOD Open(
63 const nsFileSpec& inFile,
64 int nsprMode,
65 PRIntn accessMode) = 0;
66 // Note: Open() is only needed after
67 // an explicit Close(). All file streams
68 // are automatically opened on construction.
69 NS_IMETHOD GetIsOpen(PRBool* outOpen) = 0;
71 }; // class nsIOpenFile
73 NS_DEFINE_STATIC_IID_ACCESSOR(nsIOpenFile, NS_IOPENFILE_IID)
75 /* a6cf90e8-15b3-11d2-932e-00805f8add32 */
76 #define NS_IRANDOMACCESS_IID \
77 { 0xa6cf90eb, 0x15b3, 0x11d2, \
78 {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
80 //========================================================================================
81 class nsIRandomAccessStore
82 // Supports Seek, Tell etc.
83 //========================================================================================
84 : public nsISeekableStream
86 public:
87 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRANDOMACCESS_IID)
89 /* "PROTECTED" */
90 NS_IMETHOD GetAtEOF(PRBool* outAtEOF) = 0;
91 NS_IMETHOD SetAtEOF(PRBool inAtEOF) = 0;
92 }; // class nsIRandomAccessStore
94 NS_DEFINE_STATIC_IID_ACCESSOR(nsIRandomAccessStore, NS_IRANDOMACCESS_IID)
96 #ifndef NO_XPCOM_FILE_STREAMS // hack to work around duplicate class definitions in here
97 // and mozilla/netwerks/base/nsIFileStreams.idl
99 /* a6cf90e6-15b3-11d2-932e-00805f8add32 */
100 #define NS_IFILESPECINPUTSTREAM_IID \
101 { 0xa6cf90e6, 0x15b3, 0x11d2, \
102 {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
104 //========================================================================================
105 class nsIFileSpecInputStream
106 // These are additional file-specific methods that files have, above what
107 // nsIInputStream supports. The current implementation supports both
108 // interfaces.
109 //========================================================================================
110 : public nsIInputStream
112 public:
113 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFILESPECINPUTSTREAM_IID)
114 }; // class nsIFileSpecInputStream
116 NS_DEFINE_STATIC_IID_ACCESSOR(nsIFileSpecInputStream,
117 NS_IFILESPECINPUTSTREAM_IID)
119 /* a6cf90e7-15b3-11d2-932e-00805f8add32 */
120 #define NS_IFILESPECOUTPUTSTREAM_IID \
121 { 0xa6cf90e7, 0x15b3, 0x11d2, \
122 {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
124 //========================================================================================
125 class nsIFileSpecOutputStream
126 // These are additional file-specific methods that files have, above what
127 // nsIOutputStream supports. The current implementation supports both
128 // interfaces.
129 //========================================================================================
130 : public nsIOutputStream
132 public:
133 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFILESPECOUTPUTSTREAM_IID)
134 }; // class nsIFileSpecOutputStream
136 NS_DEFINE_STATIC_IID_ACCESSOR(nsIFileSpecOutputStream,
137 NS_IFILESPECOUTPUTSTREAM_IID)
139 #endif // NO_XPCOM_FILE_STREAMS
141 //----------------------------------------------------------------------------------------
142 nsresult NS_NewTypicalInputFileStream(
143 nsISupports** aStreamResult,
144 const nsFileSpec& inFile
145 /*Default nsprMode == PR_RDONLY*/
146 /*Default accessmode = 0700 (octal)*/);
147 // Factory method to get an nsInputStream from a file, using most common options
149 //----------------------------------------------------------------------------------------
150 nsresult NS_NewTypicalOutputFileStream(
151 nsISupports** aStreamResult, // will implement all the above interfaces
152 const nsFileSpec& inFile
153 /*default nsprMode= (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE)*/
154 /*Default accessMode= 0700 (octal)*/);
155 // Factory method to get an nsOutputStream to a file - most common case.
157 //----------------------------------------------------------------------------------------
158 extern "C" NS_COM_OBSOLETE nsresult NS_NewIOFileStream(
159 nsISupports** aStreamResult, // will implement all the above interfaces
160 const nsFileSpec& inFile,
161 PRInt32 nsprMode,
162 PRInt32 accessMode);
163 // Factory method to get an object that implements both nsIInputStream
164 // and nsIOutputStream, associated with a single file.
166 #endif /* nsIFileSpecStream_h___ */