forked from anatawa12/asar4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5a0d356
Showing
27 changed files
with
2,165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* text=auto | ||
*.java text | ||
*.kt text | ||
*.json text | ||
*.asar -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/gradle | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=gradle | ||
|
||
### Gradle ### | ||
.gradle | ||
build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 | ||
# gradle/wrapper/gradle-wrapper.properties | ||
|
||
### Gradle Patch ### | ||
**/build/ | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/gradle | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
// for subproject configurations | ||
java | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
group = "com.anatawa12.asar4j" | ||
version = "1.0-SNAPSHOT" | ||
|
||
subprojects { | ||
apply(plugin = "java") | ||
apply(plugin = "maven-publish") | ||
apply(plugin = "signing") | ||
|
||
group = project(":").group | ||
version = project(":").version | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.apache.commons:commons-compress:1.20") | ||
testImplementation("com.google.guava:guava:30.1.1-jre") | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.compileJava { | ||
options.compilerArgs.add("-Xlint") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
java | ||
} |
62 changes: 62 additions & 0 deletions
62
common/src/main/java/com/anatawa12/asar4j/AsarDirectoryEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.anatawa12.asar4j; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
class AsarDirectoryEntry extends AsarEntry { | ||
// if java.util.HashMap, this is mutable. | ||
// if not, this must be immutable. | ||
private Map<String, AsarEntry> entries; | ||
|
||
AsarDirectoryEntry(String name, Map<String, AsarEntry> files) { | ||
super(name); | ||
entries = files; | ||
} | ||
|
||
@Override | ||
public AsarEntryType getType() { | ||
return AsarEntryType.DIRECTORY; | ||
} | ||
|
||
@Override | ||
public Collection<AsarEntry> getChildren() throws IllegalStateException { | ||
return Collections.unmodifiableCollection(entries.values()); | ||
} | ||
|
||
@Override | ||
public AsarEntry getChild(String name) throws IllegalStateException { | ||
return entries.get(name); | ||
} | ||
|
||
@Override | ||
public boolean isExecutable() { | ||
throw new IllegalStateException("this is not FILE, but DIRECTORY"); | ||
} | ||
|
||
@Override | ||
public void setExecutable(boolean executable) { | ||
throw new IllegalStateException("this is not FILE, but DIRECTORY"); | ||
} | ||
|
||
void addChild(AsarEntry child) { | ||
if (!child.getName().startsWith(getName()) | ||
|| child.getName().length() == getName().length() | ||
|| child.getName().charAt(child.getName().length() - 1) != '/') | ||
throw new IllegalArgumentException("the entry is not descendants of this"); | ||
String name = child.getName().substring(getName().length() + 1); | ||
if (name.contains("/")) | ||
throw new IllegalArgumentException("the entry is grandchildren"); | ||
entries.put(name, child); | ||
} | ||
|
||
@Override | ||
protected AsarDirectoryEntry clone() { | ||
AsarDirectoryEntry entry = (AsarDirectoryEntry) super.clone(); | ||
if (entries instanceof HashMap<?, ?>) { | ||
entry.entries = new HashMap<>(entries); | ||
} | ||
return entry; | ||
} | ||
} |
Oops, something went wrong.