mirror of
https://github.com/Maschell/fuse-wiiu.git
synced 2024-11-24 23:36:53 +01:00
Force the offset to be align to 0x10
This commit is contained in:
parent
2c3a5332a4
commit
7f2d519427
@ -1,5 +1,6 @@
|
|||||||
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
|
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -123,11 +124,22 @@ public class FSTDataProviderContainer implements FuseContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] data = getDataProvider().readFile(entry, offset, size);
|
byte[] data;
|
||||||
|
if (offset % 16 > 0) {
|
||||||
|
// make sure the offset is aligned to 0x10;
|
||||||
|
// in worst case we read 15 additional bytes-
|
||||||
|
long newOffset = (offset / 16) * 16;
|
||||||
|
int diff = (int) (offset - newOffset);
|
||||||
|
data = getDataProvider().readFile(entry, newOffset, size + diff);
|
||||||
|
|
||||||
buf.put(0, data, 0, data.length);
|
buf.put(0, data, diff, data.length - diff);
|
||||||
|
|
||||||
return data.length;
|
return (int) (data.length > size ? size : data.length);
|
||||||
|
} else {
|
||||||
|
data = getDataProvider().readFile(entry, offset, size);
|
||||||
|
buf.put(0, data, 0, data.length);
|
||||||
|
return data.length;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return -ErrorCodes.ENOENT();
|
return -ErrorCodes.ENOENT();
|
||||||
|
Loading…
Reference in New Issue
Block a user