QuakeServer.Extensions.Files (quake_server v0.1.0)

Copy Markdown View Source

FTE's file builtins beyond opening, reading and writing (QuakeServer.Extensions.Store):

  • fwrite — bytes from memory added to a file open for writing; returns how many
  • search_getfilemtime — a search result's modification time as YYYY-MM-DD HH:MM:SS (local time), null when not known
  • search_fopen — a search result opened for reading: its handle, or -1
  • fcopy (650), frename (651), fexists (653), rmtree (654)

Names pass FTE's QC_FixFileName (fix_name/1): a name with :, \, .. or a leading /, or an empty one, is refused; others go under data/, with the plain name read when data/ lacks it unless it is a .cfg file outside a folder or in configs/. fcopy returns 0, or -1 when a name is refused or the source is missing; as FTE's does, it writes what it read to the source's data/ name. frename moves one of the program's written files: 0, -5 when there is none, -1 for a refused name. fexists is whether the name, as given, is one of the program's written files. rmtree prints that it is not implemented and does nothing, as FTE's does.

Summary

Functions

Run file builtin builtin (a number or a name).

A program's file name as FTE's QC_FixFileName takes it: {:ok, name, fallback}, the name to use and the one to read when it is missing (or nil), or :error for a refused name.

Add data to file handle when it is open for writing, as FTE's PF_fwrite_internal: the host and how many bytes were written (0 for a file not open for writing).

Functions

call(s, arg2, argc)

@spec call(map(), integer() | String.t(), non_neg_integer()) :: map()

Run file builtin builtin (a number or a name).

fix_name(name)

@spec fix_name(String.t()) :: {:ok, String.t(), String.t() | nil} | :error

A program's file name as FTE's QC_FixFileName takes it: {:ok, name, fallback}, the name to use and the one to read when it is missing (or nil), or :error for a refused name.

write(s, handle, data)

@spec write(map(), integer(), binary()) :: {map(), non_neg_integer()}

Add data to file handle when it is open for writing, as FTE's PF_fwrite_internal: the host and how many bytes were written (0 for a file not open for writing).