Refactor ExtFile to brut.j.dir

- move to using Paths when possible
 - adapt calls to FileDirectory to leverage Paths
This commit is contained in:
Connor Tumbleson 2016-12-25 07:57:41 -05:00
parent 166bf508e2
commit 891d0d39e0
17 changed files with 28 additions and 32 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<String> files = fileDirectory.getFiles(true);
for (String filename : files) {

View File

@ -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;

View File

@ -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;

View File

@ -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.*;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<String>();
mDirs = new LinkedHashMap<String, AbstractDirectory>();
File[] files = getDir().listFiles();
for (int i = 0; i < files.length; i++) {
File file = files[i];