-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some native jar wrappers not being recognized as zip archives
- Loading branch information
Showing
5 changed files
with
207 additions
and
44 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
recaf-core/src/main/java/software/coley/recaf/info/properties/builtin/ZipMarkerProperty.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,60 @@ | ||
package software.coley.recaf.info.properties.builtin; | ||
|
||
import jakarta.annotation.Nonnull; | ||
import software.coley.recaf.info.FileInfo; | ||
import software.coley.recaf.info.properties.BasicProperty; | ||
import software.coley.recaf.info.properties.Property; | ||
|
||
/** | ||
* Built in property to track {@link FileInfo} instances that have a ZIP file header within their contents. | ||
* | ||
* @author Matt Coley | ||
*/ | ||
public class ZipMarkerProperty extends BasicProperty<Boolean> { | ||
public static final String KEY = "has-zip-marker"; | ||
|
||
/** | ||
* New property value. | ||
*/ | ||
public ZipMarkerProperty() { | ||
super(KEY, true); | ||
} | ||
|
||
@Override | ||
public boolean persistent() { | ||
return false; | ||
} | ||
|
||
/** | ||
* @param info | ||
* File info instance | ||
* | ||
* @return {@code true} when the file has a ZIP file header in the contents. | ||
*/ | ||
public static boolean get(@Nonnull FileInfo info) { | ||
Property<Boolean> property = info.getProperty(KEY); | ||
if (property != null) { | ||
Boolean value = property.value(); | ||
return value != null && value; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Marks the class as inheriting containing a ZIP file header. | ||
* | ||
* @param info | ||
* File info instance. | ||
*/ | ||
public static void set(@Nonnull FileInfo info) { | ||
info.setProperty(new ZipMarkerProperty()); | ||
} | ||
|
||
/** | ||
* @param info | ||
* File info instance. | ||
*/ | ||
public static void remove(@Nonnull FileInfo info) { | ||
info.removeProperty(KEY); | ||
} | ||
} |
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
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
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
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