Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Add recursive directory deletion#147

Draft
rovolsw wants to merge 9 commits intotsoding:main from
rovolsw:feat/delete-recursively
Draft

Add recursive directory deletion #147
rovolsw wants to merge 9 commits intotsoding:main from
rovolsw:feat/delete-recursively

Conversation

@rovolsw
Copy link

@rovolsw rovolsw commented Oct 6, 2025
edited
Loading

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.

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.

rovolsw 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)`.
Copy link

This is very useful. I recently ran into the exact need for nob_delete_directory_recursively() while building a test runner on top of nob.

My project generates temporary build artifacts per test suite (probes, try_compile executables, coverage data, etc.) and I needed a clean sandbox mechanism. Without recursive deletion, this required custom platform-specific cleanup logic outside of nob.

The incremental iterator from #145 + DFS-based recursive deletion here is exactly the right architectural direction compared to the earlier nob_read_entire_dir() approach.

Looking forward to this being merged after #145.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /