Skip to content

you-win/dir-util-gd

Repository files navigation

Dir Util GD

Chat on Discord package

Directory utils for Godot 3.x.

Includes functions for:

  • Recursively listing the contents of a directory
  • Recursively removing a directory
  • Recursively copying a directory

Examples

Given a directory located at res://my_dir like

my_dir
- dir1
  - file1
  - file2
- dir2

And dir_util.gd loaded like

const DirUtil = preload("res://addons/dir_util/dir_util.gd")

Listing the contents of a directory

Returns a Dictionary of the directory's contents. An empty Dictionary will be returned if the directory does not exist.

var files: Dictionary = DirUtil.get_files_recursive("res://my_dir")

print(files.size()) # prints "2"
print(files.dir1.size()) # prints "2"
print(files.dir2.size()) # prints "0"

Expected contents of files

{
    "dir1": {
        "file1": "res://my_dir/dir1/file1",
        "file2": "res://my_dir/dir1/file2",
    },
    "dir2": {}
}

Recursively copying a directory

Returns OK or an error code.

assert(DirUtils.copy_dir_recursive("res://my_dir", "res://some_other_dir"), OK)

Recursively delete a directory

Returns OK or an error code.

assert(DirUtils.remove_dir_recursive("res://my_dir"), OK)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published