Mercurial > 510Connectbot
comparison app/src/main/java/ch/ethz/ssh2/sftp/OpenFlags.java @ 438:d29cce60f393
migrate from Eclipse to Android Studio
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 03 Dec 2015 11:23:55 -0800 |
parents | src/ch/ethz/ssh2/sftp/OpenFlags.java@91a31873c42a |
children |
comparison
equal
deleted
inserted
replaced
437:208b31032318 | 438:d29cce60f393 |
---|---|
1 /* | |
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved. | |
3 * Please refer to the LICENSE.txt for licensing details. | |
4 */ | |
5 package ch.ethz.ssh2.sftp; | |
6 | |
7 /** | |
8 * SFTP Open Flags. | |
9 * <p/> | |
10 * The following table is provided to assist in mapping POSIX semantics | |
11 * to equivalent SFTP file open parameters: | |
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 | |
59 * @version 2.50, 03/15/10 | |
60 */ | |
61 public final class OpenFlags { | |
62 private OpenFlags() { | |
63 } | |
64 | |
65 /** | |
66 * Disposition is a 3 bit field that controls how the file is opened. | |
67 * The server MUST support these bits (possible enumaration values: | |
68 * SSH_FXF_CREATE_NEW, SSH_FXF_CREATE_TRUNCATE, SSH_FXF_OPEN_EXISTING, | |
69 * SSH_FXF_OPEN_OR_CREATE or SSH_FXF_TRUNCATE_EXISTING). | |
70 */ | |
71 public static final int SSH_FXF_ACCESS_DISPOSITION = 0x00000007; | |
72 | |
73 /** | |
74 * A new file is created; if the file already exists, the server | |
75 * MUST return status SSH_FX_FILE_ALREADY_EXISTS. | |
76 */ | |
77 public static final int SSH_FXF_CREATE_NEW = 0x00000000; | |
78 | |
79 /** | |
80 * A new file is created; if the file already exists, it is opened | |
81 * and truncated. | |
82 */ | |
83 public static final int SSH_FXF_CREATE_TRUNCATE = 0x00000001; | |
84 | |
85 /** | |
86 * An existing file is opened. If the file does not exist, the | |
87 * server MUST return SSH_FX_NO_SUCH_FILE. If a directory in the | |
88 * path does not exist, the server SHOULD return | |
89 * SSH_FX_NO_SUCH_PATH. It is also acceptable if the server | |
90 * returns SSH_FX_NO_SUCH_FILE in this case. | |
91 */ | |
92 public static final int SSH_FXF_OPEN_EXISTING = 0x00000002; | |
93 | |
94 /** | |
95 * If the file exists, it is opened. If the file does not exist, | |
96 * it is created. | |
97 */ | |
98 public static final int SSH_FXF_OPEN_OR_CREATE = 0x00000003; | |
99 | |
100 /** | |
101 * An existing file is opened and truncated. If the file does not | |
102 * exist, the server MUST return the same error codes as defined | |
103 * for SSH_FXF_OPEN_EXISTING. | |
104 */ | |
105 public static final int SSH_FXF_TRUNCATE_EXISTING = 0x00000004; | |
106 | |
107 /** | |
108 * Data is always written at the end of the file. The offset field | |
109 * of the SSH_FXP_WRITE requests are ignored. | |
110 * <p/> | |
111 * Data is not required to be appended atomically. This means that | |
112 * if multiple writers attempt to append data simultaneously, data | |
113 * from the first may be lost. However, data MAY be appended | |
114 * atomically. | |
115 */ | |
116 public static final int SSH_FXF_ACCESS_APPEND_DATA = 0x00000008; | |
117 | |
118 /** | |
119 * Data is always written at the end of the file. The offset field | |
120 * of the SSH_FXP_WRITE requests are ignored. | |
121 * <p/> | |
122 * Data MUST be written atomically so that there is no chance that | |
123 * multiple appenders can collide and result in data being lost. | |
124 * <p/> | |
125 * If both append flags are specified, the server SHOULD use atomic | |
126 * append if it is available, but SHOULD use non-atomic appends | |
127 * otherwise. The server SHOULD NOT fail the request in this case. | |
128 */ | |
129 public static final int SSH_FXF_ACCESS_APPEND_DATA_ATOMIC = 0x00000010; | |
130 | |
131 /** | |
132 * Indicates that the server should treat the file as text and | |
133 * convert it to the canonical newline convention in use. | |
134 * (See Determining Server Newline Convention in section 5.3 in the | |
135 * SFTP standard draft). | |
136 * <p/> | |
137 * When a file is opened with this flag, the offset field in the read | |
138 * and write functions is ignored. | |
139 * <p/> | |
140 * Servers MUST process multiple, parallel reads and writes correctly | |
141 * in this mode. Naturally, it is permissible for them to do this by | |
142 * serializing the requests. | |
143 * <p/> | |
144 * Clients SHOULD use the SSH_FXF_ACCESS_APPEND_DATA flag to append | |
145 * data to a text file rather then using write with a calculated offset. | |
146 */ | |
147 public static final int SSH_FXF_ACCESS_TEXT_MODE = 0x00000020; | |
148 | |
149 /** | |
150 * The server MUST guarantee that no other handle has been opened | |
151 * with ACE4_READ_DATA access, and that no other handle will be | |
152 * opened with ACE4_READ_DATA access until the client closes the | |
153 * handle. (This MUST apply both to other clients and to other | |
154 * processes on the server.) | |
155 * <p/> | |
156 * If there is a conflicting lock the server MUST return | |
157 * SSH_FX_LOCK_CONFLICT. If the server cannot make the locking | |
158 * guarantee, it MUST return SSH_FX_OP_UNSUPPORTED. | |
159 * <p/> | |
160 * Other handles MAY be opened for ACE4_WRITE_DATA or any other | |
161 * combination of accesses, as long as ACE4_READ_DATA is not included | |
162 * in the mask. | |
163 */ | |
164 public static final int SSH_FXF_ACCESS_BLOCK_READ = 0x00000040; | |
165 | |
166 /** | |
167 * The server MUST guarantee that no other handle has been opened | |
168 * with ACE4_WRITE_DATA or ACE4_APPEND_DATA access, and that no other | |
169 * handle will be opened with ACE4_WRITE_DATA or ACE4_APPEND_DATA | |
170 * access until the client closes the handle. (This MUST apply both | |
171 * to other clients and to other processes on the server.) | |
172 * <p/> | |
173 * If there is a conflicting lock the server MUST return | |
174 * SSH_FX_LOCK_CONFLICT. If the server cannot make the locking | |
175 * guarantee, it MUST return SSH_FX_OP_UNSUPPORTED. | |
176 * <p/> | |
177 * Other handles MAY be opened for ACE4_READ_DATA or any other | |
178 * combination of accesses, as long as neither ACE4_WRITE_DATA nor | |
179 * ACE4_APPEND_DATA are included in the mask. | |
180 */ | |
181 public static final int SSH_FXF_ACCESS_BLOCK_WRITE = 0x00000080; | |
182 | |
183 /** | |
184 * The server MUST guarantee that no other handle has been opened | |
185 * with ACE4_DELETE access, opened with the | |
186 * SSH_FXF_ACCESS_DELETE_ON_CLOSE flag set, and that no other handle | |
187 * will be opened with ACE4_DELETE access or with the | |
188 * SSH_FXF_ACCESS_DELETE_ON_CLOSE flag set, and that the file itself | |
189 * is not deleted in any other way until the client closes the handle. | |
190 * <p/> | |
191 * If there is a conflicting lock the server MUST return | |
192 * SSH_FX_LOCK_CONFLICT. If the server cannot make the locking | |
193 * guarantee, it MUST return SSH_FX_OP_UNSUPPORTED. | |
194 */ | |
195 public static final int SSH_FXF_ACCESS_BLOCK_DELETE = 0x00000100; | |
196 | |
197 /** | |
198 * If this bit is set, the above BLOCK modes are advisory. In advisory | |
199 * mode, only other accesses that specify a BLOCK mode need be | |
200 * considered when determining whether the BLOCK can be granted, | |
201 * and the server need not prevent I/O operations that violate the | |
202 * block mode. | |
203 * <p/> | |
204 * The server MAY perform mandatory locking even if the BLOCK_ADVISORY | |
205 * bit is set. | |
206 */ | |
207 public static final int SSH_FXF_ACCESS_BLOCK_ADVISORY = 0x00000200; | |
208 | |
209 /** | |
210 * If the final component of the path is a symlink, then the open | |
211 * MUST fail, and the error SSH_FX_LINK_LOOP MUST be returned. | |
212 */ | |
213 public static final int SSH_FXF_ACCESS_NOFOLLOW = 0x00000400; | |
214 | |
215 /** | |
216 * The file should be deleted when the last handle to it is closed. | |
217 * (The last handle may not be an sftp-handle.) This MAY be emulated | |
218 * by a server if the OS doesn't support it by deleting the file when | |
219 * this handle is closed. | |
220 * <p/> | |
221 * It is implementation specific whether the directory entry is | |
222 * removed immediately or when the handle is closed. | |
223 */ | |
224 public static final int SSH_FXF_ACCESS_DELETE_ON_CLOSE = 0x00000800; | |
225 } |