mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-04 18:12:54 +01:00
dir: add methods getSize() and getCompressedSize()
This commit is contained in:
parent
eecfc18c82
commit
76bf6ff0c8
@ -47,6 +47,10 @@ public interface Directory {
|
||||
public void copyToDir(File out, String fileName)
|
||||
throws DirectoryException;
|
||||
|
||||
public long getSize(String fileName)
|
||||
throws DirectoryException;
|
||||
public long getCompressedSize(String fileName)
|
||||
throws DirectoryException;
|
||||
public int getCompressionLevel(String fileName)
|
||||
throws DirectoryException;
|
||||
|
||||
|
@ -40,6 +40,22 @@ public class FileDirectory extends AbstractDirectory {
|
||||
mDir = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize(String fileName)
|
||||
throws DirectoryException {
|
||||
File file = new File(generatePath(fileName));
|
||||
if (! file.isFile()) {
|
||||
throw new DirectoryException("file must be a file: " + file);
|
||||
}
|
||||
return file.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCompressedSize(String fileName)
|
||||
throws DirectoryException {
|
||||
return getSize(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractDirectory createDirLocal(String name) throws DirectoryException {
|
||||
File dir = new File(generatePath(name));
|
||||
|
@ -100,14 +100,34 @@ public class ZipRODirectory extends AbstractDirectory {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = getZipFileEntry(fileName);
|
||||
return entry.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCompressedSize(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = getZipFileEntry(fileName);
|
||||
return entry.getCompressedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompressionLevel(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = mZipFile.getEntry(fileName);
|
||||
ZipEntry entry = getZipFileEntry(fileName);
|
||||
return entry.getMethod();
|
||||
}
|
||||
|
||||
private ZipEntry getZipFileEntry(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = mZipFile.getEntry(fileName);
|
||||
if (entry == null) {
|
||||
throw new PathNotExist("Entry not found: " + fileName);
|
||||
}
|
||||
return entry.getMethod();
|
||||
return entry;
|
||||
}
|
||||
|
||||
private void loadAll() {
|
||||
|
Loading…
Reference in New Issue
Block a user