Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	dokan-java.iml
  • Loading branch information
Armin Schrenk committed Apr 25, 2020
2 parents 520ecc1 + e445007 commit 64233b2
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 138 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ hs_err_pid*
# gradle directory
.gradle/*
!gradle/

# Mac metadata
.DS_Store
7 changes: 0 additions & 7 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/compiler.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/encodings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

21 changes: 11 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ plugins {
id 'com.jfrog.bintray' version '1.8.4'
}

tasks.withType(JavaCompile) {
options.incremental = true
options.encoding = 'UTF-8'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

dependencies {
implementation (group:'com.google.guava', name:'guava', version:guavaVersion)
implementation (group:'net.java.dev.jna', name:'jna', version:jnaVersion)
implementation (group: 'commons-io', name: 'commons-io', version: apacheCommonsIOVersion)

api (group:'net.java.dev.jna', name:'jna-platform', version:jnaVersion)
api (group:'org.slf4j', name:'slf4j-api', version:slf4jVersion) //is this correct or should it be implementation?

testImplementation (group:'org.slf4j', name:'slf4j-simple', version:'1.7.25')
testImplementation (group:'org.junit.jupiter', name:'junit-jupiter-api', version:'5.3.1')

testRuntimeOnly (group:'org.junit.jupiter', name:'junit-jupiter-engine', version:'5.3.1')
testImplementation (group:'org.junit.jupiter', name:'junit-jupiter-api', version:junitVersion)
testRuntimeOnly (group:'org.junit.jupiter', name:'junit-jupiter-engine', version:junitVersion)
}

// In this section you declare where to find the dependencies of your project
Expand Down Expand Up @@ -75,12 +76,12 @@ test {
}

task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allJava
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

Expand Down
13 changes: 0 additions & 13 deletions dokan-java.iml

This file was deleted.

22 changes: 6 additions & 16 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,18 @@ maintainer=Armin Schrenk
maintainerId=infeo
maintainerMail=[email protected]


#license
licenseName=GNU Lesser General Public License, Version 3.0
licenseUrl=https://www.gnu.org/licenses/lgpl-3.0.en.html

#lib versions
jnaVersion=5.4.0
guavaVersion=27.0-jre
slf4jVersion=1.7.25
apacheCommonsIOVersion=2.6
jnaVersion=5.5.0
slf4jVersion=1.7.30
junitVersion =5.6.0

#using the build cache
org.gradle.caching=true
#level of output logging
org.gradle.console=rich
# location of java home
#org.gradle.java.home=PATH/TO/JDK
#arguments passed to the JVM
#org.gradle.jvmargs=...
#logging level
org.gradle.logging.level=lifecycle
#more than one jvm is spawned to build several projects in parallel
org.gradle.parallel=true

#passing systemproperties to jvm with systemProp
#systemProp.waffle=waffle
#more than one jvm is spawned to build several projects in parallel
org.gradle.parallel=true
7 changes: 2 additions & 5 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#Wed Jan 22 15:25:48 PST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
6 changes: 3 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
/* rootProject.name = 'dokan-java'
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.10.2/userguide/multi_project_builds.html
*/

rootProject.name = 'dokan-java'
rootProject.name = 'dokan-java'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import dev.dokan.dokan_java.constants.dokany.MountError;
import dev.dokan.dokan_java.constants.dokany.MountOption;
Expand Down
49 changes: 30 additions & 19 deletions src/main/java/dev/dokan/dokan_java/DokanyException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,49 @@

public final class DokanyException extends RuntimeException {

private final int value;
private final String message;
private final Throwable cause;
private final int errorCode;

public DokanyException(Exception e) {
this.value = Integer.MIN_VALUE;
this.message = "";
this.cause = e;
super(e);
this.errorCode = Integer.MIN_VALUE;
}

public DokanyException(String message) {
super(message);
this.errorCode = Integer.MIN_VALUE;
}
public DokanyException(String message, int errorCode) {
this.value = errorCode;
this.message = message;
this.cause = null;
super(message);
this.errorCode = errorCode;
}

public DokanyException(String message, Throwable cause) {
this.value = Integer.MIN_VALUE;
this.message = message;
this.cause = cause;
public DokanyException(Throwable cause, int errorCode) {
super(cause);
this.errorCode = errorCode;
}

public int getValue() {
return value;
public DokanyException(String message, Throwable cause) {
super(message, cause);
this.errorCode = Integer.MIN_VALUE;
}

public DokanyException(String message, Throwable cause, int errorCode) {
super(message, cause);
this.errorCode = errorCode;
}

public Throwable getCause() {
return this.cause;
public int getErrorCode() {
return errorCode;
}

public String getMessage() {
return message;
/**
* Use #getErrorCode() instead.
* @return error code.
*/
@Deprecated
public int getValue() {
return errorCode;
}


}
5 changes: 3 additions & 2 deletions src/main/java/dev/dokan/dokan_java/DokanyOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* <p>
* This is the same struct as <i>_DOKAN_OPERATIONS</i> (dokan.h) in the C++ version of Dokany.
*/
@SuppressWarnings("ALL")
public class DokanyOperations extends Structure {

public DokanyOperations() {
Expand Down Expand Up @@ -646,9 +647,9 @@ void callback(

interface Win32FindStreamDataInterface {

public void length(long val);
void length(long val);

public char[] cFileName();
char[] cFileName();
}

public void setZwCreateFile(DokanyOperations.ZwCreateFile zwCreateFile) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.dokan.dokan_java.examples;

import com.google.common.base.CharMatcher;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinBase;
Expand Down Expand Up @@ -94,7 +93,7 @@ public int zwCreateFile(WString rawPath, WinBase.SECURITY_ATTRIBUTES securityCon
}

if (Files.isDirectory(p)) {
if ((rawCreateOptions & CreateOptions.FILE_NON_DIRECTORY_FILE) == 1) {
if ((rawCreateOptions & CreateOptions.FILE_NON_DIRECTORY_FILE) != 0) {
return Win32ErrorCodes.ERROR_DIRECTORY;
} else {
dokanFileInfo.IsDirectory = 1;
Expand Down Expand Up @@ -242,7 +241,9 @@ public int getVolumeInformation(Pointer rawVolumeNameBuffer, int rawVolumeNameSi

private Path getrootedPath(WString rawPath) {
String unixPath = rawPath.toString().replace('\\', '/');
String relativeUnixPath = CharMatcher.is('/').trimLeadingFrom(unixPath);
String relativeUnixPath = unixPath;
if(unixPath.startsWith("/"))
relativeUnixPath = unixPath.length()==1?"":unixPath.substring(1); // if it is already the root, we return the empty string
return root.resolve(relativeUnixPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public EnumIntegerSet(final Class<T> clazz) {
this.elements = EnumSet.noneOf(clazz);
}

@SafeVarargs
public EnumIntegerSet(T first, T... others) {
this.elements = EnumSet.of(first, others);
}
Expand Down Expand Up @@ -49,6 +50,7 @@ public static <T extends Enum<T> & EnumInteger> EnumIntegerSet<T> enumSetFromInt
return elements;
}

@SafeVarargs
public final void add(T item, T... items) {
if (item == null) {
throw new IllegalArgumentException("Adding null is not allowed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public int sizeOfByteArray() {
+ 2 // aclSize
+ 2 //ace count
+ 2 //sbz2
+ aces.stream().reduce(0, (sum, ace) -> sum + ace.sizeOfByteArray(), (x, y) -> x + y);
+ aces.stream().reduce(0, (sum, ace) -> sum + ace.sizeOfByteArray(), Integer::sum);
}

public static AccessControlList createDaclRevision2(List<? extends AccessControlEntry> aces) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package dev.dokan.dokan_java.structure.filesecurity;

import dev.dokan.dokan_java.Byteable;
import dev.dokan.dokan_java.DokanyException;
import dev.dokan.dokan_java.constants.microsoft.filesecurity.SidIdentifierAuthority;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.ByteBuffer;
import java.util.ArrayList;
Expand All @@ -16,10 +15,10 @@
*/
public class SecurityIdentifier implements Byteable {

private static final Logger LOG = LoggerFactory.getLogger(SecurityIdentifier.class);

private final byte revision = 0x01;

private final static int MAX_SUB_AUTHORITIES =15 ;

private SidIdentifierAuthority sidAuth;

private List<Integer> subAuthorities;
Expand All @@ -33,21 +32,12 @@ public class SecurityIdentifier implements Byteable {
*/
public SecurityIdentifier(SidIdentifierAuthority sidAuth, List<Integer> subAuthorities) {
this.sidAuth = sidAuth;
this.subAuthorities = new ArrayList<>(0);
this.subAuthorities = new ArrayList<>(MAX_SUB_AUTHORITIES);
if (subAuthorities != null) {
if (subAuthorities.size() <= 15) {
if (subAuthorities.size() <= MAX_SUB_AUTHORITIES) {
this.subAuthorities.addAll(subAuthorities);
} else {
LOG.warn("Number of subauthorities exceeds the limit of 15. Only taking the first 15 ones.");
int i = 0;
for (Integer subAuth : subAuthorities) {
this.subAuthorities.add(subAuth);
if (i >= 15) {
break;
}
i++;
}

throw new DokanyException("Number of sub-authorities exceeds the limit of "+MAX_SUB_AUTHORITIES+", it is: "+subAuthorities.size());
}
}
}
Expand Down
Loading

0 comments on commit 64233b2

Please sign in to comment.