glob_resource(3)

πŸ“¦
version 0.7.1 Β· 2 versions
, in nixos 26.05

✨ glob_resource(3) ✨

okay bestie, this is the Arcan Lua API page for glob_resource, and it’s literally about searching the different datastores for resources that match a pattern. it’s giving β€œfind my stuff across namespaces” energy 🫢


πŸ’– NAME πŸ’–

glob_resource β€” search the different datastores for resources matching a pattern.


πŸŽ€ SYNOPSIS πŸŽ€

strtbl or nbio
glob_resource( string:pattern )
glob_resource( string:pattern, int:domain )
glob_resource( string:pattern, int:domain, bool:asynch )
glob_resource( string:pattern, string:namespace )
glob_resource( string:pattern, string:namespace, bool:asynch )
glob_resource( string:pattern, int:domain )

🌸 DESCRIPTION 🌸

so there are a bunch of different statically defined namespaces β€” think distinct groups where a certain resource key corresponds to a file or similar data-source. this function lets you query parts of those namespaces, and those parts are indicated by a search path, aka the pattern πŸ¦‹

by specifying a domain, you can limit the search to a specific set of namespaces. that domain can be a predefined bitmap of numeric constants, or a user-defined dynamic namespace tag. valid constants for domain (can be OR-ed) are:

  • APPL_RESOURCE
  • APPL_TEMP_RESOURCE
  • SHARED_RESOURCE
  • SYS_APPL_RESOURCE
  • SYS_FONT_RESOURCE
  • APPL_STATE_RESOURCE

the dynamic namespace tag has to match a valid name from list_namespaces, iykyk πŸ’…

if the asynch argument is provided, the function will return an nbio table as if opened with open_nonblock, or nil if there are too many open files or not enough memory. the results readable from open_nonblock will contain the terminating in order to capture file names with special characters 😭 they will also contain the namespace relative path prefix.

open_nonblock :lf_strip(true, " ") can be used to get per-read separation and β€” yep, the sentence literally ends on β€œand” in the source, so I’m leaving it exactly like that 🫠


🌈 NOTES 🌈

  1. the default domain is the compile-time defined (DEFAULT_USERMASK) which is comprised of (application- specific, application shared, application temporary) ✨
  2. due to legacy and backwards compatibility, the synchronous results contain only filename and, possibly, extension.
  3. SYS_APPL_RESOURCE is special and relates to the list of application targets that can be used as argument to system_collapse.

πŸ“ EXAMPLE πŸ“

function glob_resource0()
      local tbl = glob_resource("*");
      for i,v in ipairs(tbl) do
            print(v);
      end
end

πŸ¦‹ EXAMPLE πŸ¦‹

function glob_resource1()
      local tbl = glob_resource("*", SYS_APPL_RESOURCE);
      for i,v in ipairs(tbl) do
            print(v);
      end
end

πŸ™ˆ MISUSE πŸ™ˆ

not me passing 0 and then checking if the vibes are table-shaped 😭 this is the misuse example, bestie:

function glob_resource0()
      local tbl = glob_resource(0);
      if (type(tbl) ~= "table") then
            abort();
      end
end

πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’‹ β€” this page comes from the resource source, October 2026 version, and it’s literally iconic. glob_resource(3) out, periodt πŸ’…

πŸ“¦ where this page comes from