forked from dokan-dev/dokan-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MountInfo-API to wrap the class DokanOptions for the respective field in DokanFileHandle (wrapper for DokanFileInfo). Added Interfaces ROMountInfo and RWMountInfo Added ImmutableMountInfo and MountInfo as implementations This commit is part of my effort to fix dokan-java's issue dokan-dev#32
- Loading branch information
Showing
4 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
145 changes: 145 additions & 0 deletions
145
src/main/java/dev/dokan/dokan_java/wrappers/mountinfo/ImmutableMountInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package dev.dokan.dokan_java.wrappers.mountinfo; | ||
|
||
|
||
import com.sun.jna.WString; | ||
import dev.dokan.dokan_java.DokanNativeMethods; | ||
import dev.dokan.dokan_java.constants.dokany.MountOption; | ||
import dev.dokan.dokan_java.structure.DokanOptions; | ||
import dev.dokan.dokan_java.structure.EnumIntegerSet; | ||
|
||
|
||
public class ImmutableMountInfo implements ROMountInfo { | ||
|
||
// private final long globalContext; | ||
|
||
private final short threadCount; | ||
private final int mountOptions; | ||
private final String mountPoint; | ||
private final String uncName; | ||
private final long timeout; | ||
private final long allocationUnitSize; | ||
private final long sectorSize; | ||
|
||
public ImmutableMountInfo(DokanOptions dokanOptions) { | ||
this.threadCount = dokanOptions.ThreadCount; | ||
this.mountOptions = dokanOptions.Options; | ||
// this.globalContext = dokanOptions.GlobalContext; | ||
this.mountPoint = dokanOptions.MountPoint.toString(); | ||
this.uncName = dokanOptions.UNCName.toString(); | ||
this.timeout = dokanOptions.Timeout; | ||
this.allocationUnitSize = dokanOptions.AllocationUnitSize; | ||
this.sectorSize = dokanOptions.SectorSize; | ||
} | ||
|
||
ImmutableMountInfo(ImmutableMountInfo info) { | ||
this.threadCount = info.threadCount; | ||
this.mountOptions = info.mountOptions; | ||
// this.globalContext = info.globalContext; | ||
this.mountPoint = info.mountPoint; | ||
this.uncName = info.uncName; | ||
this.timeout = info.timeout; | ||
this.allocationUnitSize = info.allocationUnitSize; | ||
this.sectorSize = info.sectorSize; | ||
} | ||
|
||
ImmutableMountInfo(MountInfo info) { | ||
this.threadCount = info.getThreadCount(); | ||
this.mountOptions = info.getFlags(); | ||
// this.globalContext = info.getGlobalContext(); | ||
this.mountPoint = info.getMountPoint(); | ||
this.uncName = info.getUNCName(); | ||
this.timeout = info.getTimeout(); | ||
this.allocationUnitSize = info.getAllocationUnitSize(); | ||
this.sectorSize = info.getSectorSize(); | ||
} | ||
|
||
@Override | ||
public short getDokanVersion() { | ||
return DokanNativeMethods.getMinimumRequiredDokanVersion(); | ||
} | ||
|
||
@Override | ||
public short getThreadCount() { | ||
return this.threadCount; | ||
} | ||
|
||
@Override | ||
public EnumIntegerSet<MountOption> getMountOptions() { | ||
return MountOption.fromInt(this.mountOptions); | ||
} | ||
|
||
@Override | ||
public int getFlags() { | ||
return this.mountOptions; | ||
} | ||
|
||
@Override | ||
public boolean getFlag(MountOption flag) { | ||
return (this.mountOptions & flag.getMask()) != 0; | ||
} | ||
|
||
// @Override | ||
// public long getGlobalContext() { | ||
// return this.globalContext; | ||
// } | ||
|
||
@Override | ||
public String getMountPoint() { | ||
return this.mountPoint; | ||
} | ||
|
||
@Override | ||
public String getUNCName() { | ||
return this.uncName; | ||
} | ||
|
||
@Override | ||
public long getTimeout() { | ||
return this.timeout; | ||
} | ||
|
||
@Override | ||
public long getAllocationUnitSize() { | ||
return this.allocationUnitSize; | ||
} | ||
|
||
@Override | ||
public long getSectorSize() { | ||
return this.sectorSize; | ||
} | ||
|
||
@Override | ||
public boolean isMutable() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ROMountInfo immutableCopy() { | ||
return new ImmutableMountInfo(this); | ||
} | ||
|
||
@Override | ||
public RWMountInfo mutableCopy() { | ||
return new MountInfo(this); | ||
} | ||
|
||
@Override | ||
public DokanOptions nativeCopy() { | ||
DokanOptions options = new DokanOptions(this.mountPoint, this.threadCount, this.mountOptions, this.uncName, this.timeout, this.allocationUnitSize, this.sectorSize); | ||
// options.GlobalContext = this.globalContext; | ||
|
||
return options; | ||
} | ||
|
||
@Override | ||
public void nativeCopy(DokanOptions options) { | ||
options.ThreadCount = this.threadCount; | ||
options.Options = this.mountOptions; | ||
// options.GlobalContext = this.globalContext; | ||
options.MountPoint = new WString(this.mountPoint); | ||
options.UNCName = new WString(this.uncName); | ||
options.Timeout = this.timeout; | ||
options.AllocationUnitSize = this.allocationUnitSize; | ||
options.SectorSize = this.sectorSize; | ||
} | ||
} |
203 changes: 203 additions & 0 deletions
203
src/main/java/dev/dokan/dokan_java/wrappers/mountinfo/MountInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
package dev.dokan.dokan_java.wrappers.mountinfo; | ||
|
||
|
||
import com.sun.jna.WString; | ||
import dev.dokan.dokan_java.DokanNativeMethods; | ||
import dev.dokan.dokan_java.constants.dokany.MountOption; | ||
import dev.dokan.dokan_java.structure.DokanOptions; | ||
import dev.dokan.dokan_java.structure.EnumIntegerSet; | ||
|
||
|
||
public class MountInfo implements RWMountInfo { | ||
|
||
// private long globalContext; | ||
|
||
private short threadCount; | ||
private int mountOptions; | ||
private String mountPoint; | ||
private String uncName; | ||
private long timeout; | ||
private long allocationUnitSize; | ||
private long sectorSize; | ||
|
||
public MountInfo(DokanOptions dokanOptions) { | ||
this.threadCount = dokanOptions.ThreadCount; | ||
this.mountOptions = dokanOptions.Options; | ||
// this.globalContext = dokanOptions.GlobalContext; | ||
this.mountPoint = dokanOptions.MountPoint.toString(); | ||
this.uncName = dokanOptions.UNCName.toString(); | ||
this.timeout = dokanOptions.Timeout; | ||
this.allocationUnitSize = dokanOptions.AllocationUnitSize; | ||
this.sectorSize = dokanOptions.SectorSize; | ||
} | ||
|
||
MountInfo(MountInfo info) { | ||
this.threadCount = info.threadCount; | ||
this.mountOptions = info.mountOptions; | ||
// this.globalContext = info.globalContext; | ||
this.mountPoint = info.mountPoint; | ||
this.uncName = info.uncName; | ||
this.timeout = info.timeout; | ||
this.allocationUnitSize = info.allocationUnitSize; | ||
this.sectorSize = info.sectorSize; | ||
} | ||
|
||
MountInfo(ImmutableMountInfo info) { | ||
this.threadCount = info.getThreadCount(); | ||
this.mountOptions = info.getFlags(); | ||
// this.globalContext = info.getGlobalContext(); | ||
this.mountPoint = info.getMountPoint(); | ||
this.uncName = info.getUNCName(); | ||
this.timeout = info.getTimeout(); | ||
this.allocationUnitSize = info.getAllocationUnitSize(); | ||
this.sectorSize = info.getSectorSize(); | ||
} | ||
|
||
@Override | ||
public short getDokanVersion() { | ||
return DokanNativeMethods.getMinimumRequiredDokanVersion(); | ||
} | ||
|
||
@Override | ||
public short getThreadCount() { | ||
return this.threadCount; | ||
} | ||
|
||
@Override | ||
public void setThreadCount(short threadCount) { | ||
this.threadCount = threadCount; | ||
} | ||
|
||
@Override | ||
public EnumIntegerSet<MountOption> getMountOptions() { | ||
return MountOption.fromInt(this.mountOptions); | ||
} | ||
|
||
@Override | ||
public void setMountOptions(EnumIntegerSet<MountOption> mountOptions) { | ||
this.mountOptions = mountOptions.toInt(); | ||
} | ||
|
||
@Override | ||
public int getFlags() { | ||
return this.mountOptions; | ||
} | ||
|
||
@Override | ||
public void setFlags(int flags) { | ||
this.mountOptions = flags; | ||
} | ||
|
||
@Override | ||
public boolean getFlag(MountOption flag) { | ||
return (this.mountOptions & flag.getMask()) != 0; | ||
} | ||
|
||
@Override | ||
public boolean setFlag(MountOption flag) { | ||
return updateFlag(flag, true); | ||
} | ||
|
||
@Override | ||
public boolean unsetFlag(MountOption flag) { | ||
return updateFlag(flag, false); | ||
} | ||
|
||
@Override | ||
public boolean updateFlag(MountOption flag, boolean value) { | ||
boolean prev = getFlag(flag); | ||
this.mountOptions &= value ? flag.getMask() : ~flag.getMask(); | ||
|
||
return prev; | ||
} | ||
|
||
// @Override | ||
// public long getGlobalContext() { | ||
// return this.globalContext; | ||
// } | ||
|
||
@Override | ||
public String getMountPoint() { | ||
return this.mountPoint; | ||
} | ||
|
||
@Override | ||
public void setMountPoint(String mountPoint) { | ||
this.mountPoint = mountPoint; | ||
} | ||
|
||
@Override | ||
public String getUNCName() { | ||
return this.uncName; | ||
} | ||
|
||
@Override | ||
public void setUNCName(String uncName) { | ||
this.uncName = uncName; | ||
} | ||
|
||
@Override | ||
public long getTimeout() { | ||
return this.timeout; | ||
} | ||
|
||
@Override | ||
public void setTimeout(long timeout) { | ||
this.timeout = timeout; | ||
} | ||
|
||
@Override | ||
public long getAllocationUnitSize() { | ||
return this.allocationUnitSize; | ||
} | ||
|
||
@Override | ||
public void setAllocationUnitSize(long allocationUnitSize) { | ||
this.allocationUnitSize = allocationUnitSize; | ||
} | ||
|
||
@Override | ||
public long getSectorSize() { | ||
return this.sectorSize; | ||
} | ||
|
||
@Override | ||
public void setSectorSize(long sectorSize) { | ||
this.sectorSize = sectorSize; | ||
} | ||
|
||
@Override | ||
public boolean isMutable() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public ROMountInfo immutableCopy() { | ||
return new ImmutableMountInfo(this); | ||
} | ||
|
||
@Override | ||
public RWMountInfo mutableCopy() { | ||
return new MountInfo(this); | ||
} | ||
|
||
@Override | ||
public DokanOptions nativeCopy() { | ||
DokanOptions options = new DokanOptions(this.mountPoint, this.threadCount, this.mountOptions, this.uncName, this.timeout, this.allocationUnitSize, this.sectorSize); | ||
// options.GlobalContext = this.globalContext; | ||
|
||
return options; | ||
} | ||
|
||
@Override | ||
public void nativeCopy(DokanOptions options) { | ||
options.ThreadCount = this.threadCount; | ||
options.Options = this.mountOptions; | ||
// options.GlobalContext = this.globalContext; | ||
options.MountPoint = new WString(this.mountPoint); | ||
options.UNCName = new WString(this.uncName); | ||
options.Timeout = this.timeout; | ||
options.AllocationUnitSize = this.allocationUnitSize; | ||
options.SectorSize = this.sectorSize; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/dev/dokan/dokan_java/wrappers/mountinfo/ROMountInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dev.dokan.dokan_java.wrappers.mountinfo; | ||
|
||
|
||
import dev.dokan.dokan_java.constants.dokany.MountOption; | ||
import dev.dokan.dokan_java.structure.DokanOptions; | ||
import dev.dokan.dokan_java.structure.EnumIntegerSet; | ||
|
||
|
||
public interface ROMountInfo { | ||
|
||
short getDokanVersion(); | ||
|
||
short getThreadCount(); | ||
|
||
EnumIntegerSet<MountOption> getMountOptions(); | ||
|
||
int getFlags(); | ||
|
||
boolean getFlag(MountOption flag); | ||
|
||
// long getGlobalContext(); | ||
|
||
String getMountPoint(); | ||
|
||
String getUNCName(); | ||
|
||
long getTimeout(); | ||
|
||
long getAllocationUnitSize(); | ||
|
||
long getSectorSize(); | ||
|
||
boolean isMutable(); | ||
|
||
ROMountInfo immutableCopy(); | ||
|
||
RWMountInfo mutableCopy(); | ||
|
||
DokanOptions nativeCopy(); | ||
|
||
void nativeCopy(DokanOptions options); | ||
} |
Oops, something went wrong.