Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/dev/dokan/dokan_java/AbstractDokanyFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class AbstractDokanyFileSystem implements DokanyFileSystem {
protected final FileSystemInformation fileSystemInformation;
protected final DokanyOperations dokanyOperations;
protected final boolean usesKernelFlagsAndCodes;
protected final boolean installShutdownHook;
protected Path mountPoint;
protected String volumeName;
protected int volumeSerialnumber;
Expand All @@ -38,14 +39,19 @@ public abstract class AbstractDokanyFileSystem implements DokanyFileSystem {
private final AtomicBoolean isMounted;
private Set<String> notImplementedMethods;

public AbstractDokanyFileSystem(FileSystemInformation fileSystemInformation, boolean usesKernelFlagsAndCodes) {
public AbstractDokanyFileSystem(FileSystemInformation fileSystemInformation, boolean usesKernelFlagsAndCodes, boolean installShutdownHook) {
this.fileSystemInformation = fileSystemInformation;
this.usesKernelFlagsAndCodes = usesKernelFlagsAndCodes;
this.installShutdownHook = installShutdownHook;
this.isMounted = new AtomicBoolean(false);
this.dokanyOperations = new DokanyOperations();
init(dokanyOperations);
}

public AbstractDokanyFileSystem(FileSystemInformation fileSystemInformation, boolean usesKernelFlagsAndCodes) {
this(fileSystemInformation,usesKernelFlagsAndCodes,true);
}

private void init(DokanyOperations dokanyOperations) {
notImplementedMethods = Arrays.stream(getClass().getMethods())
.filter(method -> method.getAnnotation(NotImplemented.class) != null)
Expand Down Expand Up @@ -247,7 +253,7 @@ public final synchronized void mount(Path mountPoint, String volumeName, int vol
try {
int mountStatus;

if (DokanyUtils.canHandleShutdownHooks()) {
if (installShutdownHook && DokanyUtils.canHandleShutdownHooks()) {
Runtime.getRuntime().addShutdownHook(new Thread(this::unmount));
}

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/dev/dokan/dokan_java/DokanyFileSystemStub.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package dev.dokan.dokan_java;

import dev.dokan.dokan_java.structure.ByHandleFileInformation;
import dev.dokan.dokan_java.structure.DokanFileInfo;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinBase;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import dev.dokan.dokan_java.structure.ByHandleFileInformation;
import dev.dokan.dokan_java.structure.DokanFileInfo;

public class DokanyFileSystemStub extends AbstractDokanyFileSystem {

public DokanyFileSystemStub(FileSystemInformation fileSystemInformation, boolean usesKernelFlagsAndCodes) {
super(fileSystemInformation, usesKernelFlagsAndCodes);
}

public DokanyFileSystemStub(FileSystemInformation fileSystemInformation, boolean usesKernelFlagsAndCodes, boolean installShutdownHook) {
super(fileSystemInformation, usesKernelFlagsAndCodes,installShutdownHook);
}

/**
* {@inheritDoc}
*
Expand Down