From b70e6e79843f7c1bbc0031dd74cdf8005d3da4ff Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 21:53:23 +0200 Subject: [PATCH] global-functions: introduce $FileGet --- global-functions.rsc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 759b274..3a2d20a 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -38,6 +38,7 @@ :global ExitError; :global FetchHuge; :global FetchUserAgentStr; +:global FileGet; :global FormatLine; :global FormatMultiLines; :global GetMacVendor; @@ -529,6 +530,18 @@ $Resource->"architecture-name" . " " . $Caller . "/Fetch (https://rsc.eworm.de/)"); } +# get file properties in array, or false on error +:set FileGet do={ + :local FileName [ :tostr $1 ]; + + :local FileVal false; + :do { + :set FileVal [ /file/get $FileName ]; + } on-error={ } + + :return $FileVal; +} + # format a line for output :set FormatLine do={ :local Key [ :tostr $1 ];