mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-31 15:19:28 +02:00
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 RandomDelay;
|
||||
:global RequiredRouterOS;
|
||||
:global RmDir;
|
||||
:global RmFile;
|
||||
:global ScriptFromTerminal;
|
||||
:global ScriptInstallUpdate;
|
||||
|
@ -1005,6 +1006,26 @@
|
|||
: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
|
||||
:set RmFile do={
|
||||
:local FileName [ :tostr $1 ];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue