Skip to content

Commit

Permalink
Updated DokanFileHandle to use ROMountInfo and added missing method
Browse files Browse the repository at this point in the history
Updated DokanFileHandle to use ROMountInfo instead of DokanOptions
Added setFileInfo method

This commit led to discovery of dokan-dev#46 which leads to problems with this code.
  • Loading branch information
JaniruTEC committed Jun 8, 2020
1 parent bffbce0 commit 8ba91fd
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/main/java/dev/dokan/dokan_java/wrappers/DokanFileHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,34 @@
import dev.dokan.dokan_java.constants.dokany.DokanFileInfoFlag;
import dev.dokan.dokan_java.masking.MaskValueSet;
import dev.dokan.dokan_java.structure.DokanFileInfo;
import dev.dokan.dokan_java.structure.DokanOptions;
import dev.dokan.dokan_java.wrappers.mountinfo.MountInfo;
import dev.dokan.dokan_java.wrappers.mountinfo.ROMountInfo;

import java.util.concurrent.atomic.AtomicInteger;

public class DokanFileHandle { //TODO Add Getters?!
public class DokanFileHandle {

private static final long INVALID_HANDLE = 0L;

private final AtomicInteger flags;
private final long dokanContext; //DokanFileInfo tells us to "never modify". Happy to oblige
private final ROMountInfo mountInfo;

private long context;
private int processId;
private DokanOptions dokanOpts; //TODO

public DokanFileHandle(DokanFileInfo nativeInfo) {
this.context = nativeInfo.Context;
this.dokanContext = nativeInfo.DokanContext;
this.processId = nativeInfo.ProcessId;
this.dokanOpts = nativeInfo.DokanOpts; //TODO Copy/Different link?
/*
* FIXME
* This copy is as expensive as it is useless. A reference to a stored MountInfo-Object would be far more useful.
* Due to bug/issue #46 this would be inherently unsafe, so it's a copy for now...
*
* See https://github.com/dokan-dev/dokan-java/issues/46
*/
this.mountInfo = new MountInfo(nativeInfo.DokanOpts);

MaskValueSet<DokanFileInfoFlag> flagSet = MaskValueSet.emptySet(DokanFileInfoFlag.class);
if(nativeInfo.deleteOnClose()) {
Expand Down Expand Up @@ -49,6 +58,10 @@ public MaskValueSet<DokanFileInfoFlag> getFileInfo() {
return MaskValueSet.maskValueSet(this.flags.get(), DokanFileInfoFlag.values());
}

public void setFileInfo(MaskValueSet<DokanFileInfoFlag> flagSet) {
this.flags.set(flagSet.intValue());
}

public int getFlags() {
return this.flags.get();
}
Expand Down Expand Up @@ -102,11 +115,7 @@ public void setProcessId(int processId) {
this.processId = processId;
}

public DokanOptions getDokanOptions() {
return this.dokanOpts;
}

public void setDokanOptions(DokanOptions dokanOpts) {
this.dokanOpts = dokanOpts;
public ROMountInfo getMountInfo() {
return mountInfo;
}
}

0 comments on commit 8ba91fd

Please sign in to comment.