- Changed char_to_java() to use C charset instead of JVM's default encoding.
- Changed PosixFileFunctions.readLink() to return String instead of byte[].
This commit is contained in:
@@ -36,11 +36,11 @@ public class DefaultPosixFile implements PosixFile {
|
||||
@Override
|
||||
public String readLink(File link) throws NativeException {
|
||||
FunctionResult result = new FunctionResult();
|
||||
byte[] encodedContents = PosixFileFunctions.readlink(encode(link), result);
|
||||
String contents = PosixFileFunctions.readlink(encode(link), result);
|
||||
if (result.isFailed()) {
|
||||
throw new NativeException(String.format("Could not read symlink %s: %s", link, result.getMessage()));
|
||||
}
|
||||
return decode(encodedContents);
|
||||
return contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,14 +52,6 @@ public class DefaultPosixFile implements PosixFile {
|
||||
}
|
||||
}
|
||||
|
||||
private String decode(byte[] path) {
|
||||
try {
|
||||
return new String(path, 0, path.length, characterEncoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new NativeException(String.format("Could not decode path using encoding %s.", characterEncoding), e);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] encode(File file) {
|
||||
return encode(file.getPath());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.rubygrapefruit.platform.internal.FunctionResult;
|
||||
import net.rubygrapefruit.platform.internal.MutableSystemInfo;
|
||||
|
||||
public class NativeLibraryFunctions {
|
||||
public static final int VERSION = 7;
|
||||
public static final int VERSION = 8;
|
||||
|
||||
public static native int getVersion();
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@ public class PosixFileFunctions {
|
||||
|
||||
public static native void symlink(byte[] file, byte[] content, FunctionResult result);
|
||||
|
||||
public static native byte[] readlink(byte[] file, FunctionResult result);
|
||||
public static native String readlink(byte[] file, FunctionResult result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user