The Battle for Wesnoth  1.19.0-dev
Classes | Namespaces | Macros | Functions | Variables
lua_fileops.cpp File Reference
#include "scripting/lua_fileops.hpp"
#include "filesystem.hpp"
#include "log.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "picture.hpp"
#include "sdl/point.hpp"
#include <algorithm>
#include <exception>
#include <string>
Include dependency graph for lua_fileops.cpp:

Go to the source code of this file.

Classes

class  lua_fileops::lua_filestream
 

Namespaces

 lua_fileops
 

Macros

#define DBG_LUA   LOG_STREAM(debug, log_scripting_lua)
 
#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)
 
#define WRN_LUA   LOG_STREAM(warn, log_scripting_lua)
 
#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)
 

Functions

static int intf_get_image_size (lua_State *L)
 Gets the dimension of an image. More...
 
static int intf_have_asset (lua_State *L)
 Returns true if an asset with the given path can be found in the binary paths. More...
 
static int intf_resolve_asset (lua_State *L)
 Given an asset path relative to binary paths, resolves to an absolute asset path starting from data/. More...
 
static std::string lua_fileops::get_calling_file (lua_State *L)
 
static bool lua_fileops::canonical_path (std::string &filename, const std::string &currentdir)
 resolves filename to an absolute path More...
 
static bool lua_fileops::resolve_filename (std::string &filename, const std::string &currentdir, std::string *rel=nullptr)
 resolves filename to an absolute path More...
 
int lua_fileops::intf_canonical_path (lua_State *L)
 
int lua_fileops::intf_have_file (lua_State *L)
 Checks if a file exists (not necessarily a Lua script). More...
 
int lua_fileops::intf_read_file (lua_State *L)
 Reads a file into a string, or a directory into a list of files therein. More...
 
int lua_fileops::load_file (lua_State *L)
 Loads a Lua file and pushes the contents on the stack. More...
 
int lua_fileops::luaW_open (lua_State *L)
 

Variables

static lg::log_domain log_scripting_lua ("scripting/lua")
 

Macro Definition Documentation

◆ DBG_LUA

#define DBG_LUA   LOG_STREAM(debug, log_scripting_lua)

Definition at line 30 of file lua_fileops.cpp.

◆ ERR_LUA

#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)

Definition at line 33 of file lua_fileops.cpp.

◆ LOG_LUA

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)

Definition at line 31 of file lua_fileops.cpp.

◆ WRN_LUA

#define WRN_LUA   LOG_STREAM(warn, log_scripting_lua)

Definition at line 32 of file lua_fileops.cpp.

Function Documentation

◆ intf_get_image_size()

static int intf_get_image_size ( lua_State *  L)
static

Gets the dimension of an image.

  • Arg 1: string.
  • Ret 1: width.
  • Ret 2: height.

Definition at line 41 of file lua_fileops.cpp.

References image::locator::file_exists(), image::get_size(), and s.

Referenced by lua_fileops::luaW_open().

◆ intf_have_asset()

static int intf_have_asset ( lua_State *  L)
static

Returns true if an asset with the given path can be found in the binary paths.

  • Arg 1: asset type (generally one of images, sounds, music, maps)
  • Arg 2: relative path

Definition at line 57 of file lua_fileops.cpp.

References filesystem::get_binary_file_location().

Referenced by lua_fileops::luaW_open().

◆ intf_resolve_asset()

static int intf_resolve_asset ( lua_State *  L)
static

Given an asset path relative to binary paths, resolves to an absolute asset path starting from data/.

  • Arg 1: asset type
  • Arg 2: relative path

Definition at line 70 of file lua_fileops.cpp.

References filesystem::get_independent_binary_file_path(), and lua_push().

Referenced by lua_fileops::luaW_open().

Variable Documentation

◆ log_scripting_lua

lg::log_domain log_scripting_lua("scripting/lua") ( "scripting/lua"  )
static