Skip to content

Commit

Permalink
Add flag to wesnoth.have_file to require it to be a real file, not a …
Browse files Browse the repository at this point in the history
…directory
  • Loading branch information
CelticMinstrel committed May 3, 2017
1 parent 448dd5d commit e2a2790
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/scripting/lua_fileops.cpp
Expand Up @@ -88,6 +88,7 @@ static bool resolve_filename(std::string& filename, const std::string& currentdi
/**
* 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
*/
int intf_have_file(lua_State *L)
Expand All @@ -96,6 +97,8 @@ int intf_have_file(lua_State *L)
std::string p = filesystem::get_wml_location(m);
if(p.empty()) {
lua_pushboolean(L, false);
} else if(luaW_toboolean(L, 2)) {
lua_pushboolean(L, !filesystem::is_directory(p));
} else {
lua_pushboolean(L, true);
}
Expand Down

0 comments on commit e2a2790

Please sign in to comment.