diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java index 2bbc8e49..8a1aaf55 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java @@ -22,7 +22,7 @@ import brut.androlib.res.AndrolibResources; import brut.androlib.res.data.ResPackage; import brut.androlib.res.data.ResTable; import brut.androlib.res.data.ResUnknownFiles; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.androlib.res.xml.ResXmlPatcher; import brut.androlib.src.SmaliBuilder; import brut.androlib.src.SmaliDecoder; @@ -31,7 +31,6 @@ import brut.directory.*; import brut.util.BrutIO; import brut.util.OS; import java.io.*; -import java.nio.file.Files; import java.util.*; import java.util.logging.Logger; import java.util.regex.Pattern; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java index 2aa8be2a..aa2ca555 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java @@ -26,7 +26,7 @@ import brut.androlib.meta.VersionInfo; import brut.androlib.res.AndrolibResources; import brut.androlib.res.data.ResPackage; import brut.androlib.res.data.ResTable; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.androlib.res.xml.ResXmlPatcher; import brut.common.BrutException; import brut.directory.DirectoryException; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java index 9b500ddd..ae884321 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java @@ -25,7 +25,7 @@ import brut.androlib.res.data.*; import brut.androlib.res.decoder.*; import brut.androlib.res.decoder.ARSCDecoder.ARSCData; import brut.androlib.res.decoder.ARSCDecoder.FlagsOffset; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.androlib.res.util.ExtMXSerializer; import brut.androlib.res.util.ExtXmlSerializer; import brut.androlib.res.xml.ResValuesXmlSerializable; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/src/SmaliBuilder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/src/SmaliBuilder.java index 75fb2e35..57a375f2 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/src/SmaliBuilder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/src/SmaliBuilder.java @@ -18,14 +18,12 @@ package brut.androlib.src; import brut.androlib.AndrolibException; import brut.androlib.mod.SmaliMod; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.directory.DirectoryException; import java.io.*; -import java.util.List; import java.util.logging.Logger; import org.antlr.runtime.RecognitionException; -import org.apache.commons.io.IOUtils; import org.jf.dexlib2.Opcodes; import org.jf.dexlib2.writer.builder.DexBuilder; import org.jf.dexlib2.writer.io.FileDataStore; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/AndResGuardTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/AndResGuardTest.java index e8d2e0d3..129db300 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/AndResGuardTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/AndResGuardTest.java @@ -16,7 +16,7 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import java.io.File; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeJarTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeJarTest.java index 4ca0146e..5ed1fa72 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeJarTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeJarTest.java @@ -15,7 +15,7 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import org.junit.AfterClass; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index 6a4dace5..6040f039 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -16,7 +16,7 @@ package brut.androlib; import brut.androlib.meta.MetaInfo; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.directory.FileDirectory; import brut.util.OS; @@ -31,7 +31,6 @@ import org.custommonkey.xmlunit.*; import org.junit.*; import static org.junit.Assert.*; -import org.junit.rules.ExpectedException; import org.xml.sax.SAXException; import javax.imageio.ImageIO; @@ -420,7 +419,7 @@ public class BuildAndDecodeTest { String location = tmp + path; - FileDirectory fileDirectory = new FileDirectory(sTestOrigDir + location); + FileDirectory fileDirectory = new FileDirectory(sTestOrigDir, location); Set files = fileDirectory.getFiles(true); for (String filename : files) { diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/DebugTagRetainedTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/DebugTagRetainedTest.java index 7cde0856..fb77867a 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/DebugTagRetainedTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/DebugTagRetainedTest.java @@ -15,7 +15,7 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import org.junit.AfterClass; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/DoubleExtensionUnknownFileTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/DoubleExtensionUnknownFileTest.java index 11c2d13b..55b745ce 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/DoubleExtensionUnknownFileTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/DoubleExtensionUnknownFileTest.java @@ -17,7 +17,7 @@ package brut.androlib; import brut.androlib.meta.MetaInfo; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import org.apache.commons.lang3.StringUtils; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/LargeIntsInManifestTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/LargeIntsInManifestTest.java index f8635315..74e03c99 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/LargeIntsInManifestTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/LargeIntsInManifestTest.java @@ -16,15 +16,12 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; -import brut.directory.FileDirectory; import brut.util.OS; import java.io.*; import java.io.File; import java.io.IOException; -import java.util.Map; -import java.util.Set; import java.util.logging.Logger; import org.custommonkey.xmlunit.*; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/MissingVersionManifestTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/MissingVersionManifestTest.java index 16d121f8..e93e1dc9 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/MissingVersionManifestTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/MissingVersionManifestTest.java @@ -16,7 +16,7 @@ package brut.androlib; import brut.androlib.meta.MetaInfo; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import org.junit.AfterClass; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/ProviderAttributeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/ProviderAttributeTest.java index 0d19efef..242b4af1 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/ProviderAttributeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/ProviderAttributeTest.java @@ -16,9 +16,8 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; -import brut.directory.DirectoryException; import brut.util.OS; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/ReferenceVersionCodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/ReferenceVersionCodeTest.java index 4fa4193f..533a739d 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/ReferenceVersionCodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/ReferenceVersionCodeTest.java @@ -16,7 +16,7 @@ package brut.androlib; import brut.androlib.meta.MetaInfo; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import org.junit.AfterClass; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/SharedLibraryTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/SharedLibraryTest.java index ae35d255..e61e0f44 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/SharedLibraryTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/SharedLibraryTest.java @@ -16,9 +16,8 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; -import brut.directory.DirectoryException; import brut.util.OS; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/UnknownCompressionTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/UnknownCompressionTest.java index f7d1875e..39e5e2bc 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/UnknownCompressionTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/UnknownCompressionTest.java @@ -16,7 +16,7 @@ */ package brut.androlib; -import brut.androlib.res.util.ExtFile; +import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; import org.junit.AfterClass; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtFile.java b/brut.j.dir/src/main/java/brut/directory/ExtFile.java similarity index 89% rename from brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtFile.java rename to brut.j.dir/src/main/java/brut/directory/ExtFile.java index 81d1b033..583c3fa1 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtFile.java +++ b/brut.j.dir/src/main/java/brut/directory/ExtFile.java @@ -14,12 +14,8 @@ * limitations under the License. */ -package brut.androlib.res.util; +package brut.directory; -import brut.directory.Directory; -import brut.directory.DirectoryException; -import brut.directory.FileDirectory; -import brut.directory.ZipRODirectory; import java.io.File; import java.net.URI; diff --git a/brut.j.dir/src/main/java/brut/directory/FileDirectory.java b/brut.j.dir/src/main/java/brut/directory/FileDirectory.java index 8124b47a..33bb124e 100644 --- a/brut.j.dir/src/main/java/brut/directory/FileDirectory.java +++ b/brut.j.dir/src/main/java/brut/directory/FileDirectory.java @@ -22,6 +22,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Paths; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -32,6 +33,14 @@ public class FileDirectory extends AbstractDirectory { this(new File(dir)); } + public FileDirectory(ExtFile dir, String folder) throws DirectoryException { + this(dir.toString(), folder); + } + + public FileDirectory(String dir, String folder) throws DirectoryException { + this(Paths.get(dir, folder).toFile()); + } + public FileDirectory(File dir) throws DirectoryException { super(); if (! dir.isDirectory()) { @@ -79,7 +88,7 @@ public class FileDirectory extends AbstractDirectory { protected void removeFileLocal(String name) { new File(generatePath(name)).delete(); } - + private String generatePath(String name) { return getDir().getPath() + separator + name; } @@ -87,7 +96,7 @@ public class FileDirectory extends AbstractDirectory { private void loadAll() { mFiles = new LinkedHashSet(); mDirs = new LinkedHashMap(); - + File[] files = getDir().listFiles(); for (int i = 0; i < files.length; i++) { File file = files[i];