Skip to content

Commit

Permalink
Added utils-io module
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelaux committed Oct 3, 2023
1 parent 4d5b2ac commit 1f72d2d
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ dependencies{
- [utils](utils%2FREADME.md)
- [entries](utils%2FREADME.md#entries) `utils-entries`
- [files](utils%2FREADME.md#files) `utils-files`
- [io](utils%2FREADME.md#io) `utils-io`
- [pools](utils%2FREADME.md#pools) `utils-pools`
- [refs](utils%2FREADME.md#refs) `utils-refs`
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include ":utils:files"
include ":utils:pools"
include ":utils:entries"
include ":utils:refs"
include ":utils:io"

include "settings"
include "betterCommandHandler"
Expand Down
11 changes: 11 additions & 0 deletions utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Entries](#entries)
- [Files](#files)
- [IO](#io)
- [Pools](#pools)
- [Refs](#refs)

Expand All @@ -22,6 +23,16 @@ Adds `set`, `create` and `copy` methods for each exited Entry type in `Arc`
Adds [`arclibrary.utils.files.InternalFileTree`](files%2Fsrc%2Farclibrary%2Futils%2Ffiles%2FInternalFileTree.java) for internal jar navigation.

---
## <a name="ui"></a> UI

###### Full name: `utils-ui`

### Adds
- [ByteReads](io%2Fsrc%2Farclibrary%2Fio%2FByteReads.java)
- [ByteWrites](io%2Fsrc%2Farclibrary%2Fio%2FByteWrites.java)

----

# <a name="pools"></a>Pools

###### Full name: `utils-pools`
Expand Down
3 changes: 0 additions & 3 deletions utils/entries/build.gradle

This file was deleted.

37 changes: 37 additions & 0 deletions utils/io/src/arclibrary/io/ByteReads.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package arclibrary.io;

import arc.util.io.*;

import java.io.*;
/**
* Uses to read something from clear bytes
* */
public class ByteReads extends Reads{
public final ReusableByteInStream r = new ReusableByteInStream();

public ByteReads(){
super(null);
input = new DataInputStream(r);
}

public ByteReads(byte[] bytes){
this();
setBytes(bytes);
}

public static ReusableByteInStream setBytes(Reads reads, byte[] bytes){
if(reads instanceof ByteReads){
ByteReads byteReads = (ByteReads)reads;
byteReads.setBytes(bytes);
return byteReads.r;
}
ReusableByteInStream reusableByteInStream = new ReusableByteInStream();
reads.input = new DataInputStream(reusableByteInStream);
reusableByteInStream.setBytes(bytes);
return reusableByteInStream;
}

public void setBytes(byte[] bytes){
r.setBytes(bytes);
}
}
24 changes: 24 additions & 0 deletions utils/io/src/arclibrary/io/ByteWrites.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package arclibrary.io;

import arc.util.io.*;

import java.io.*;

/**
* Uses to write something to clear bytes
* */
public class ByteWrites extends Writes{
public final ReusableByteOutStream r = new ReusableByteOutStream(8192);

public ByteWrites(){
super(null);
output = new DataOutputStream(r);
}
public void reset(){
r.reset();
}

public byte[] getBytes(){
return r.toByteArray();
}
}

0 comments on commit 1f72d2d

Please sign in to comment.