xmlrdf/commit

ADDED: Make load_xml_as_rdf/2 look for .gz compressed input

authorJan Wielemaker
Mon Mar 12 15:05:20 2012 +0100
committerJan Wielemaker
Mon Mar 12 15:05:20 2012 +0100
commit3e95baa137fac69d3ae9fd094077aeb7e696a281
tree458b9bd70ddbf92281b97e809749da72711c873f
parent6a7052dae95a187858d9e551baa563541697b798
Diff style: patch stat
diff --git a/lib/xmlrdf/xmlrdf.pl b/lib/xmlrdf/xmlrdf.pl
index 076b9d8..a400757 100644
--- a/lib/xmlrdf/xmlrdf.pl
+++ b/lib/xmlrdf/xmlrdf.pl
@@ -148,8 +148,7 @@ open_input(stream(In), In, true) :- !.
 open_input(URL, In, Cleanup) :-
 	atom(URL),
 	uri_file_name(URL, File), !,
-	open(File, read, In, [type(binary)]),
-	Cleanup = close(In).
+	open_file(File, In, Cleanup).
 open_input(URL, In, Cleanup) :-
 	atom(URL),
 	uri_components(URL, Data),
@@ -158,10 +157,17 @@ open_input(URL, In, Cleanup) :-
 	set_stream(In, file_name(URL)),
 	Cleanup = close(In).
 open_input(Spec, In, Cleanup) :-
-	absolute_file_name(Spec, Path, [access(read)]),
-	open(Path, read, In, [type(binary)]),
+	absolute_file_name(Spec, Path, [extensions([gz,'']), access(read)]),
+	open_file(Path, In, Cleanup).
+
+open_file(Path, In, Cleanup) :-
+	(   file_name_extension(_, gz, Path)
+	->  gzopen(Path, read, In, [type(binary)])
+	;   open(Path, read, In, [type(binary)])
+	),
 	Cleanup = close(In).
 
+
 %%	process(+Stream, +Options)
 
 process(Stream, Options) :-