-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathDokanOptions.java
More file actions
122 lines (101 loc) · 3.79 KB
/
DokanOptions.java
File metadata and controls
122 lines (101 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package dev.dokan.dokan_java.structure;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import dev.dokan.dokan_java.DokanNativeMethods;
import dev.dokan.dokan_java.Unsigned;
import dev.dokan.dokan_java.UnsignedNumbers;
import dev.dokan.dokan_java.constants.dokany.MountOption;
import dev.dokan.dokan_java.masking.MaskValueSet;
import java.util.Arrays;
import java.util.List;
/**
* Dokan mount options used to describe Dokan device behavior.
*
* @see <a href="https://dokan-dev.github.io/dokany-doc/html/struct_d_o_k_a_n___o_p_t_i_o_n_s.html">Dokany Documentation of PDOKAN_OPTIONS</a>
*/
public class DokanOptions extends Structure implements Structure.ByReference {
/**
* Version of the Dokan features requested (version "123" is equal to Dokan version 1.2.3).
*/
@Unsigned
public short Version = DokanNativeMethods.getMinimumRequiredDokanVersion();
/**
* Number of threads to be used internally by Dokan library. More thread will handle more events at the same time.
*/
@Unsigned
public short ThreadCount;
/**
* Features enable for the mount. It is a combination of {@link MountOption} masks.
*/
@Unsigned
public int Options;
/**
* FileSystem can store anything here
*/
@Unsigned
public long GlobalContext = 0L;
/**
* Mount point. It can be a drive letter like \"M:\\\" or a folder path \"C:\\mount\\dokany\" on a NTFS partition.
*/
public WString MountPoint;
/**
* UNC name used for the Network Redirector.
*
* @see <a href="https://docs.microsoft.com/de-de/windows-hardware/drivers/ifs/support-for-unc-naming-and-mup">Support for UNC Naming</a>
*/
public WString UNCName;
/**
* Max timeout in milliseconds of each request before Dokan gives up to wait events to complete.
*/
@Unsigned
public int Timeout;
/**
* Allocation Unit Size of the volume. This will affect the file size.
*/
@Unsigned
public int AllocationUnitSize;
/**
* Sector Size of the volume. This will affect then file size.
*/
@Unsigned
public int SectorSize;
public DokanOptions() {
}
public DokanOptions(String mountPoint, @Unsigned short threadCount, MaskValueSet<MountOption> mountOptions, String uncName, @Unsigned int timeout, @Unsigned int allocationUnitSize, @Unsigned int sectorSize) {
this(mountPoint, threadCount, mountOptions.intValue(), uncName, timeout, allocationUnitSize, sectorSize);
}
public DokanOptions(String mountPoint, @Unsigned short threadCount, @Unsigned int mountOptions, String uncName, @Unsigned int timeout, @Unsigned int allocationUnitSize, @Unsigned int sectorSize) {
MountPoint = new WString(mountPoint);
ThreadCount = threadCount;
Options = mountOptions;
if (uncName != null) {
UNCName = new WString(uncName);
} else {
UNCName = null;
}
Timeout = timeout;
AllocationUnitSize = allocationUnitSize;
SectorSize = sectorSize;
}
public MaskValueSet<MountOption> getMountOptions() {
return MaskValueSet.maskValueSet(this.Options, MountOption.values());
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList("Version", "ThreadCount", "Options", "GlobalContext", "MountPoint", "UNCName", "Timeout", "AllocationUnitSize", "SectorSize");
}
@Override
public String toString() {
return String.format("DeviceOptions(Version=%s, ThreadCount=%s, Options=%s, mountOptions=%s, GlobalContext=%s, MountPoint=%s, UNCName=%s, Timeout=%s, AllocationUnitSize=%s, SectorSize=%s)",
UnsignedNumbers.toUnsignedString(this.Version),
UnsignedNumbers.toUnsignedString(this.ThreadCount),
UnsignedNumbers.toUnsignedString(this.Options),
this.getMountOptions(),
UnsignedNumbers.toUnsignedString(this.GlobalContext),
this.MountPoint,
this.UNCName,
UnsignedNumbers.toUnsignedString(this.Timeout),
UnsignedNumbers.toUnsignedString(this.AllocationUnitSize),
UnsignedNumbers.toUnsignedString(this.SectorSize));
}
}