1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.util.win32;
17
18
19
20
21
22
23 public class VolumeInformation {
24 static final int FS_CASE_IS_PRESERVED = 2;
25
26 static final int FS_CASE_SENSITIVE = 1;
27
28 static final int FS_UNICODE_STORED_ON_DISK = 4;
29
30 static final int FS_PERSISTENT_ACLS = 8;
31
32 static final int FS_FILE_COMPRESSION = 16;
33
34 static final int FS_VOL_IS_COMPRESSED = 32768;
35
36 static final int FILE_NAMED_STREAMS = 0x00040000;
37
38 static final int FILE_SUPPORTS_ENCRYPTION = 0x00020000;
39
40 static final int FILE_SUPPORTS_OBJECT_IDS = 0x00010000;
41
42 static final int FILE_SUPPORTS_REPARSE_POINTS = 0x00000080;
43
44 static final int FILE_SUPPORTS_SPARSE_FILES = 0x00000040;
45
46 static final int FILE_VOLUME_QUOTAS = 0x00000020;
47
48 private String rootPath;
49
50 private String volumeLabel;
51
52 private int serialNumber;
53
54 private String fileSystemName;
55
56 private int maxComponentLength;
57
58 private int fileSystemFlags;
59
60 VolumeInformation() {
61 }
62
63
64
65
66
67
68 public String getRootPath() {
69 return this.rootPath;
70 }
71
72 void setRootPath(final String rootPath) {
73 this.rootPath = rootPath;
74 }
75
76
77
78
79
80
81 public String getVolumeLabel() {
82 return this.volumeLabel;
83 }
84
85 void setVolumeLabel(final String volumeLabel) {
86 this.volumeLabel = volumeLabel;
87 }
88
89
90
91
92
93
94 public int getSerialNumber() {
95 return this.serialNumber;
96 }
97
98
99
100
101
102
103 public String getSerialNumberAsString() {
104 int high = (this.serialNumber >> 16) & 0x0000ffff;
105 int low = this.serialNumber & 0x0000ffff;
106 StringBuilder builder = new StringBuilder();
107 builder.append(String.format("%04X", high));
108 builder.append("-");
109 builder.append(String.format("%04X", low));
110 return builder.toString();
111 }
112
113 void setSerialNumber(final int serialNumber) {
114 this.serialNumber = serialNumber;
115 }
116
117
118
119
120
121
122 public String getFileSystemName() {
123 return this.fileSystemName;
124 }
125
126 void setFileSystemName(final String fileSystemName) {
127 this.fileSystemName = fileSystemName;
128 }
129
130
131
132
133
134
135 public int getMaxComponentLength() {
136 return this.maxComponentLength;
137 }
138
139 void setMaxComponentLength(final int maxComponentLength) {
140 this.maxComponentLength = maxComponentLength;
141 }
142
143 void setFileSystemFlags(final int fileSystemFlags) {
144 this.fileSystemFlags = fileSystemFlags;
145 }
146
147
148
149
150
151
152 public boolean isCaseIsPreserved() {
153 return (fileSystemFlags & FS_CASE_IS_PRESERVED) != 0 ? true : false;
154 }
155
156
157
158
159
160
161 public boolean isCaseSensitive() {
162 return (fileSystemFlags & FS_CASE_SENSITIVE) != 0 ? true : false;
163
164 }
165
166
167
168
169
170
171 public boolean isUnicodeStoredOnDisk() {
172 return (fileSystemFlags & FS_UNICODE_STORED_ON_DISK) != 0 ? true
173 : false;
174 }
175
176
177
178
179
180
181 public boolean isPersistentACLs() {
182 return (fileSystemFlags & FS_PERSISTENT_ACLS) != 0 ? true : false;
183 }
184
185
186
187
188
189
190 public boolean isFileCompression() {
191 return (fileSystemFlags & FS_FILE_COMPRESSION) != 0 ? true : false;
192 }
193
194
195
196
197
198
199 public boolean isVolumeComplessed() {
200 return (fileSystemFlags & FS_VOL_IS_COMPRESSED) != 0 ? true : false;
201 }
202
203
204
205
206
207
208 public boolean isNamedStreams() {
209 return (fileSystemFlags & FILE_NAMED_STREAMS) != 0 ? true : false;
210 }
211
212
213
214
215
216
217 public boolean isSupportsEncryption() {
218 return (fileSystemFlags & FILE_SUPPORTS_ENCRYPTION) != 0 ? true : false;
219 }
220
221
222
223
224
225
226 public boolean isSupportsObjectIDs() {
227 return (fileSystemFlags & FILE_SUPPORTS_OBJECT_IDS) != 0 ? true : false;
228 }
229
230
231
232
233
234
235 public boolean isSupportsReparsePoints() {
236 return (fileSystemFlags & FILE_SUPPORTS_REPARSE_POINTS) != 0 ? true
237 : false;
238 }
239
240
241
242
243
244
245 public boolean isSupportsSparseFiles() {
246 return (fileSystemFlags & FILE_SUPPORTS_SPARSE_FILES) != 0 ? true
247 : false;
248 }
249
250
251
252
253
254
255 public boolean isVolumeQuotas() {
256 return (fileSystemFlags & FILE_VOLUME_QUOTAS) != 0 ? true : false;
257 }
258
259
260
261
262 @Override
263 public String toString() {
264 StringBuilder builder = new StringBuilder();
265 builder
266 .append("RootPath : " + getRootPath()
267 + "\n");
268 builder.append("VolumeLabel : " + getVolumeLabel()
269 + "\n");
270 builder.append("SerialNumber : "
271 + getSerialNumberAsString() + "\n");
272 builder.append("FileSystemName : " + getFileSystemName()
273 + "\n");
274 builder.append("MaxComponentLength : "
275 + getMaxComponentLength() + "\n");
276 builder.append("FS_CASE_IS_PRESERVED : " + isCaseIsPreserved()
277 + "\n");
278 builder.append("FS_CASE_SENSITIVE : " + isCaseSensitive()
279 + "\n");
280 builder.append("FS_UNICODE_STORED_ON_DISK : "
281 + isUnicodeStoredOnDisk() + "\n");
282 builder.append("FS_PERSISTENT_ACLS : " + isPersistentACLs()
283 + "\n");
284 builder.append("FS_FILE_COMPRESSION : " + isFileCompression()
285 + "\n");
286 builder.append("FS_VOL_IS_COMPRESSED : " + isVolumeComplessed()
287 + "\n");
288 builder.append("FILE_NAMED_STREAMS : " + isNamedStreams()
289 + "\n");
290 builder.append("FILE_SUPPORTS_ENCRYPTION : "
291 + isSupportsEncryption() + "\n");
292 builder.append("FILE_SUPPORTS_OBJECT_IDS : "
293 + isSupportsObjectIDs() + "\n");
294 builder.append("FILE_SUPPORTS_REPARSE_POINTS : "
295 + isSupportsReparsePoints() + "\n");
296 builder.append("FILE_SUPPORTS_SPARSE_FILES : "
297 + isSupportsSparseFiles() + "\n");
298 builder.append("FILE_VOLUME_QUOTAS : " + isVolumeQuotas()
299 + "\n");
300 return builder.toString();
301 }
302 }