erl_prim_loader(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– erl_prim_loader β€” the low-level Erlang loader πŸ’–

okay bestie, welcome to erl_prim_loader, aka the lowkey Erlang loader from the erts manual. This is the module that loads all Erlang modules into the system β€” yes, all of them. The start script also gets fetched with this same low-level loader. She does it all, no cap. πŸ‘‘


✨ DESCRIPTION ✨

erl_prim_loader knows about the environment and how to fetch modules. That's literally her whole thing.

The command-line flag -loader Loader is how you pick which method erl_prim_loader uses. The Erlang runtime system supports two Loader methods: efile and inet. Two options, two vibes. 🌸

πŸŽ€ Command-Line Flags πŸŽ€

The erl_prim_loader module interprets these command-line flags, bestie β€” write them down, they matter:

  • -loader Loader β€” says the name of the loader that erl_prim_loader uses. Loader can be either efile (uses the local file system) or inet (loads using the boot_server on another Erlang node). And if you just... omit the -loader flag entirely? It defaults to efile. periodt.
  • -loader_debug β€” makes the efile loader spill some debug information while it's handling files, like the reason for failures. it's giving detective energy πŸ”
  • -hosts Hosts β€” says which other Erlang nodes the inet loader is allowed to use. This flag is mandatory if the -loader inet flag is present. On each host there has to be an Erlang node running the erl_boot_server, and that server handles the load requests. Hosts is a list of IP addresses β€” and heads up, hostnames are not acceptable. it's IPs only, sorry bestie 😭
  • -setcookie Cookie β€” sets the cookie of the Erlang runtime system. This flag is mandatory if the -loader inet flag is present.

πŸ‘€ See Also

init, erl_boot_server


πŸ’… FUNCTIONS πŸ’…

🌈 get_file(Filename) -> {ok, Bin, FullName} | error

when
    Filename :: atom() | string(),
    Bin :: binary(),
    FullName :: string().
⚠️ Using this function is deprecated in favor of read_file/1. she's iconic but she's retired, ok?

Fetches a file using the low-level loader. Filename is either an absolute filename or just the name of the file, for example, "lists.beam". If an internal path is set to the loader, that path gets used to find the file. FullName is the complete name of the fetched file, and Bin is the contents of the file as a binary.

Filename can also be a file inside an archive, for example, $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia.beam. For the tea on archive files, go see code.


🌟 get_path() -> {ok, Path}

when Path :: [Dir :: string()].
⚠️ Using this function is deprecated in favor of code:get_path/0.

Gets the path set in the loader. The path is set by the init process according to the information found in the start script.


πŸ¦‹ list_dir(Dir) -> {ok, Filenames} | error

when
    Dir :: string(),
    Filenames :: [Filename :: string()].

Lists all the files in a directory.

Returns {ok, Filenames} if successful, otherwise error. Filenames is a list of the names of all the files in the directory β€” and ngl, the names are not sorted. no alphabetical order, no vibes, just whatever.

Dir can also be a directory inside an archive, for example, $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin. For information about archive files, see code.


πŸŽ€ read_file(Filename) -> {ok, Bin} | error

when Filename :: string(), Bin :: binary().

Reads a file using the low-level loader. slay.

Returns {ok, Bin} if successful, otherwise error. Bin is the contents of the file as a binary.

Filename can also be a file inside an archive, for example, $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia.beam. For information about archive files, see code.


πŸ’œ read_file_info(Filename) -> {ok, FileInfo} | error

when
    Filename :: string(),
    FileInfo :: file:file_info().

Retrieves information about a file. nosy but make it legal πŸ’…

Returns {ok, FileInfo} if successful, otherwise error. FileInfo is a record file_info, defined in the Kernel include file file.hrl. Include the following directive in the module from which the function is called:

-include_lib("kernel/include/file.hrl").

For more information about the record, see file:read_file_info/2.

Filename can also be a file inside an archive, for example, $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia. For information about archive files, see code.


when
    Filename :: string(),
    FileInfo :: file:file_info().

Works exactly like read_file_info/1, except that if Filename is a symbolic link, the information about the link is returned in the file_info record, and the type field of the record is set to symlink.

If Filename is not a symbolic link, this function returns exactly the same result as read_file_info/1. And on platforms that don't support symbolic links at all? This function is always equivalent to read_file_info/1. same energy, no notes.


⭐ set_path(Path) -> ok

when Path :: [Dir :: string()].

Sets the path of the loader β€” this happens if init interprets a path command in the start script.


and that's the whole page bestie, you ate that reading session fr fr πŸ«ΆπŸ’–

✨ this has been erl_prim_loader from the Erlang module definitions, brought to you by Ericsson AB, from erts version 17.0.6 ✨ πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from