1 /*
2 * dpkg - Debian Package library and the Debian Package Maven plugin
3 * (c) Copyright 2016 Gerrit Hohl
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 package net.sourceforge.javadpkg.io;
20
21
22 /**
23 * <p>
24 * The mode of a file.
25 * </p>
26 *
27 * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net)
28 * @version <b>1.0</b>, 12.05.2016 by Gerrit Hohl
29 * @version <b>1.0</b>, 21.06.2018 by Gerrit Hohl
30 */
31 public interface FileMode {
32
33
34 /**
35 * <p>
36 * Returns the mode as number including all octals.
37 * </p>
38 *
39 * @return The mode.
40 */
41 int getMode();
42
43
44 /**
45 * <p>
46 * Returns the mode as an octal number consisting only of the last 3 octals.
47 * </p>
48 * <p>
49 * The returned value may look like this: <blockquote>
50 * <code>777</code></blockquote> or like this: <blockquote>
51 * <code>000</code></blockquote>
52 * </p>
53 *
54 * @return The mode.
55 */
56 String getOctal();
57
58
59 /**
60 * <p>
61 * Returns the mode as textual representation excluding the "sticky
62 * bit".
63 * </p>
64 * <p>
65 * The returned value may look like this: <blockquote>
66 * <code>rwxrwxrwx</code></blockquote> or like this: <blockquote>
67 * <code>---------</code></blockquote>
68 * </p>
69 *
70 * @return The mode.
71 */
72 String getText();
73
74
75 /**
76 * <p>
77 * Returns the sticky bit.
78 * </p>
79 * <p>
80 * See <a href=
81 * "https://en.wikipedia.org/wiki/File_system_permissions#Changing_permission_behavior_with_setuid.2C_setgid.2C_and_sticky_bits">
82 * Changing permission behavior with setuid, setgid, and sticky bits</a> for
83 * more information.
84 * </p>
85 *
86 * @return The sticky bit: A number from octal 0 (decimal: 0) to octal 7
87 * (decimal: 7).
88 */
89 int getStickyBit();
90
91
92 /**
93 * <p>
94 * Returns the flag if the owner can read the file.
95 * </p>
96 *
97 * @return The flag: <code>true</code>, if the owner can, <code>false</code>
98 * otherwise.
99 */
100 boolean isOwnerReadable();
101
102
103 /**
104 * <p>
105 * Returns the flag if the owner can write the file.
106 * </p>
107 *
108 * @return The flag: <code>true</code>, if the owner can, <code>false</code>
109 * otherwise.
110 */
111 boolean isOwnerWriteable();
112
113
114 /**
115 * <p>
116 * Returns the flag if the owner can execute the file.
117 * </p>
118 *
119 * @return The flag: <code>true</code>, if the owner can, <code>false</code>
120 * otherwise.
121 */
122 boolean isOwnerExecutable();
123
124
125 /**
126 * <p>
127 * Returns the flag if the group can read the file.
128 * </p>
129 *
130 * @return The flag: <code>true</code>, if the group can, <code>false</code>
131 * otherwise.
132 */
133 boolean isGroupReadable();
134
135
136 /**
137 * <p>
138 * Returns the flag if the group can write the file.
139 * </p>
140 *
141 * @return The flag: <code>true</code>, if the group can, <code>false</code>
142 * otherwise.
143 */
144 boolean isGroupWriteable();
145
146
147 /**
148 * <p>
149 * Returns the flag if the group can execute the file.
150 * </p>
151 *
152 * @return The flag: <code>true</code>, if the group can, <code>false</code>
153 * otherwise.
154 */
155 boolean isGroupExecutable();
156
157
158 /**
159 * <p>
160 * Returns the flag if the others can read the file.
161 * </p>
162 *
163 * @return The flag: <code>true</code>, if the others can,
164 * <code>false</code> otherwise.
165 */
166 boolean isOtherReadable();
167
168
169 /**
170 * <p>
171 * Returns the flag if the others can write the file.
172 * </p>
173 *
174 * @return The flag: <code>true</code>, if the others can,
175 * <code>false</code> otherwise.
176 */
177 boolean isOtherWriteable();
178
179
180 /**
181 * <p>
182 * Returns the flag if the others can execute the file.
183 * </p>
184 *
185 * @return The flag: <code>true</code>, if the others can,
186 * <code>false</code> otherwise.
187 */
188 boolean isOtherExecutable();
189
190
191 }