@@ -8,7 +8,6 @@ module stdlib_io_zip
8
8
9
9
character (* ), parameter :: default_unzip_dir = temp_dir// ' /unzipped_files'
10
10
character (* ), parameter :: zip_contents = default_unzip_dir// ' /zip_contents.txt'
11
- character (* ), parameter :: default_zip_dir = temp_dir// ' .'
12
11
13
12
contains
14
13
@@ -72,14 +71,20 @@ subroutine unzip(filename, outputdir, stat, msg)
72
71
if (present (stat)) stat = 0
73
72
run_stat = 0
74
73
75
- call run(' rm -rf ' // default_unzip_dir, run_stat)
74
+ if (.not. exists(filename)) then
75
+ if (present (stat)) stat = 1
76
+ if (present (msg)) msg = " File '" // filename// " ' does not exist."
77
+ return
78
+ end if
79
+
80
+ call run(' rm -rf ' // output_dir, run_stat)
76
81
if (run_stat /= 0 ) then
77
82
if (present (stat)) stat = run_stat
78
- if (present (msg)) msg = " Error removing folder '" // default_unzip_dir // " '."
83
+ if (present (msg)) msg = " Error removing folder '" // output_dir // " '."
79
84
return
80
85
end if
81
86
82
- if (.not. exists(temp_dir)) then
87
+ if (.not. present (outputdir) .and. .not. exists(temp_dir)) then
83
88
call run(' mkdir ' // temp_dir, run_stat)
84
89
if (run_stat /= 0 ) then
85
90
if (present (stat)) stat = run_stat
@@ -88,8 +93,6 @@ subroutine unzip(filename, outputdir, stat, msg)
88
93
end if
89
94
end if
90
95
91
- print * , ' hellohello'
92
- call execute_command_line(' pwd' )
93
96
call run(' unzip -q ' // filename// ' -d ' // output_dir, run_stat)
94
97
if (run_stat /= 0 ) then
95
98
if (present (stat)) stat = run_stat
0 commit comments