mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-19 22:25:56 +00:00
More documentation.
This commit is contained in:
@@ -18,43 +18,79 @@ package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.iggy.conversion.IggySwfBundle;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Information about openable source.
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class OpenableSourceInfo {
|
||||
|
||||
/**
|
||||
* Input stream of the source
|
||||
*/
|
||||
private final InputStream inputStream;
|
||||
|
||||
/**
|
||||
* File path of the source
|
||||
*/
|
||||
private String file;
|
||||
|
||||
/**
|
||||
* Title of the file
|
||||
*/
|
||||
private String fileTitle;
|
||||
|
||||
/**
|
||||
* Whether to auto-detect bundle
|
||||
*/
|
||||
private final boolean detectBundle;
|
||||
|
||||
/**
|
||||
* Whether the source is empty
|
||||
*/
|
||||
private boolean empty = false;
|
||||
|
||||
/**
|
||||
* Kind of the source
|
||||
*/
|
||||
private OpenableSourceKind kind;
|
||||
|
||||
/**
|
||||
* Constructs OpenableSourceInfo with empty source
|
||||
* @param fileTitle Title of the file
|
||||
*/
|
||||
public OpenableSourceInfo(String fileTitle) {
|
||||
this(null, null, fileTitle, false);
|
||||
empty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the source is empty
|
||||
* @return true if the source is empty
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs OpenableSourceInfo with input stream
|
||||
* @param inputStream Input stream of the source
|
||||
* @param file File path of the source
|
||||
* @param fileTitle Title of the file
|
||||
*/
|
||||
public OpenableSourceInfo(InputStream inputStream, String file, String fileTitle) {
|
||||
this(inputStream, file, fileTitle, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs OpenableSourceInfo with input stream
|
||||
* @param inputStream Input stream of the source
|
||||
* @param file File path of the source
|
||||
* @param fileTitle Title of the file
|
||||
* @param detectBundle Whether to auto-detect bundle
|
||||
*/
|
||||
public OpenableSourceInfo(InputStream inputStream, String file, String fileTitle, boolean detectBundle) {
|
||||
this.inputStream = inputStream;
|
||||
this.file = file;
|
||||
@@ -63,10 +99,17 @@ public class OpenableSourceInfo {
|
||||
detectKind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets kind of the source.
|
||||
* @return Kind of the source
|
||||
*/
|
||||
public OpenableSourceKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects kind of the source.
|
||||
*/
|
||||
private void detectKind() {
|
||||
if (isBundle()) {
|
||||
kind = OpenableSourceKind.BUNDLE;
|
||||
@@ -77,32 +120,54 @@ public class OpenableSourceInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets input stream of the source.
|
||||
* @return Input stream of the source
|
||||
*/
|
||||
public InputStream getInputStream() {
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets file path of the source.
|
||||
* @return File path of the source
|
||||
*/
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets file path of the source.
|
||||
* @param file File path of the source
|
||||
*/
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
detectKind();
|
||||
empty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets title of the file.
|
||||
*
|
||||
* @param fileTitle File title
|
||||
*/
|
||||
public void setFileTitle(String fileTitle) {
|
||||
this.fileTitle = fileTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets title of the file.
|
||||
*
|
||||
* @return File title
|
||||
*/
|
||||
public String getFileTitle() {
|
||||
return fileTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title of the file
|
||||
* Gets title of the file.
|
||||
*
|
||||
* @return file title
|
||||
* @return File title
|
||||
*/
|
||||
public String getFileTitleOrName() {
|
||||
if (fileTitle != null) {
|
||||
@@ -111,11 +176,15 @@ public class OpenableSourceInfo {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the source is a bundle.
|
||||
* @return True if the source is a bundle
|
||||
*/
|
||||
public boolean isBundle() {
|
||||
if (inputStream == null && file != null) {
|
||||
File fileObj = new File(file);
|
||||
String fileName = fileObj.getName();
|
||||
if (fileName.startsWith("asdec_") && fileName.endsWith(".tmp")) {
|
||||
if (fileName.startsWith("asdec_") && fileName.endsWith(".tmp")) { //FIXME: is this still needed?
|
||||
return false;
|
||||
}
|
||||
String extension = Path.getExtension(fileObj);
|
||||
@@ -124,6 +193,13 @@ public class OpenableSourceInfo {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bundle from the source.
|
||||
* @param noCheck Whether to check the bundle
|
||||
* @param searchMode Search mode
|
||||
* @return Bundle or null
|
||||
* @throws IOException
|
||||
*/
|
||||
public Bundle getBundle(boolean noCheck, SearchMode searchMode) throws IOException {
|
||||
if (!isBundle()) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user