mirror of
https://github.com/sasjs/core.git
synced 2026-01-11 02:50:06 +00:00
fix: enabling binary file support in mp_unzip
This commit is contained in:
@@ -31,18 +31,18 @@
|
|||||||
,outdir=%sysfunc(pathname(work))
|
,outdir=%sysfunc(pathname(work))
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%local fname1 fname2 fname3;
|
%local f1 f2 f3;
|
||||||
%let fname1=%mf_getuniquefileref();
|
%let f1=%mf_getuniquefileref();
|
||||||
%let fname2=%mf_getuniquefileref();
|
%let f2=%mf_getuniquefileref();
|
||||||
%let fname3=%mf_getuniquefileref();
|
%let f3=%mf_getuniquefileref();
|
||||||
|
|
||||||
/* Macro variable &datazip would be read from the file */
|
/* Macro variable &datazip would be read from the file */
|
||||||
filename &fname1 ZIP &ziploc;
|
filename &f1 ZIP &ziploc;
|
||||||
|
|
||||||
/* Read the "members" (files) from the ZIP file */
|
/* Read the "members" (files) from the ZIP file */
|
||||||
data _data_(keep=memname isFolder);
|
data _data_(keep=memname isFolder);
|
||||||
length memname $200 isFolder 8;
|
length memname $200 isFolder 8;
|
||||||
fid=dopen("&fname1");
|
fid=dopen("&f1");
|
||||||
if fid=0 then stop;
|
if fid=0 then stop;
|
||||||
memcount=dnum(fid);
|
memcount=dnum(fid);
|
||||||
do i=1 to memcount;
|
do i=1 to memcount;
|
||||||
@@ -53,16 +53,21 @@ data _data_(keep=memname isFolder);
|
|||||||
end;
|
end;
|
||||||
rc=dclose(fid);
|
rc=dclose(fid);
|
||||||
run;
|
run;
|
||||||
filename &fname1 clear;
|
filename &f1 clear;
|
||||||
|
|
||||||
/* loop through each entry and either create the subfolder or extract member */
|
/* loop through each entry and either create the subfolder or extract member */
|
||||||
|
%mf_mkdir(&outdir)
|
||||||
data _null_;
|
data _null_;
|
||||||
set &syslast;
|
set &syslast;
|
||||||
if isFolder then call execute('%mf_mkdir(&outdir/'!!memname!!')');
|
if isFolder then call execute('%mf_mkdir(&outdir/'!!memname!!')');
|
||||||
else call execute('filename &fname2 zip &ziploc member='
|
else do;
|
||||||
!!quote(trim(memname))!!';filename &fname3 "&outdir/'
|
call execute(
|
||||||
!!trim(memname)!!'" recfm=n;data _null_; rc=fcopy("&fname2","&fname3");run;'
|
cats('filename &f2 zip &ziploc member="',memname,'" recfm=n;')
|
||||||
!!'filename &fname2 clear; filename &fname3 clear;');
|
);
|
||||||
|
call execute('filename &f3 "&outdir/'!!trim(memname)!!'" recfm=n;');
|
||||||
|
call execute('data _null_; rc=fcopy("&f2","&f3");run;');
|
||||||
|
call execute('filename &f2 clear; filename &f3 clear;');
|
||||||
|
end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%mend mp_unzip;
|
%mend mp_unzip;
|
||||||
Reference in New Issue
Block a user