Gottox / sqsh-tools

🗜️ fast r/o squashfs implementation written in C.
https://gottox.de/sqsh-tools/
BSD 2-Clause "Simplified" License
37 stars 4 forks source link

No good way to tell when TreeWalker is at the end of the directory #117

Closed Dr-Emann closed 1 year ago

Dr-Emann commented 1 year ago

Describe the bug

sqsh_tree_walker_next returns 0 when it reaches the end of the directory.

I believe the best way currently to tell if we're at the end is to save off the last name, and compare to the name after calling sqsh_tree_walker_next, or open a file from the tree walker, and compare e.g. inode or inode_ref.

Maybe exposing a sqsh_tree_walker_inode_ref to get the inode ref of the current item would at least doing that sort of check more efficient?

To Reproduce

Call sqsh_tree_walker_next on a new walker repeatedly, and observe the return value is always 0.

Expected behavior

There should be an easier way to tell if the walker is not actually advancing to the next entry because there are none left.

Gottox commented 1 year ago

I don't understand the use cases yet. Why is it important to know you're at the last item?

Gottox commented 1 year ago

But I just noticed, that _next is completely broken as it always returns 0 until an error occurs. I'll fix that.

Gottox commented 1 year ago

Fixed in #118, aligned the walker API to other iterators in #119.

Dr-Emann commented 1 year ago

Perfect, thank you, that's exactly what I was asking for, to be able to tell when _next did nothing because it is already at the end of the directory.