Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
? 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyxlandlee committed Dec 26, 2020
1 parent 9ce6787 commit f4ba0a7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out/
*.iml
*.ipr
*.iws
*.iws
run/
46 changes: 34 additions & 12 deletions FileSpliterator.iws
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="2e837d0e-f64d-441f-982b-ceea8ceb799a" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/ByteHelper.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/Emaps.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/InvalidFileException.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FileSpliterator.ipr" beforeDir="false" afterPath="$PROJECT_DIR$/FileSpliterator.ipr" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FileSpliterator.iws" beforeDir="false" afterPath="$PROJECT_DIR$/FileSpliterator.iws" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/CodecStatus.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/CodecStatus.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/Core.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/Core.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/main.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/main.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/version.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/version.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/ByteHelper.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/ByteHelper.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/Emaps.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/io/github/teddyxlandlee/nios/filesplit/util/Emaps.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
Expand Down Expand Up @@ -40,20 +36,33 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
</component>
<component name="RunManager" selected="Application.nul">
<component name="RunManager" selected="Application.Example Decoder">
<configuration default="true" type="JarApplication">
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
<configuration name="Example" type="JetRunConfigurationType">
<configuration name="Example Decoder" type="JetRunConfigurationType">
<module name="FileSpliterator" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="decode $PROJECT_DIR$/run/filesplit-giao.ywlib" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" value="io.github.teddyxlandlee.nios.filesplit.MainKt" />
<option name="WORKING_DIRECTORY" value="" />
<option name="WORKING_DIRECTORY" value="file://run/" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Example Encoder" type="JetRunConfigurationType">
<module name="FileSpliterator" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="encode $PROJECT_DIR$/run/giao.ywlib --size 64 " />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" value="io.github.teddyxlandlee.nios.filesplit.MainKt" />
<option name="WORKING_DIRECTORY" value="file://run/" />
<method v="2">
<option name="Make" enabled="true" />
</method>
Expand Down Expand Up @@ -120,7 +129,8 @@
</configuration>
<list>
<item itemvalue="Application.nul" />
<item itemvalue="Application.Example" />
<item itemvalue="Application.Example Encoder" />
<item itemvalue="Application.Example Decoder" />
</list>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
Expand All @@ -132,6 +142,14 @@
<option name="presentableId" value="Default" />
<updated>1608877305551</updated>
</task>
<task id="LOCAL-00001" summary="? 0.1.0">
<created>1608963131809</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1608963131810</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
Expand All @@ -146,4 +164,8 @@
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="? 0.1.0" />
<option name="LAST_COMMIT_MESSAGE" value="? 0.1.0" />
</component>
</project>
16 changes: 10 additions & 6 deletions src/io/github/teddyxlandlee/nios/filesplit/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ public static void run(CodecStatus codecStatus, File file, int maxOneFileSize, S

public static void encode(File file, int maxOneFileSize, String outputDirectory) {
File outputDirectoryFile = new File(outputDirectory);
if (file.exists() || !outputDirectoryFile.mkdir()) {
if (outputDirectoryFile.exists() || !outputDirectoryFile.mkdir()) {
encode(file, maxOneFileSize, outputDirectory + "_");
return;
}

int i = 0;
FileOutputStream fileOutputStream;
try {
byte[] bytes = new byte[maxOneFileSize - 4];
byte[] bytes;
FileInputStream inputStream = new FileInputStream(file);
while (true) {
int byteCount = inputStream.read(bytes, 0, maxOneFileSize - 4);
if (byteCount < 0)
break;
bytes = inputStream.readNBytes(maxOneFileSize - 4);
if (bytes.length == 0) break;

File outputOneFile = new File(outputDirectory + '/' + i + ".fsplit");
if (!outputOneFile.createNewFile()) {
Expand Down Expand Up @@ -103,7 +102,12 @@ public static void decode(File file) {
FileOutputStream outputStream = new FileOutputStream(newFile);

iCache = 0; // current file name count
for (; iCache < maxFilenameCount; ++iCache) {
for (int iCache2; iCache < maxFilenameCount; ++iCache) {
inputStream = new FileInputStream(file.getName() + '/' + iCache + ".fsplit");
iCache2 = inputStream.read(cache, 0, 4);
if (iCache2 != 4 || toInt(cache) != VersionKt.fsplitHeader) {
throw new InvalidFileException(iCache + ".fsplit", 0x00000002);
}
cache = inputStream.readAllBytes();
outputStream.write(cache);
inputStream.close();
Expand Down
4 changes: 2 additions & 2 deletions src/io/github/teddyxlandlee/nios/filesplit/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import kotlin.system.exitProcess
/**
* @param args [0] encode/decode
* @param args [1] filename
* @param args [2] max one file size, string
* @param args [3] directory
* @param args --size max one file size, string
* @param args --output directory
*/
fun main(args: Array<String>) {
if (args.size < 2)
Expand Down
15 changes: 11 additions & 4 deletions src/io/github/teddyxlandlee/nios/filesplit/util/ByteHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ fun fromInt(i: Int): ByteArray {
fun toInt(bs: ByteArray): Int {
if (bs.size < 4)
return -1
return bs[0].toInt().shl(24) +
bs[1].toInt().shl(16) +
bs[2].toInt().shl(8) +
bs[3].toInt()
val intArray = IntArray(4)
for (i in 0..3) {
if (bs[i] < 0)
intArray[i] = 256 + bs[i]
else
intArray[i] = bs[i].toInt()
}
return intArray[0].shl(24) +
intArray[1].shl(16) +
intArray[2].shl(8) +
intArray[3]
}

fun concat(vararg byteArrays: ByteArray): ByteArray {
Expand Down
2 changes: 1 addition & 1 deletion src/io/github/teddyxlandlee/nios/filesplit/util/Emaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Emaps {

public static Map<Integer, String> errMap = new HashMap<>();
static {
errMap.put(0x00000002, "bad file header for INFO.fsplitinfo");
errMap.put(0x00000002, "bad file header");
errMap.put(0x00000003, "invalid data version: < 1");
errMap.put(0x00000004, "bad string byte length");
errMap.put(0x00000005, "invalid or null new filename");
Expand Down

0 comments on commit f4ba0a7

Please sign in to comment.