summaryrefslogtreecommitdiff
path: root/unzip_wrap.f90
diff options
context:
space:
mode:
Diffstat (limited to 'unzip_wrap.f90')
-rw-r--r--unzip_wrap.f9048
1 files changed, 48 insertions, 0 deletions
diff --git a/unzip_wrap.f90 b/unzip_wrap.f90
new file mode 100644
index 0000000..c29dfd7
--- /dev/null
+++ b/unzip_wrap.f90
@@ -0,0 +1,48 @@
+module m_unzip
+implicit none
+
+ interface
+ function unzip_file_c(archive, directory, indexed) bind(c, name="unzip_file")
+ use iso_c_binding
+ integer(kind=c_int)::unzip_file_c
+ type(c_ptr), value::archive, directory, indexed
+ end function unzip_file_c
+ end interface
+
+contains
+
+ function unzip(archive, directory, indexed)
+ use iso_c_binding
+ implicit none
+
+ logical::unzip
+ character(*), intent(in)::archive, directory
+ character(*), intent(in), optional::indexed
+
+ character(kind=c_char, len=:), pointer::c_arc, c_dir, c_index
+
+ allocate(character(len=(len_trim(archive)+1)) :: c_arc)
+ c_arc = trim(archive)//c_null_char
+ allocate(character(len=(len_trim(directory)+1)) :: c_dir)
+ c_dir = trim(directory)//c_null_char
+
+ if(present(indexed)) then
+ allocate(character(len=(len_trim(indexed)+1)) :: c_index)
+ c_index = trim(indexed)//c_null_char
+ else
+ c_index => NULL()
+ end if
+
+ !if(associated(c_index)) then
+
+ unzip = (unzip_file_c(c_loc(c_arc), c_loc(c_dir), c_loc(c_index)) == 1)
+
+ deallocate(c_arc)
+ deallocate(c_dir)
+ if(associated(c_index)) then
+ deallocate(c_index)
+ end if
+
+ end function unzip
+
+end module m_unzip \ No newline at end of file