Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of URLs in Harmony datasets #4

Merged
merged 2 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion components/formats-common/src/loci/common/StreamHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ public void seek(long pos) throws IOException {
fp = pos;

if (diff < 0) {
// resetStream sets the fp to 0
resetStream();
diff = fp;
diff = pos;
fp = pos;
}
int skipped = stream.skipBytes((int) diff);
while (skipped < diff) {
int n = stream.skipBytes((int) (diff - skipped));
if (n == 0) break;
skipped += n;
}
markManager();
}

/* @see IRandomAccess.write(ByteBuffer) */
Expand Down
21 changes: 15 additions & 6 deletions components/formats-gpl/src/loci/formats/in/HarmonyReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,13 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
if (reader == null) {
reader = new MinimalTiffReader();
}
reader.setId(p.filename);
reader.openBytes(0, buf, x, y, w, h);
reader.close();
try {
reader.setId(p.filename);
reader.openBytes(0, buf, x, y, w, h);
}
finally {
reader.close();
}
}
else {
LOGGER.debug("Could not find file {}", p.filename);
Expand Down Expand Up @@ -662,9 +666,14 @@ else if ("MeasurementStartTime".equals(currentName)) {
}
else if (activePlane != null && "Image".equals(parentName)) {
if ("URL".equals(currentName)) {
Location parent =
new Location(currentId).getAbsoluteFile().getParentFile();
activePlane.filename = new Location(parent, value).getAbsolutePath();
if (value.startsWith("http")) {
activePlane.filename = value;
}
else {
Location parent =
new Location(currentId).getAbsoluteFile().getParentFile();
activePlane.filename = new Location(parent, value).getAbsolutePath();
}
}
else if ("Row".equals(currentName)) {
activePlane.row = Integer.parseInt(value) - 1;
Expand Down