Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding new mf_deletefile macro (and test)
Also, update to mm_spkexport macro
- Loading branch information
munja
committed
Mar 11, 2022
1 parent
76207c4
commit 8ffd063
Showing
4 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
@file | ||
@brief Deletes a physical file, if it exists | ||
@details Usage: | ||
%mf_writefile(&sasjswork/myfile.txt,l1=some content) | ||
%mf_deletefile(&sasjswork/myfile.txt) | ||
%mf_deletefile(&sasjswork/myfile.txt) | ||
@param filepath Full path to the target file | ||
@returns The return code from the fdelete() invocation | ||
<h4> Related Macros </h4> | ||
@li mf_deletefile.test.sas | ||
@li mf_writefile.sas | ||
@version 9.2 | ||
@author Allan Bowe | ||
**/ | ||
|
||
%macro mf_deletefile(file | ||
)/*/STORE SOURCE*/; | ||
%local rc fref; | ||
%let rc= %sysfunc(filename(fref,&file)); | ||
%if %sysfunc(fdelete(&fref)) ne 0 %then %put %sysfunc(sysmsg()); | ||
%let rc= %sysfunc(filename(fref)); | ||
%mend mf_deletefile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
@file | ||
@brief Testing mf_deletefile.sas macro | ||
<h4> SAS Macros </h4> | ||
@li mf_deletefile.sas | ||
@li mp_assert.sas | ||
@li mp_assertscope.sas | ||
**/ | ||
|
||
%let test1file=&sasjswork/myfile1.txt; | ||
|
||
%mf_writefile(&test1file,l1=some content) | ||
|
||
%mp_assert( | ||
iftrue=(%sysfunc(fileexist(&test1file))=1), | ||
desc=Check &test1file exists | ||
) | ||
|
||
%mp_assertscope(SNAPSHOT) | ||
%mf_deletefile(&test1file) | ||
%mp_assertscope(COMPARE) | ||
|
||
%mp_assert( | ||
iftrue=(%sysfunc(fileexist(&test1file))=0), | ||
desc=Check &test1file no longer exists | ||
) |