mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-06-21 01:25:52 +02:00
global-functions: introduce $FileExists
This commit is contained in:
parent
0e00a228d6
commit
cb984a5e52
1 changed files with 24 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
||||||
:global ExitError;
|
:global ExitError;
|
||||||
:global FetchHuge;
|
:global FetchHuge;
|
||||||
:global FetchUserAgentStr;
|
:global FetchUserAgentStr;
|
||||||
|
:global FileExists;
|
||||||
:global FileGet;
|
:global FileGet;
|
||||||
:global FormatLine;
|
:global FormatLine;
|
||||||
:global FormatMultiLines;
|
:global FormatMultiLines;
|
||||||
|
@ -530,6 +531,29 @@
|
||||||
$Resource->"architecture-name" . " " . $Caller . "/Fetch (https://rsc.eworm.de/)");
|
$Resource->"architecture-name" . " " . $Caller . "/Fetch (https://rsc.eworm.de/)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check for existence of file, optionally with type
|
||||||
|
:set FileExists do={
|
||||||
|
:local FileName [ :tostr $1 ];
|
||||||
|
:local Type [ :tostr $2 ];
|
||||||
|
|
||||||
|
:global FileGet;
|
||||||
|
|
||||||
|
:local FileVal [ $FileGet $FileName ];
|
||||||
|
:if ($FileVal = false) do={
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ :len ($FileVal->"size") ] = 0) do={
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ :len $Type ] = 0 || $FileVal->"type" = $Type) do={
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
|
||||||
# get file properties in array, or false on error
|
# get file properties in array, or false on error
|
||||||
:set FileGet do={
|
:set FileGet do={
|
||||||
:local FileName [ :tostr $1 ];
|
:local FileName [ :tostr $1 ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue