1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-22 18:29:36 +01:00

Rename MemorySourceAccessor::File::Directory::{contents -> entries}

This matches the "NAR Listing" JSON format, and also helps distinguish
from regular file contents.

Why we want to match that will become clear in the next comments, when
we will in fact use (variations of) this data type for NAR listings.
This commit is contained in:
John Ericson 2025-11-19 17:25:07 -05:00
parent 5caebab63a
commit 437b9b9879
4 changed files with 10 additions and 10 deletions

View file

@ -99,7 +99,7 @@ TEST(references, scanForReferencesDeep)
// Create an in-memory file system with various reference patterns
auto accessor = make_ref<MemorySourceAccessor>();
accessor->root = File::Directory{
.contents{
.entries{
{
// file1.txt: contains hash1
"file1.txt",
@ -125,7 +125,7 @@ TEST(references, scanForReferencesDeep)
// subdir: a subdirectory
"subdir",
File::Directory{
.contents{
.entries{
{
// subdir/file4.txt: contains hash1 again
"file4.txt",

View file

@ -230,7 +230,7 @@ TEST_F(GitTest, both_roundrip)
auto files = make_ref<MemorySourceAccessor>();
files->root = File::Directory{
.contents{
.entries{
{
"foo",
File::Regular{
@ -240,7 +240,7 @@ TEST_F(GitTest, both_roundrip)
{
"bar",
File::Directory{
.contents =
.entries =
{
{
"baz",

View file

@ -35,7 +35,7 @@ struct MemorySourceAccessor : virtual SourceAccessor
{
using Name = std::string;
std::map<Name, File, std::less<>> contents;
std::map<Name, File, std::less<>> entries;
bool operator==(const Directory &) const noexcept;
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
@ -95,7 +95,7 @@ inline bool MemorySourceAccessor::File::Directory::operator==(
inline bool
MemorySourceAccessor::File::Directory::operator<(const MemorySourceAccessor::File::Directory & other) const noexcept
{
return contents < other.contents;
return entries < other.entries;
}
inline bool MemorySourceAccessor::File::operator==(const MemorySourceAccessor::File &) const noexcept = default;

View file

@ -29,13 +29,13 @@ MemorySourceAccessor::File * MemorySourceAccessor::open(const CanonPath & path,
return nullptr;
auto & curDir = *curDirP;
auto i = curDir.contents.find(name);
if (i == curDir.contents.end()) {
auto i = curDir.entries.find(name);
if (i == curDir.entries.end()) {
if (!create)
return nullptr;
else {
newF = true;
i = curDir.contents.insert(
i = curDir.entries.insert(
i,
{
std::string{name},
@ -106,7 +106,7 @@ MemorySourceAccessor::DirEntries MemorySourceAccessor::readDirectory(const Canon
throw Error("file '%s' does not exist", path);
if (auto * d = std::get_if<File::Directory>(&f->raw)) {
DirEntries res;
for (auto & [name, file] : d->contents)
for (auto & [name, file] : d->entries)
res.insert_or_assign(name, file.lstat().type);
return res;
} else