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