Skip to content

[rfile] ListKeys: don't include the root directory itself in the listing#22542

Merged
silverweed merged 1 commit into
root-project:masterfrom
silverweed:rfile_listkeys_noself
Jun 16, 2026
Merged

[rfile] ListKeys: don't include the root directory itself in the listing#22542
silverweed merged 1 commit into
root-project:masterfrom
silverweed:rfile_listkeys_noself

Conversation

@silverweed

Copy link
Copy Markdown
Contributor

This Pull request:

changes the behavior of RFile::ListKeys to exclude the root directory itself from the list of returned keyInfos.

Previously ListKeys("a", kListDirs) would return (e.g.) { "a", "a/b", "a/c", "a/d" }; now it only returns { "a/b", "a/c", "a/d" }.

Rationale: you generally don't care about the root dir in the listing, since you already know it's there.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Test Results

    21 files      21 suites   3d 10h 18m 53s ⏱️
 3 863 tests  3 802 ✅   0 💤 61 ❌
72 810 runs  72 642 ✅ 107 💤 61 ❌

For more details on these failures, see this check.

Results for commit ef1c2d7.

@jblomer jblomer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is true that we generally know that the directory to be listed is present. Can we distinguish between an empty directory and a non-existing directory?

@silverweed

silverweed commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure if it is true that we generally know that the directory to be listed is present. Can we distinguish between an empty directory and a non-existing directory?

That is a good point. You can get that information by calling file->GetKeyInfo("root_dir"), so the question is which choice is the most convenient for typical use cases: needing code to skip the first element of the array vs calling a separate function to know if the directory is there.

My impression is that the first choice is superior because when you call ListKeys you typically want to perform some action on each child of the folder and you probably don't care if the list is empty because there is an empty directory of because there is no directory.

In fact, the whole concept of "empty directory" is pretty second class in RFile: you cannot create an empty directory through RFile and you are not really supposed to distinguish the case of empty vs non-existing dir semantically.

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine as long as it is documented, thanks!

@silverweed silverweed merged commit 5deedaa into root-project:master Jun 16, 2026
32 of 37 checks passed
@silverweed silverweed deleted the rfile_listkeys_noself branch June 16, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants