Skip to content

Commit

Permalink
[MERGE] Fix file permission to read write tmp files
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Aug 27, 2024
1 parent 9a6e573 commit 9ca0194
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/reandroid/apkeditor/merge/Merger.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
Expand Down Expand Up @@ -104,6 +105,7 @@ private File extractFile(File file) throws IOException {
}
tmp.deleteOnExit();
ArchiveFile archive = new ArchiveFile(file);
fixFilePermissions(archive);
Predicate <ArchiveEntry> filter = archiveEntry -> archiveEntry.getName().endsWith(".apk");
int count = archive.extractAll(tmp, filter, this);
archive.close();
Expand All @@ -112,6 +114,15 @@ private File extractFile(File file) throws IOException {
}
return tmp;
}
private void fixFilePermissions(ArchiveFile archive) {
int rw_all = 438; // equivalent to chmod 666
Iterator<ArchiveEntry> iterator = archive.iterator();
while (iterator.hasNext()) {
ArchiveEntry entry = iterator.next();
entry.getCentralEntryHeader()
.getFilePermissions().permissions(rw_all);
}
}
private File toTmpDir(File file){
String name = file.getName();
name = HexUtil.toHex8("tmp_", name.hashCode());
Expand Down

0 comments on commit 9ca0194

Please sign in to comment.