global-functions: introduce $RmDir
This commit is contained in:
parent
4542c2b19e
commit
727495d9c4
1 changed files with 21 additions and 0 deletions
|
|
@ -63,6 +63,7 @@
|
||||||
:global ProtocolStrip;
|
:global ProtocolStrip;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
:global RequiredRouterOS;
|
:global RequiredRouterOS;
|
||||||
|
:global RmDir;
|
||||||
:global RmFile;
|
:global RmFile;
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
:global ScriptInstallUpdate;
|
:global ScriptInstallUpdate;
|
||||||
|
|
@ -1005,6 +1006,26 @@
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# remove directory
|
||||||
|
:set RmDir do={
|
||||||
|
:local DirName [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global LogPrint;
|
||||||
|
|
||||||
|
:local Dir [ /file/find where name=$DirName type=directory ];
|
||||||
|
:if ([ :len $Dir ] = 0) do={
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:do {
|
||||||
|
/file/remove $Dir;
|
||||||
|
} on-error={
|
||||||
|
$LogPrint error $0 ("Removing directory '" . $DirName . "' (" . $Dir . ") failed.");
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
# remove file
|
# remove file
|
||||||
:set RmFile do={
|
:set RmFile do={
|
||||||
:local FileName [ :tostr $1 ];
|
:local FileName [ :tostr $1 ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue