diff --git a/src/main/java/net/preibisch/mvrecon/fiji/plugin/queryXML/GenericLoadParseQueryXML.java b/src/main/java/net/preibisch/mvrecon/fiji/plugin/queryXML/GenericLoadParseQueryXML.java index 0d5db7c7..a5ef35f3 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/plugin/queryXML/GenericLoadParseQueryXML.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/plugin/queryXML/GenericLoadParseQueryXML.java @@ -30,8 +30,6 @@ import java.awt.event.TextEvent; import java.awt.event.TextListener; import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Paths; import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; @@ -58,7 +56,6 @@ import mpicbg.spim.data.sequence.Angle; import mpicbg.spim.data.sequence.Channel; import mpicbg.spim.data.sequence.Illumination; -import mpicbg.spim.data.sequence.ImgLoader; import mpicbg.spim.data.sequence.Tile; import mpicbg.spim.data.sequence.TimePoint; import net.preibisch.legacy.io.IOFunctions; @@ -715,7 +712,7 @@ protected boolean tryParsing( final URI xmlURI, final boolean parseAllTypes ) { this.data = parseXML( xmlURI ); - this.xmlFileName = Paths.get(xmlURI.getPath()).getFileName().toString(); + this.xmlFileName = URITools.getFileName(xmlURI); //Paths.get(xmlURI.getPath()).getFileName().toString(); // which attributes this.attributes = getAttributes( data, comparator ); diff --git a/src/main/java/util/URITools.java b/src/main/java/util/URITools.java index fd2d8647..ea5251b3 100644 --- a/src/main/java/util/URITools.java +++ b/src/main/java/util/URITools.java @@ -35,7 +35,6 @@ import java.io.PrintWriter; import java.net.URI; import java.net.URISyntaxException; -import java.nio.file.Paths; import java.util.Date; import java.util.regex.Pattern; @@ -671,7 +670,19 @@ public static String fromURI( final URI uri ) public static String getFileName( final URI uri ) { - return Paths.get( uri.getPath() ).getFileName().toString(); + int l1 = uri.toString().length(); + int l2 = l1; + try + { + l2 = getParentURI( uri ).toString().length(); + } + catch (SpimDataIOException e) + { + IOFunctions.println( "Error getting the parent URI for '" + uri + "' in order to extract the filename. Returning entire URI as filename, even though this is most likely wrong: " + e ); + e.printStackTrace(); + } + + return uri.toString().substring( l2, l1 ); } public static String appendName( final URI uri, final String name ) @@ -744,10 +755,12 @@ public static void minimalExampleTobiS3GS() throws URISyntaxException, IOExcepti public static void main( String[] args ) throws SpimDataException, IOException, URISyntaxException { - URI uri1 = URITools.toURI( "s3://aind-open-data/exaSPIM_708373_2024-04-02_19-49-38/SPIM.ome.zarr" ); + URI uri1 = URITools.toURI( "s3://aind-open-data/exaSPIM_708373_2024-04-02_19-49-38/SPIM.ome.zarr/" ); System.out.println( uri1.getHost() ); System.out.println( uri1.getPath() ); + System.out.println( getFileName( uri1 ) ); + System.exit( 0 ); minimalExampleTobiS3GS();