KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > ssh2 > sftp > OpenFlags


1
2 package ch.ethz.ssh2.sftp;
3
4 /**
5  *
6  * SFTP Open Flags.
7  *
8  * The following table is provided to assist in mapping POSIX semantics
9  * to equivalent SFTP file open parameters:
10  * <p>
11  * TODO: This comment should be moved to the open method.
12  * <p>
13  * <ul>
14  * <li>O_RDONLY
15  * <ul><li>desired-access = READ_DATA | READ_ATTRIBUTES</li></ul>
16  * </li>
17  * </ul>
18  * <ul>
19  * <li>O_WRONLY
20  * <ul><li>desired-access = WRITE_DATA | WRITE_ATTRIBUTES</li></ul>
21  * </li>
22  * </ul>
23  * <ul>
24  * <li>O_RDWR
25  * <ul><li>desired-access = READ_DATA | READ_ATTRIBUTES | WRITE_DATA | WRITE_ATTRIBUTES</li></ul>
26  * </li>
27  * </ul>
28  * <ul>
29  * <li>O_APPEND
30  * <ul>
31  * <li>desired-access = WRITE_DATA | WRITE_ATTRIBUTES | APPEND_DATA</li>
32  * <li>flags = SSH_FXF_ACCESS_APPEND_DATA and or SSH_FXF_ACCESS_APPEND_DATA_ATOMIC</li>
33  * </ul>
34  * </li>
35  * </ul>
36  * <ul>
37  * <li>O_CREAT
38  * <ul>
39  * <li>flags = SSH_FXF_OPEN_OR_CREATE</li>
40  * </ul>
41  * </li>
42  * </ul>
43  * <ul>
44  * <li>O_TRUNC
45  * <ul>
46  * <li>flags = SSH_FXF_TRUNCATE_EXISTING</li>
47  * </ul>
48  * </li>
49  * </ul>
50  * <ul>
51  * <li>O_TRUNC|O_CREATE
52  * <ul>
53  * <li>flags = SSH_FXF_CREATE_TRUNCATE</li>
54  * </ul>
55  * </li>
56  * </ul>
57  *
58  * @author Christian Plattner, plattner@inf.ethz.ch
59  * @version $Id: OpenFlags.java,v 1.2 2006/08/02 12:05:00 cplattne Exp $
60  */

61 public class OpenFlags
62 {
63     /**
64      * Disposition is a 3 bit field that controls how the file is opened.
65      * The server MUST support these bits (possible enumaration values:
66      * SSH_FXF_CREATE_NEW, SSH_FXF_CREATE_TRUNCATE, SSH_FXF_OPEN_EXISTING,
67      * SSH_FXF_OPEN_OR_CREATE or SSH_FXF_TRUNCATE_EXISTING).
68      */

69     public static final int SSH_FXF_ACCESS_DISPOSITION = 0x00000007;
70
71     /**
72      * A new file is created; if the file already exists, the server
73      * MUST return status SSH_FX_FILE_ALREADY_EXISTS.
74      */

75     public static final int SSH_FXF_CREATE_NEW = 0x00000000;
76
77     /**
78      * A new file is created; if the file already exists, it is opened
79      * and truncated.
80      */

81     public static final int SSH_FXF_CREATE_TRUNCATE = 0x00000001;
82
83     /**
84      * An existing file is opened. If the file does not exist, the
85      * server MUST return SSH_FX_NO_SUCH_FILE. If a directory in the
86      * path does not exist, the server SHOULD return
87      * SSH_FX_NO_SUCH_PATH. It is also acceptable if the server
88      * returns SSH_FX_NO_SUCH_FILE in this case.
89      */

90     public static final int SSH_FXF_OPEN_EXISTING = 0x00000002;
91
92     /**
93      * If the file exists, it is opened. If the file does not exist,
94      * it is created.
95      */

96     public static final int SSH_FXF_OPEN_OR_CREATE = 0x00000003;
97
98     /**
99      * An existing file is opened and truncated. If the file does not
100      * exist, the server MUST return the same error codes as defined
101      * for SSH_FXF_OPEN_EXISTING.
102      */

103     public static final int SSH_FXF_TRUNCATE_EXISTING = 0x00000004;
104
105     /**
106      * Data is always written at the end of the file. The offset field
107      * of the SSH_FXP_WRITE requests are ignored.
108      * <p>
109      * Data is not required to be appended atomically. This means that
110      * if multiple writers attempt to append data simultaneously, data
111      * from the first may be lost. However, data MAY be appended
112      * atomically.
113      */

114     public static final int SSH_FXF_ACCESS_APPEND_DATA = 0x00000008;
115
116     /**
117      * Data is always written at the end of the file. The offset field
118      * of the SSH_FXP_WRITE requests are ignored.
119      * <p>
120      * Data MUST be written atomically so that there is no chance that
121      * multiple appenders can collide and result in data being lost.
122      * <p>
123      * If both append flags are specified, the server SHOULD use atomic
124      * append if it is available, but SHOULD use non-atomic appends
125      * otherwise. The server SHOULD NOT fail the request in this case.
126      */

127     public static final int SSH_FXF_ACCESS_APPEND_DATA_ATOMIC = 0x00000010;
128
129     /**
130      * Indicates that the server should treat the file as text and
131      * convert it to the canonical newline convention in use.
132      * (See Determining Server Newline Convention in section 5.3 in the
133      * SFTP standard draft).
134      * <p>
135      * When a file is opened with this flag, the offset field in the read
136      * and write functions is ignored.
137      * <p>
138      * Servers MUST process multiple, parallel reads and writes correctly
139      * in this mode. Naturally, it is permissible for them to do this by
140      * serializing the requests.
141      * <p>
142      * Clients SHOULD use the SSH_FXF_ACCESS_APPEND_DATA flag to append
143      * data to a text file rather then using write with a calculated offset.
144      */

145     public static final int SSH_FXF_ACCESS_TEXT_MODE = 0x00000020;
146
147     /**
148      * The server MUST guarantee that no other handle has been opened
149      * with ACE4_READ_DATA access, and that no other handle will be
150      * opened with ACE4_READ_DATA access until the client closes the
151      * handle. (This MUST apply both to other clients and to other
152      * processes on the server.)
153      * <p>
154      * If there is a conflicting lock the server MUST return
155      * SSH_FX_LOCK_CONFLICT. If the server cannot make the locking
156      * guarantee, it MUST return SSH_FX_OP_UNSUPPORTED.
157      * <p>
158      * Other handles MAY be opened for ACE4_WRITE_DATA or any other
159      * combination of accesses, as long as ACE4_READ_DATA is not included
160      * in the mask.
161      */

162     public static final int SSH_FXF_ACCESS_BLOCK_READ = 0x00000040;
163
164     /**
165      * The server MUST guarantee that no other handle has been opened
166      * with ACE4_WRITE_DATA or ACE4_APPEND_DATA access, and that no other
167      * handle will be opened with ACE4_WRITE_DATA or ACE4_APPEND_DATA
168      * access until the client closes the handle. (This MUST apply both
169      * to other clients and to other processes on the server.)
170      * <p>
171      * If there is a conflicting lock the server MUST return
172      * SSH_FX_LOCK_CONFLICT. If the server cannot make the locking
173      * guarantee, it MUST return SSH_FX_OP_UNSUPPORTED.
174      * <p>
175      * Other handles MAY be opened for ACE4_READ_DATA or any other
176      * combination of accesses, as long as neither ACE4_WRITE_DATA nor
177      * ACE4_APPEND_DATA are included in the mask.
178      */

179     public static final int SSH_FXF_ACCESS_BLOCK_WRITE = 0x00000080;
180
181     /**
182      * The server MUST guarantee that no other handle has been opened
183      * with ACE4_DELETE access, opened with the
184      * SSH_FXF_ACCESS_DELETE_ON_CLOSE flag set, and that no other handle
185      * will be opened with ACE4_DELETE access or with the
186      * SSH_FXF_ACCESS_DELETE_ON_CLOSE flag set, and that the file itself
187      * is not deleted in any other way until the client closes the handle.
188      * <p>
189      * If there is a conflicting lock the server MUST return
190      * SSH_FX_LOCK_CONFLICT. If the server cannot make the locking
191      * guarantee, it MUST return SSH_FX_OP_UNSUPPORTED.
192      */

193     public static final int SSH_FXF_ACCESS_BLOCK_DELETE = 0x00000100;
194
195     /**
196      * If this bit is set, the above BLOCK modes are advisory. In advisory
197      * mode, only other accesses that specify a BLOCK mode need be
198      * considered when determining whether the BLOCK can be granted,
199      * and the server need not prevent I/O operations that violate the
200      * block mode.
201      * <p>
202      * The server MAY perform mandatory locking even if the BLOCK_ADVISORY
203      * bit is set.
204      */

205     public static final int SSH_FXF_ACCESS_BLOCK_ADVISORY = 0x00000200;
206
207     /**
208      * If the final component of the path is a symlink, then the open
209      * MUST fail, and the error SSH_FX_LINK_LOOP MUST be returned.
210      */

211     public static final int SSH_FXF_ACCESS_NOFOLLOW = 0x00000400;
212
213     /**
214      * The file should be deleted when the last handle to it is closed.
215      * (The last handle may not be an sftp-handle.) This MAY be emulated
216      * by a server if the OS doesn't support it by deleting the file when
217      * this handle is closed.
218      * <p>
219      * It is implementation specific whether the directory entry is
220      * removed immediately or when the handle is closed.
221      */

222     public static final int SSH_FXF_ACCESS_DELETE_ON_CLOSE = 0x00000800;
223 }
224
Popular Tags