Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.5 #5

Merged
merged 6 commits into from
Nov 30, 2024
Merged
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
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>moe.yo3explorer</groupId>
<artifactId>dotnet4j</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>

<packaging>jar</packaging>

Expand All @@ -15,15 +15,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.1</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.5</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
Expand All @@ -34,7 +34,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<version>3.7.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -63,7 +63,7 @@
<additionalOption>-Xdoclint:-missing</additionalOption>
</additionalOptions>
<locale>en_US</locale> <!-- doesn't work why ??? -->
<debug>true</debug>
<debug>false</debug>
<verbose>false</verbose>
<failOnWarnings>false</failOnWarnings>
<failOnError>false</failOnError>
Expand All @@ -80,7 +80,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<version>5.10.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -104,7 +104,7 @@
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.11</version>
<version>1.1.14</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dotnet4j/io/BinaryReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,14 @@ private int internalReadOneChar() {
charsRead = this.singleChar.length;

assert charsRead < 2 : "InternalReadOneChar - assuming we only got 0 or 1 char, not 2!";
// System.err.println("That became: " + charsRead + " characters.");
//logger.log(Level.TRACE, "That became: " + charsRead + " characters.");
}
if (charsRead == 0)
return -1;
return this.singleChar[0];
}

//[SecuritySafeCritical]
// [SecuritySafeCritical]
public char[] readChars(int count) throws java.io.IOException {
if (count < 0) {
throw new IndexOutOfBoundsException("count: " + count);
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/dotnet4j/io/FileStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

import vavi.util.Debug;
import static java.lang.System.getLogger;


/**
* Created by FT on 27.11.14.
*/
public class FileStream extends Stream {

private static final Logger logger = getLogger(FileStream.class.getName());

private FileChannel channel;
private final FileMode myMode;
private final FileAccess myAccess;
Expand Down Expand Up @@ -156,12 +161,12 @@ public int read(byte[] buffer, int offset, int length) {
int m;
try {
m = channel.read(tmp);
//Debug.println(m + ", " + offset + ", " + length + " / " + channel.size() + ", " + channel.size() + ", " + channel.position());
//logger.log(Level.TRACE, m + ", " + offset + ", " + length + " / " + channel.size() + ", " + channel.size() + ", " + channel.position());
if (m == -1) {
return 0;
}
} catch (IOException e) {
Debug.printStackTrace(e);
logger.log(Level.TRACE, e.getMessage(), e);
throw new dotnet4j.io.IOException(e);
}
return m;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/dotnet4j/io/MemoryStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ public int read(byte[] buffer, int offset, int count) {
return n;
}

//public static boolean debug;

@Override
public void write(byte[] buffer, int offset, int count) {
if (buffer == null)
Expand All @@ -289,7 +287,7 @@ public void write(byte[] buffer, int offset, int count) {
throw new dotnet4j.io.IOException("object disposed");
if (!canWrite())
throw new dotnet4j.io.IOException("not writable");
//if (debug) { Debug.println(offset + ", " + count + "\n" + StringUtil.getDump(buffer, offset, Math.min(count, 64))); new Exception().printStackTrace(); }
//logger.log(Level.TRACE, offset + ", " + count + "\n" + StringUtil.getDump(buffer, offset, Math.min(count, 64))); new Exception().printStackTrace(); }

int i = position + count;
// Check for overflow
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/dotnet4j/io/compat/JavaIOStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


/**
* JavaIOStream.
* InputStream + OutputStream = Stream.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (umjammer)
* @version 0.00 2019/10/09 umjammer initial version <br>
Expand Down Expand Up @@ -118,24 +118,27 @@ public void setLength(long value) {
throw new UnsupportedOperationException();
}

/**
* @return 0 when EOF (it's C# spec) ⚠️⚠️⚠️ CAUTION not same as the java specs. ⚠️⚠️⚠️
*/
@Override
public int read(byte[] buffer, int offset, int length) {
if (is == null) {
throw new dotnet4j.io.IOException("closed");
}

try {
//Debug.println(buffer.length + ", " + offset + ", " + length + ", " + is.available());
//logger.log(Level.TRACE, buffer.length + ", " + offset + ", " + length + ", " + is.available());
int r = is.read(buffer, offset, length);
//Debug.println(StringUtil.getDump(buffer, 16));
//logger.log(Level.TRACE, StringUtil.getDump(buffer, 16));
if (r > 0) {
position += r;
}
if (r == -1) {
//Debug.println("EOF");
//logger.log(Level.TRACE, "EOF");
return 0; // C# Spec.
}
//Debug.println("position: " + position);
//logger.log(Level.TRACE, "position: " + position);
return r;
} catch (IOException e) {
throw new dotnet4j.io.IOException(e);
Expand Down Expand Up @@ -166,7 +169,7 @@ public void write(byte[] buffer, int offset, int count) {
}

try {
//Debug.println("w: " + count + ", " + os);
//logger.log(Level.TRACE, "w: " + count + ", " + os);
os.write(buffer, offset, count);
position += count;
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dotnet4j/io/compat/StreamInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


/**
* StreamInputStream.
* Treats Stream as InputStream.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (umjammer)
* @version 0.00 2019/09/30 umjammer initial version <br>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dotnet4j/io/compat/StreamOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


/**
* StreamOutputStream.
* Treats Stream as OutputStream.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (umjammer)
* @version 0.00 2019/09/30 umjammer initial version <br>
Expand All @@ -34,7 +34,7 @@ public void write(int b) {

@Override
public void write(byte[] buffer, int offset, int count) {
//Debug.println("w: " + count + ", " + stream);
//logger.log(Level.TRACE, "w: " + count + ", " + stream);
stream.write(buffer, offset, count);
}

Expand Down
32 changes: 21 additions & 11 deletions src/main/java/dotnet4j/io/compression/GZipStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import vavi.io.InputEngineOutputStream;
import vavi.io.OutputEngine;
import vavi.io.OutputEngineInputStream;
import vavi.util.Debug;


/**
Expand All @@ -30,10 +31,14 @@
*/
public class GZipStream extends JavaIOStream {

/**
* @param stream assume as input stream
* @param compressionMode {@link CompressionMode}
*/
static InputStream toInputStream(Stream stream, CompressionMode compressionMode) {
try {
InputStream is = new StreamInputStream(stream);
return compressionMode == CompressionMode.Decompress ? new GZIPInputStream(is)
return compressionMode == CompressionMode.Decompress ? new GZIPInputStream(is) // TODO should be null stream? this maybe no mean
: new OutputEngineInputStream(new OutputEngine() {
OutputStream out;

Expand All @@ -45,7 +50,8 @@ static InputStream toInputStream(Stream stream, CompressionMode compressionMode)

@Override public void execute() throws IOException {
int r = is.read(buf);
out.write(buf, 0, r);
if (r < 0) out.close();
else out.write(buf, 0, r);
}

@Override public void finish() {
Expand All @@ -56,24 +62,30 @@ static InputStream toInputStream(Stream stream, CompressionMode compressionMode)
}
}

/**
* @param stream assume as output stream
* @param compressionMode {@link CompressionMode}
*/
static OutputStream toOutputStream(Stream stream, CompressionMode compressionMode) {
try {
OutputStream os = new StreamOutputStream(stream);
return compressionMode == CompressionMode.Compress ? new GZIPOutputStream(os)
: new InputEngineOutputStream(new InputEngine() {
: new InputEngineOutputStream(new InputEngine() { // TODO should be null stream? this maybe no mean
InputStream in;

@Override public void initialize(InputStream in) {
@Override public void initialize(InputStream in) throws IOException {
if (this.in == null && in.available() > 0 /* means stream is for input */) {
Debug.println(in + ", " + in.available());
this.in = new GZIPInputStream(in);
}
}

final byte[] buf = new byte[8192];

@Override public void execute() throws IOException {
if (in == null) {
this.in = new GZIPInputStream(in);
}
int r = in.read(buf);
os.write(buf, 0, r);
if (r < 0) in.close();
else os.write(buf, 0, r);
}

@Override public void finish() {
Expand All @@ -84,9 +96,7 @@ static OutputStream toOutputStream(Stream stream, CompressionMode compressionMod
}
}

/**
*
*/
/** @throws dotnet4j.io.IOException when an error occurs */
public GZipStream(Stream stream, CompressionMode compressionMode) {
super(toInputStream(stream, compressionMode), toOutputStream(stream, compressionMode));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@


public enum AccessControlSections {
/** 随意アクセス制御リスト (DACL: Discretionary Access Control List)。 */
/** DACL: Discretionary Access Control List */
Access(0x2),
/** システム アクセス制御リスト (SACL: System Access Control List)。 */
/** SACL: System Access Control List */
Audit(0x1),
/** プライマリ グループ。 */
/** primary group */
Group(0x8),
/** セクションを指定しません。 */
/** no section specified */
None(0x0),
/** 所有者。 */
/** owner */
Owner(0x4);

final int value;
Expand All @@ -21,6 +21,6 @@ public enum AccessControlSections {
this.value = value;
}

/** セキュリティ記述子全体。 */
/** entire security descriptor */
public static final EnumSet<AccessControlSections> All = EnumSet.of(Audit, Access, Owner, Group);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public String getSecurityDescriptorSddlForm(EnumSet<AccessControlSections> secti

/** TODO impl */
public void setSecurityDescriptorSddlForm(String form, EnumSet<AccessControlSections> sections) {
//System.err.println(form);
//logger.log(Level.TRACE, form);
binaryForm = form.getBytes(StandardCharsets.US_ASCII);
}
}
4 changes: 2 additions & 2 deletions src/main/java/dotnet4j/win32/RegistryValueOptions.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dotnet4j.win32;

public enum RegistryValueOptions {
/** オプションの動作は指定されていません。 */
/** optional behavior is unspecified */
None,
/**
* 型の値が、埋め込まれた環境変数を展開せずに取得されます。
* the value of the type is retrieved without expanding embedded environment variables.
*
* @see "F:Microsoft.Win32.RegistryValueKind.ExpandString"
*/
Expand Down
Loading