mirror of
https://github.com/revanced/smali.git
synced 2025-05-14 21:27:06 +02:00
Track and seek to the current position in RandomAccessFileOutputStream
This commit is contained in:
parent
b85cfe5cc8
commit
3d0419c963
@ -233,7 +233,7 @@ public class DexFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static DexWriter outputAt(RandomAccessFile raf, int filePosition) throws IOException {
|
private static DexWriter outputAt(RandomAccessFile raf, int filePosition) throws IOException {
|
||||||
return new DexWriter(new RandomAccessFileOutputStream(raf), filePosition);
|
return new DexWriter(new RandomAccessFileOutputStream(raf, filePosition), filePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException {
|
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException {
|
||||||
|
@ -37,21 +37,29 @@ import java.io.OutputStream;
|
|||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
|
|
||||||
public class RandomAccessFileOutputStream extends OutputStream {
|
public class RandomAccessFileOutputStream extends OutputStream {
|
||||||
|
private int filePosition;
|
||||||
@Nonnull private final RandomAccessFile raf;
|
@Nonnull private final RandomAccessFile raf;
|
||||||
|
|
||||||
public RandomAccessFileOutputStream(@Nonnull RandomAccessFile raf) {
|
public RandomAccessFileOutputStream(@Nonnull RandomAccessFile raf, int startFilePosition) {
|
||||||
|
this.filePosition = startFilePosition;
|
||||||
this.raf = raf;
|
this.raf = raf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void write(int b) throws IOException {
|
@Override public void write(int b) throws IOException {
|
||||||
|
raf.seek(filePosition);
|
||||||
|
filePosition++;
|
||||||
raf.write(b);
|
raf.write(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void write(byte[] b) throws IOException {
|
@Override public void write(byte[] b) throws IOException {
|
||||||
|
raf.seek(filePosition);
|
||||||
|
filePosition += b.length;
|
||||||
raf.write(b);
|
raf.write(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void write(byte[] b, int off, int len) throws IOException {
|
@Override public void write(byte[] b, int off, int len) throws IOException {
|
||||||
|
raf.seek(filePosition);
|
||||||
|
filePosition += len;
|
||||||
raf.write(b, off, len);
|
raf.write(b, off, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user