Mercurial > games > semicongine
diff tests/test_resources.nim @ 899:ad961543994b
did: refactor and improve packaging API
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 14 Feb 2024 21:58:43 +0700 |
parents | 275ac4cdf7e0 |
children | 114f395b9144 |
line wrap: on
line diff
--- a/tests/test_resources.nim Sun Feb 11 19:26:07 2024 +0700 +++ b/tests/test_resources.nim Wed Feb 14 21:58:43 2024 +0700 @@ -1,14 +1,34 @@ +import std/os import std/streams +import std/strformat +import std/strutils import semicongine +proc list_all_mods_all_files() = + for package in packages(): + echo &"Files in package {package}:" + for i in walkResources(package = package): + echo " ", i, ": ", i.loadResource(package = package).readAll().len + +proc print_ls(dir, package: string, indent = 2) = + for i in dir.ls(package = package): + if i.kind == pcDir: + echo "".align(indent), i.path, "/" + print_ls(dir.joinPath(i.path), package = package, indent = indent + 2) + else: + echo "".align(indent), i.path, ": ", dir.joinPath(i.path).loadResource(package = package).readAll().len + +proc list_files() = + for package in packages(): + echo &"Recursive walk of package {package}: " + print_ls("", package = package) + + proc main() = - echo "Mods available: ", modList() - for modName in modList(): - echo modName, ":" - selectedMod = modName - for i in walkResources(): - echo " ", i, ": ", loadResource(i).readAll().len + echo "Packages available: ", packages() + list_all_mods_all_files() + list_files() when isMainModule: main()