1/*
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
3 * Please refer to the LICENSE.txt for licensing details.
4 */
5package ch.ethz.ssh2.sftp;
6
7/**
8 *
9 * SFTP Attribute Bits for the "attrib-bits" and "attrib-bits-valid" fields
10 * of the SFTP ATTR data type.
11 * <p>
12 * Yes, these are the "attrib-bits", even though they have "_FLAGS_" in
13 * their name. Don't ask - I did not invent it.
14 * <p>
15 * "<i>These fields, taken together, reflect various attributes of the file
16 * or directory, on the server. Bits not set in 'attrib-bits-valid' MUST be
17 * ignored in the 'attrib-bits' field.  This allows both the server and the
18 * client to communicate only the bits it knows about without inadvertently
19 * twiddling bits they don't understand.</i>"
20 *
21 * @author Christian Plattner
22 * @version 2.50, 03/15/10
23 *
24 */
25public class AttribBits
26{
27	/**
28	 * Advisory, read-only bit. This bit is not part of the access
29	 * control information on the file, but is rather an advisory field
30	 * indicating that the file should not be written.
31	 */
32	public static final int SSH_FILEXFER_ATTR_FLAGS_READONLY = 0x00000001;
33
34	/**
35	 * The file is part of the operating system.
36	 */
37	public static final int SSH_FILEXFER_ATTR_FLAGS_SYSTEM = 0x00000002;
38
39	/**
40	 * File SHOULD NOT be shown to user unless specifically requested.
41	 * For example, most UNIX systems SHOULD set this bit if the filename
42	 * begins with a 'period'. This bit may be read-only (see section 5.4 of
43	 * the SFTP standard draft). Most UNIX systems will not allow this to be
44	 * changed.
45	 */
46	public static final int SSH_FILEXFER_ATTR_FLAGS_HIDDEN = 0x00000004;
47
48	/**
49	 * This attribute applies only to directories. This attribute is
50	 * always read-only, and cannot be modified. This attribute means
51	 * that files and directory names in this directory should be compared
52	 * without regard to case.
53	 * <p>
54	 * It is recommended that where possible, the server's filesystem be
55	 * allowed to do comparisons. For example, if a client wished to prompt
56	 * a user before overwriting a file, it should not compare the new name
57	 * with the previously retrieved list of names in the directory. Rather,
58	 * it should first try to create the new file by specifying
59	 * SSH_FXF_CREATE_NEW flag. Then, if this fails and returns
60	 * SSH_FX_FILE_ALREADY_EXISTS, it should prompt the user and then retry
61	 * the create specifying SSH_FXF_CREATE_TRUNCATE.
62	 * <p>
63	 * Unless otherwise specified, filenames are assumed to be case sensitive.
64	 */
65	public static final int SSH_FILEXFER_ATTR_FLAGS_CASE_INSENSITIVE = 0x00000008;
66
67	/**
68	 * The file should be included in backup / archive operations.
69	 */
70	public static final int SSH_FILEXFER_ATTR_FLAGS_ARCHIVE = 0x00000010;
71
72	/**
73	 * The file is stored on disk using file-system level transparent
74	 * encryption. This flag does not affect the file data on the wire
75	 * (for either READ or WRITE requests.)
76	 */
77	public static final int SSH_FILEXFER_ATTR_FLAGS_ENCRYPTED = 0x00000020;
78
79	/**
80	 * The file is stored on disk using file-system level transparent
81	 * compression. This flag does not affect the file data on the wire.
82	 */
83	public static final int SSH_FILEXFER_ATTR_FLAGS_COMPRESSED = 0x00000040;
84
85	/**
86	 * The file is a sparse file; this means that file blocks that have
87	 * not been explicitly written are not stored on disk. For example, if
88	 * a client writes a buffer at 10 M from the beginning of the file,
89	 * the blocks between the previous EOF marker and the 10 M offset would
90	 * not consume physical disk space.
91	 * <p>
92	 * Some servers may store all files as sparse files, in which case
93	 * this bit will be unconditionally set. Other servers may not have
94	 * a mechanism for determining if the file is sparse, and so the file
95	 * MAY be stored sparse even if this flag is not set.
96	 */
97	public static final int SSH_FILEXFER_ATTR_FLAGS_SPARSE = 0x00000080;
98
99	/**
100	 * Opening the file without either the SSH_FXF_ACCESS_APPEND_DATA or
101	 * the SSH_FXF_ACCESS_APPEND_DATA_ATOMIC flag (see section 8.1.1.3
102	 * of the SFTP standard draft) MUST result in an
103	 * SSH_FX_INVALID_PARAMETER error.
104	 */
105	public static final int SSH_FILEXFER_ATTR_FLAGS_APPEND_ONLY = 0x00000100;
106
107	/**
108	 * The file cannot be deleted or renamed, no hard link can be created
109	 * to this file, and no data can be written to the file.
110	 * <p>
111	 * This bit implies a stronger level of protection than
112	 * SSH_FILEXFER_ATTR_FLAGS_READONLY, the file permission mask or ACLs.
113	 * Typically even the superuser cannot write to immutable files, and
114	 * only the superuser can set or remove the bit.
115	 */
116	public static final int SSH_FILEXFER_ATTR_FLAGS_IMMUTABLE = 0x00000200;
117
118	/**
119	 * When the file is modified, the changes are written synchronously
120	 * to the disk.
121	 */
122	public static final int SSH_FILEXFER_ATTR_FLAGS_SYNC = 0x00000400;
123
124	/**
125	 * The server MAY include this bit in a directory listing or realpath
126	 * response. It indicates there was a failure in the translation to UTF-8.
127	 * If this flag is included, the server SHOULD also include the
128	 * UNTRANSLATED_NAME attribute.
129	 */
130	public static final int SSH_FILEXFER_ATTR_FLAGS_TRANSLATION_ERR = 0x00000800;
131
132}
133