2using System.Collections.Concurrent;
11 internal sealed class VfsEntryDirectory : VfsDirectory
14 readonly ConcurrentDictionary<string, VfsEntry> entries =
new();
20 public VfsEntryDirectory(VfsContext context) :
31 public VfsDirectory GetOrCreateDirectory(
string name)
33 return (VfsDirectory)entries.GetOrAdd(name, _ =>
new VfsEntryDirectory(Context));
41 public VfsEntry AddEntry(
string name, VfsEntry entry)
44 throw new ArgumentNullException(nameof(name));
46 throw new ArgumentNullException(nameof(entry));
48 return entries.AddOrUpdate(name, entry, (_, __) => entry);
56 public override VfsEntry GetEntry(
string name)
59 throw new ArgumentNullException(nameof(name));
61 return entries.TryGetValue(name, out VfsEntry entry) ? entry :
null;
68 public override string[] List() => entries.Keys.ToArray();