Skip to content

Commit

Permalink
Close files after merging
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Apr 23, 2024
1 parent 7d2fff8 commit f538e96
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/main/java/com/reandroid/apkeditor/merge/Merger.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.reandroid.arsc.chunk.xml.ResXmlElement;
import com.reandroid.arsc.value.Entry;
import com.reandroid.arsc.value.ValueType;
import com.reandroid.utils.StringsUtil;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -96,28 +95,13 @@ public void run() throws IOException {
logMessage("Writing apk ...");
mergedModule.writeApk(options.outputFile);
mergedModule.close();
bundle.close();
if(extracted){
Util.deleteDir(dir);
confirmDirectoryDeleted(dir);
Util.deleteDir(dir);
confirmDirectoryDeleted(dir);
dir.deleteOnExit();
}
logMessage("Saved to: " + options.outputFile);
}
private void confirmDirectoryDeleted(File dir){
if(!dir.exists()){
logMessage("Directory not exist: " + dir.getAbsolutePath());
return;
}
logMessage("Directory exists: " + dir.getAbsolutePath());
File[] files = dir.listFiles();
if(files == null){
logMessage("files == null");
return;
}
String message = "files.length = " + files.length + StringsUtil.join(files, "\n");
logMessage(message);
}
private File extractFile(File file) throws IOException {
File tmp = toTmpDir(file);
logMessage("Extracting to: " + tmp);
Expand Down

0 comments on commit f538e96

Please sign in to comment.