From 56ee1056d10d3804a8bff83eadcd44251a5cecef 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 759b2744..d2cc2abc 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,20 @@ $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; + :do { + :set FileVal [ /file/get $FileName ]; + } on-error={ + :return false; + } + + :return $FileVal; +} + # format a line for output :set FormatLine do={ :local Key [ :tostr $1 ];