From b2c2b9c3e3fcb778990734f8065e6ae281d35edc Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Tue, 29 Oct 2024 14:51:50 +0000 Subject: [PATCH] Fix issue if 'labels' part of filename --- src/loci/formats/in/ZarrReader.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index b4dcb00..6c2e4f6 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -1127,6 +1127,7 @@ private Double getDouble(Map src, String key) { public String[] getUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); String zarrRootPath = currentId.substring(0, currentId.indexOf(".zarr") + 5); + int rootPathLength = zarrRootPath.length(); ArrayList usedFiles = new ArrayList(); reloadOptionsFile(zarrRootPath); @@ -1134,11 +1135,11 @@ public String[] getUsedFiles(boolean noPixels) { boolean includeLabels = includeLabels(); try (Stream paths = Files.walk(Paths.get(zarrRootPath), FileVisitOption.FOLLOW_LINKS)) { paths.filter(Files::isRegularFile) - .forEach(path -> {if ((!skipPixels && includeLabels) || - (!skipPixels && !includeLabels && !path.toString().toLowerCase().contains("labels")) || + .forEach(path -> { if ((!skipPixels && includeLabels) || + (!skipPixels && !includeLabels && !(path.toString().toLowerCase().indexOf("labels")>=rootPathLength)) || (skipPixels && includeLabels && (path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml"))) || - (skipPixels && !includeLabels && !path.toString().toLowerCase().contains("labels") &&(path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml")))) - usedFiles.add(path.toFile().getAbsolutePath()); + (skipPixels && !includeLabels && !(path.toString().toLowerCase().indexOf("labels")>=rootPathLength) &&(path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml")))) + usedFiles.add(path.toFile().getAbsolutePath()); }); } catch (IOException e) { e.printStackTrace();