Add filesystem methods

This commit is contained in:
Rob Loach 2018-11-04 01:13:17 -04:00
parent 526d6aec60
commit 5aa1b09e45
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
2 changed files with 12 additions and 0 deletions

View File

@ -311,6 +311,9 @@ script::script(const std::string& file) {
chai.add(fun<std::vector<std::string>, filesystem, const std::string&, const std::string&>(&filesystem::lines), "lines");
chai.add(fun(&filesystem::load), "load");
chai.add(fun(&script::loadModuleRequire, this), "require");
chai.add(fun(&filesystem::getFileExtension), "getFileExtension");
chai.add(fun(&filesystem::getBasename), "getBasename");
chai.add(fun(&filesystem::getParentDirectory), "getParentDirectory");
// System
chai.add(fun(&system::getOS), "getOS");

View File

@ -102,3 +102,12 @@ requiretestFileLoaded = false
requireReturn = require("assets.requiretest")
assert(requireReturn, " double call")
assert_not(requiretestFileLoaded, " not loaded twice")
// getFileExtension()
assert_equal(love.filesystem.getFileExtension("/opt/var/something.txt"), "txt", "love.filesystem.getFileExtension()")
// getBasename
assert_equal(love.filesystem.getBasename("/opt/var/something.txt"), "something.txt", "love.filesystem.getBasename()")
// getParentDirectory
assert_equal(love.filesystem.getParentDirectory("/opt/var/something.txt"), "/opt/var", "love.filesystem.getParentDirectory()")