Skip to content

Commit

Permalink
fix build and NativeUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
bonede committed Dec 26, 2024
1 parent 5a9bdca commit 2ae788f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ allprojects {
repositories {
mavenCentral()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
}


Expand Down
19 changes: 9 additions & 10 deletions tree-sitter/src/main/java/org/treesitter/utils/NativeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ public static void loadLib(String libName){
try (
FileLock fileLock = channel.lock();
){
if(file.exists() && file.length() > 0){
System.load(file.getAbsolutePath());
return;
}
ByteBuffer buffer = ByteBuffer.allocate(1024 * 4);
int bytesRead;
while ((bytesRead = inputStream.read(buffer.array())) != -1) {
buffer.limit(bytesRead);
channel.write(buffer);
buffer.clear();
if(!file.exists() || file.length() == 0){
ByteBuffer buffer = ByteBuffer.allocate(1024 * 4);
int bytesRead;
while ((bytesRead = inputStream.read(buffer.array())) != -1) {
buffer.limit(bytesRead);
channel.write(buffer);
buffer.clear();
}
}

}
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 2ae788f

Please sign in to comment.