1 /* -*- Mode: C++; tab-width: 2; 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 the GNU General Public License Version 2 or later (the "GPL"), or
26 * 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 #include "nsIInputStream.idl"
39 #include "nsIOutputStream.idl"
40
41 interface nsIFile;
42
43 /**
44 * An input stream that allows you to read from a file.
45 */
46 [scriptable, uuid(e3d56a20-c7ec-11d3-8cda-0060b0fc14a3)]
47 interface nsIFileInputStream : nsIInputStream
48 {
49 /**
50 * @param file file to read from (must QI to nsILocalFile)
51 * @param ioFlags file open flags listed in prio.h (see
52 * PR_Open documentation) or -1 to open the
53 * file in default mode (PR_RDONLY).
54 * @param perm file mode bits listed in prio.h or -1 to
55 * use the default value (0)
56 * @param behaviorFlags flags specifying various behaviors of the class
57 * (see enumerations in the class)
58 */
59 void init(in nsIFile file, in long ioFlags, in long perm,
60 in long behaviorFlags);
61
62 /**
63 * If this is set, the file will be deleted by the time the stream is
64 * closed. It may be removed before the stream is closed if it is possible
65 * to delete it and still read from it.
66 *
67 * If OPEN_ON_READ is defined, and the file was recreated after the first
68 * delete, the file will be deleted again when it is closed again.
69 */
70 const long DELETE_ON_CLOSE = 1<<1;
71
72 /**
73 * If this is set, the file will close automatically when the end of the
74 * file is reached.
75 */
76 const long CLOSE_ON_EOF = 1<<2;
77
78 /**
79 * If this is set, the file will be reopened whenever Seek(0) occurs. If
80 * the file is already open and the seek occurs, it will happen naturally.
81 * (The file will only be reopened if it is closed for some reason.)
82 */
83 const long REOPEN_ON_REWIND = 1<<3;
84 };
85
86 /**
87 * An output stream that lets you stream to a file.
88 */
89 [scriptable, uuid(e6f68040-c7ec-11d3-8cda-0060b0fc14a3)]
90 interface nsIFileOutputStream : nsIOutputStream
91 {
92 /**
93 * @param file file to write to (must QI to nsILocalFile)
94 * @param ioFlags file open flags listed in prio.h (see
95 * PR_Open documentation) or -1 to open the
96 * file in default mode (PR_WRONLY |
97 * PR_CREATE_FILE | PR_TRUNCATE)
98 * @param perm file mode bits listed in prio.h or -1 to
99 * use the default permissions (0664)
100 * @param behaviorFlags flags specifying various behaviors of the class
101 * (currently none supported)
102 */
103 void init(in nsIFile file, in long ioFlags, in long perm,
104 in long behaviorFlags);
105 };