mirror of
https://github.com/sasjs/core.git
synced 2026-01-09 10:20:06 +00:00
Merge pull request #195 from sasjs/issue194
fix: supporting empty dirs in mp_dirlist. Test updated.
This commit is contained in:
16
all.sas
16
all.sas
@@ -4214,6 +4214,13 @@ data &out_ds(compress=no
|
|||||||
%end;
|
%end;
|
||||||
if rc = 0 then do;
|
if rc = 0 then do;
|
||||||
did = dopen(fref);
|
did = dopen(fref);
|
||||||
|
if did=0 then do;
|
||||||
|
putlog "NOTE: This directory is empty, or does not exist - &path";
|
||||||
|
msg=sysmsg();
|
||||||
|
put msg;
|
||||||
|
put _all_;
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
||||||
numopts=doptnum(did);
|
numopts=doptnum(did);
|
||||||
do i=1 to numopts;
|
do i=1 to numopts;
|
||||||
@@ -4221,12 +4228,6 @@ data &out_ds(compress=no
|
|||||||
if foption=:'Directory' then i=numopts;
|
if foption=:'Directory' then i=numopts;
|
||||||
end;
|
end;
|
||||||
directory=dinfo(did,foption);
|
directory=dinfo(did,foption);
|
||||||
if did=0 then do;
|
|
||||||
putlog "NOTE: This directory is empty - " directory;
|
|
||||||
msg=sysmsg();
|
|
||||||
put _all_;
|
|
||||||
stop;
|
|
||||||
end;
|
|
||||||
rc = filename(fref);
|
rc = filename(fref);
|
||||||
end;
|
end;
|
||||||
else do;
|
else do;
|
||||||
@@ -4362,7 +4363,8 @@ run;
|
|||||||
proc sql;
|
proc sql;
|
||||||
drop table &out_ds;
|
drop table &out_ds;
|
||||||
|
|
||||||
%mend mp_dirlist;/**
|
%mend mp_dirlist;
|
||||||
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Creates a dataset containing distinct _formatted_ values
|
@brief Creates a dataset containing distinct _formatted_ values
|
||||||
@details If no format is supplied, then the original value is used instead.
|
@details If no format is supplied, then the original value is used instead.
|
||||||
|
|||||||
@@ -94,6 +94,13 @@ data &out_ds(compress=no
|
|||||||
%end;
|
%end;
|
||||||
if rc = 0 then do;
|
if rc = 0 then do;
|
||||||
did = dopen(fref);
|
did = dopen(fref);
|
||||||
|
if did=0 then do;
|
||||||
|
putlog "NOTE: This directory is empty, or does not exist - &path";
|
||||||
|
msg=sysmsg();
|
||||||
|
put msg;
|
||||||
|
put _all_;
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
||||||
numopts=doptnum(did);
|
numopts=doptnum(did);
|
||||||
do i=1 to numopts;
|
do i=1 to numopts;
|
||||||
@@ -101,12 +108,6 @@ data &out_ds(compress=no
|
|||||||
if foption=:'Directory' then i=numopts;
|
if foption=:'Directory' then i=numopts;
|
||||||
end;
|
end;
|
||||||
directory=dinfo(did,foption);
|
directory=dinfo(did,foption);
|
||||||
if did=0 then do;
|
|
||||||
putlog "NOTE: This directory is empty - " directory;
|
|
||||||
msg=sysmsg();
|
|
||||||
put _all_;
|
|
||||||
stop;
|
|
||||||
end;
|
|
||||||
rc = filename(fref);
|
rc = filename(fref);
|
||||||
end;
|
end;
|
||||||
else do;
|
else do;
|
||||||
@@ -242,4 +243,4 @@ run;
|
|||||||
proc sql;
|
proc sql;
|
||||||
drop table &out_ds;
|
drop table &out_ds;
|
||||||
|
|
||||||
%mend mp_dirlist;
|
%mend mp_dirlist;
|
||||||
|
|||||||
@@ -47,4 +47,18 @@ run;
|
|||||||
iftrue=(%mf_nobs(work.mytable3)=2),
|
iftrue=(%mf_nobs(work.mytable3)=2),
|
||||||
desc=Top level returned,
|
desc=Top level returned,
|
||||||
outds=work.test_results
|
outds=work.test_results
|
||||||
)
|
)
|
||||||
|
|
||||||
|
%mp_dirlist(path=&root/b, outds=work.myTable4)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(work.mytable4)=0),
|
||||||
|
desc=Empty table for empty directory,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_dirlist(path=&root/notexisting, outds=work.myTable5)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_nobs(work.mytable5)=0),
|
||||||
|
desc=Empty table for non-existing directory,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user