summaryrefslogtreecommitdiff
path: root/funzip.f90
blob: dc71e84a1cc07420bd63df66e70963530e915ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
program funzip
use m_unzip
implicit none

    character(len=512)::archive, dir
    logical::success, file_exists
    
    success = .false.
    
    if(command_argument_count() < 1 .or. command_argument_count() > 2) then
    
        call get_command_argument(0, archive)
        Print *, "Usage: "//trim(archive)//" <zip file> [<destination directory>]"
    
    else
    
        call get_command_argument(1, archive)
        if(command_argument_count() == 2) then
            call get_command_argument(2, dir)
        else
            dir = "."
        end if
        
        inquire(file=trim(archive), exist=file_exists)
        if(.not. file_exists) then
            Print *, "Could not locate '"//trim(archive)//"'"
        end if
        
        if(unzip(trim(archive), trim(dir), indexed='/tmp/zip.lst')) then
        
            Print *, "Successfully extracted '"//trim(archive)//"'"
            
        end if
        
    end if
    
end program funzip