auto-sync
This commit is contained in:
parent
7dacfd06c0
commit
17bcd7c50b
|
@ -81,4 +81,10 @@ public class ConfigurationImage {
|
||||||
byte[] copy = content.clone();
|
byte[] copy = content.clone();
|
||||||
return new ConfigurationImage(copy);
|
return new ConfigurationImage(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getRange(Integer first, int size) {
|
||||||
|
byte[] r = new byte[size];
|
||||||
|
System.arraycopy(content, first, r, 0, size);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,15 @@ public class BinaryProtocol {
|
||||||
Pair<Integer, Integer> range = ConfigurationImageDiff.findDifferences(current, newVersion, offset);
|
Pair<Integer, Integer> range = ConfigurationImageDiff.findDifferences(current, newVersion, offset);
|
||||||
if (range == null)
|
if (range == null)
|
||||||
break;
|
break;
|
||||||
logger.info("Need to patch: " + range);
|
int size = range.second - range.first;
|
||||||
writeData(newVersion.getContent(), range.first, range.second - range.first, logger);
|
logger.info("Need to patch: " + range + ", size=" + size);
|
||||||
|
byte[] oldBytes = current.getRange(range.first, size);
|
||||||
|
logger.info("old " + Arrays.toString(oldBytes));
|
||||||
|
|
||||||
|
byte[] newBytes = newVersion.getRange(range.first, size);
|
||||||
|
logger.info("new " + Arrays.toString(newBytes));
|
||||||
|
|
||||||
|
writeData(newVersion.getContent(), range.first, size, logger);
|
||||||
|
|
||||||
offset = range.second;
|
offset = range.second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,7 +390,7 @@ public class ECUEditor extends AbstractFrame {
|
||||||
frame.getTable().drawTable();
|
frame.getTable().drawTable();
|
||||||
rightPanel.add(frame);
|
rightPanel.add(frame);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
;// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
frame.pack();
|
frame.pack();
|
||||||
rightPanel.repaint();
|
rightPanel.repaint();
|
||||||
|
@ -464,7 +464,7 @@ public class ECUEditor extends AbstractFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector<Rom> getImages() {
|
public Vector<Rom> getImages() {
|
||||||
Vector<Rom> images = new Vector<Rom>();
|
Vector<Rom> images = new Vector<>();
|
||||||
for (int i = 0; i < imageRoot.getChildCount(); i++) {
|
for (int i = 0; i < imageRoot.getChildCount(); i++) {
|
||||||
if(imageRoot.getChildAt(i) instanceof Rom) {
|
if(imageRoot.getChildAt(i) instanceof Rom) {
|
||||||
Rom rom = (Rom) imageRoot.getChildAt(i);
|
Rom rom = (Rom) imageRoot.getChildAt(i);
|
||||||
|
@ -515,15 +515,12 @@ public class ECUEditor extends AbstractFrame {
|
||||||
|
|
||||||
public static byte[] readFile(File inputFile) throws IOException {
|
public static byte[] readFile(File inputFile) throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
FileInputStream fis = new FileInputStream(inputFile);
|
try (FileInputStream fis = new FileInputStream(inputFile)) {
|
||||||
try {
|
|
||||||
byte[] buf = new byte[8192];
|
byte[] buf = new byte[8192];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while ((bytesRead = fis.read(buf)) != -1) {
|
while ((bytesRead = fis.read(buf)) != -1) {
|
||||||
baos.write(buf, 0, bytesRead);
|
baos.write(buf, 0, bytesRead);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
fis.close();
|
|
||||||
}
|
}
|
||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class ECUEditorToolBar extends JToolBar {
|
||||||
// refreshImage.setEnabled(true);
|
// refreshImage.setEnabled(true);
|
||||||
// closeImage.setEnabled(true);
|
// closeImage.setEnabled(true);
|
||||||
// }
|
// }
|
||||||
// revalidate();
|
revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Settings getSettings() {
|
private Settings getSettings() {
|
||||||
|
|
|
@ -187,6 +187,8 @@ public final class RomAttributeParser {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(output, 0, 4);
|
ByteBuffer bb = ByteBuffer.wrap(output, 0, 4);
|
||||||
if (endian == Settings.ENDIAN_LITTLE) {
|
if (endian == Settings.ENDIAN_LITTLE) {
|
||||||
bb.order(ByteOrder.BIG_ENDIAN);
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
|
} else {
|
||||||
|
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
}
|
}
|
||||||
bb.putFloat(input);
|
bb.putFloat(input);
|
||||||
return bb.array();
|
return bb.array();
|
||||||
|
|
Loading…
Reference in New Issue