Skip to content
Snippets Groups Projects
Commit db9f45a5 authored by blackoverlord's avatar blackoverlord
Browse files

exposed some methods for testing

parent 31d3aa33
No related branches found
No related tags found
No related merge requests found
@echo %cd%
@pause
\ No newline at end of file
@echo off
echo Current file: %0
echo Current directory: %cd%
if not "%*" == "" (
echo Command line: %*
)
pause
\ No newline at end of file
......@@ -37,6 +37,16 @@ public class ByteReader extends InputStream {
le = !le;
return this;
}
public ByteReader setLittleEndian() {
le = true;
return this;
}
public ByteReader setBigEndian() {
le = false;
return this;
}
public boolean seek(int n) throws IOException {
if (n <= 0) return false;
......
......@@ -38,6 +38,16 @@ public class ByteWriter extends OutputStream {
return this;
}
public ByteWriter setLittleEndian() {
le = true;
return this;
}
public ByteWriter setBigEndian() {
le = false;
return this;
}
@Override
public void close() throws IOException
{
......
......@@ -84,6 +84,12 @@ public class ShellLink {
parse(reader);
}
}
public ShellLink(ByteReader reader) throws IOException, ShellLinkException {
try (reader) {
parse(reader);
}
}
private void parse(ByteReader data) throws ShellLinkException, IOException {
header = new ShellLinkHeader(data);
......@@ -119,10 +125,15 @@ public class ShellLink {
}
}
}
public void serialize(OutputStream out) throws IOException {
var bw = new ByteWriter(out);
serialize(bw);
out.close();
}
public void serialize(ByteWriter bw) throws IOException {
LinkFlags lf = header.getLinkFlags();
ByteWriter bw = new ByteWriter(out);
header.serialize(bw);
if (lf.hasLinkTargetIDList())
idlist.serialize(bw);
......@@ -144,7 +155,6 @@ public class ShellLink {
i.serialize(bw);
bw.write4bytes(0);
out.close();
}
public ShellLinkHeader getHeader() { return header; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment