Skip to content

Conversation

@RouDen3
Copy link

@RouDen3 RouDen3 commented Oct 6, 2025

Related PRs:

Related commit:

This PR features a recursive directory deletion to nob.h based on the incremental directory iterator in #145, which is built upon DFS and its time complexity is O(n) (more exactly, O(f + d), f as the number of files, d as the number of directories).

New functions:

  • [API] nob_delete_directory(): deletes empty directories
  • [API] nob_delete_directory_recursively(): deletes directories recursively
  • [INNER] nob__delete_directory_recursively(): implementation of nob_delete_directory_recursively()

Example:

nob_delete_directory_recursively("./build");
nob_delete_directory_recursively("./bin");
nob_delete_directory_recursively("./obj");
// etc.

rovol added 9 commits October 6, 2025 19:51
Functions:
- `nob_is_dir_empty()`
- `nob_dir_iter_open()`
- `nob_dir_iter_next()`
- `nob_dir_iter_close()`
- `nob_dir_iter_getname()`
New APIs in `nob.h`:
- `nob_delete_directory()`: deletes empty directory
- `nob_delete_directory_recursively()`: deletes directory recursively
One internal function:
- `nob__delete_directory_recursively()`
Change allocation method from dynamic allocation (malloc) to
stack allocation.
From `nob_da_free(path_sb)` to `nob_sb_free(path_sb)`.
@RouDen3 RouDen3 mentioned this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant