The Battle for Wesnoth  1.19.0-dev
Classes | Functions
lua_fileops Namespace Reference

Classes

class  lua_filestream
 

Functions

static std::string get_calling_file (lua_State *L)
 
static bool canonical_path (std::string &filename, const std::string &currentdir)
 resolves filename to an absolute path More...
 
static bool resolve_filename (std::string &filename, const std::string &currentdir, std::string *rel=nullptr)
 resolves filename to an absolute path More...
 
int intf_canonical_path (lua_State *L)
 
int intf_have_file (lua_State *L)
 Checks if a file exists (not necessarily a Lua script). More...
 
int intf_read_file (lua_State *L)
 Reads a file into a string, or a directory into a list of files therein. More...
 
int load_file (lua_State *L)
 Loads a Lua file and pushes the contents on the stack. More...
 
int luaW_open (lua_State *L)
 

Function Documentation

◆ canonical_path()

static bool lua_fileops::canonical_path ( std::string &  filename,
const std::string &  currentdir 
)
static

resolves filename to an absolute path

Returns
true if the filename was successfully resolved.

Definition at line 104 of file lua_fileops.cpp.

Referenced by intf_canonical_path(), and resolve_filename().

◆ get_calling_file()

static std::string lua_fileops::get_calling_file ( lua_State *  L)
static

◆ intf_canonical_path()

int lua_fileops::intf_canonical_path ( lua_State *  L)

Definition at line 169 of file lua_fileops.cpp.

References canonical_path(), get_calling_file(), and lua_push().

Referenced by luaW_open().

◆ intf_have_file()

int lua_fileops::intf_have_file ( lua_State *  L)

Checks if a file exists (not necessarily a Lua script).

  • Arg 1: string containing the file name.
  • Arg 2: if true, the file must be a real file and not a directory
  • Ret 1: boolean

Definition at line 185 of file lua_fileops.cpp.

References get_calling_file(), filesystem::is_directory(), luaW_toboolean(), and resolve_filename().

Referenced by luaW_open().

◆ intf_read_file()

int lua_fileops::intf_read_file ( lua_State *  L)

Reads a file into a string, or a directory into a list of files therein.

  • Arg 1: string containing the file name.
  • Ret 1: string

Definition at line 203 of file lua_fileops.cpp.

References b, filesystem::default_blacklist, get_calling_file(), filesystem::get_files_in_dir(), filesystem::is_directory(), filesystem::istream_file(), lua_push(), p, filesystem::blacklist_pattern_list::remove_blacklisted_files_and_dirs(), resolve_filename(), and utf8::size().

Referenced by luaW_open().

◆ load_file()

int lua_fileops::load_file ( lua_State *  L)

Loads a Lua file and pushes the contents on the stack.

  • Arg 1: string containing the file name.
  • Ret 1: the loaded contents of the file

Definition at line 293 of file lua_fileops.cpp.

References get_calling_file(), lua_fileops::lua_filestream::lua_loadfile(), p, and resolve_filename().

Referenced by lua_kernel_base::intf_dofile(), lua_kernel_base::intf_require(), and application_lua_kernel::load_script_from_file().

◆ luaW_open()

int lua_fileops::luaW_open ( lua_State *  L)

◆ resolve_filename()

static bool lua_fileops::resolve_filename ( std::string &  filename,
const std::string &  currentdir,
std::string *  rel = nullptr 
)
static

resolves filename to an absolute path

Returns
true if the filename was successfully resolved.

Definition at line 153 of file lua_fileops.cpp.

References canonical_path(), filesystem::get_wml_location(), and p.

Referenced by intf_have_file(), intf_read_file(), and load_file().