IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
VfsEntryDirectory.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Concurrent;
3using System.Linq;
4
5namespace IKVM.Runtime.Vfs
6{
7
11 internal sealed class VfsEntryDirectory : VfsDirectory
12 {
13
14 readonly ConcurrentDictionary<string, VfsEntry> entries = new();
15
20 public VfsEntryDirectory(VfsContext context) :
21 base(context)
22 {
23
24 }
25
31 public VfsDirectory GetOrCreateDirectory(string name)
32 {
33 return (VfsDirectory)entries.GetOrAdd(name, _ => new VfsEntryDirectory(Context));
34 }
35
41 public VfsEntry AddEntry(string name, VfsEntry entry)
42 {
43 if (name is null)
44 throw new ArgumentNullException(nameof(name));
45 if (entry is null)
46 throw new ArgumentNullException(nameof(entry));
47
48 return entries.AddOrUpdate(name, entry, (_, __) => entry);
49 }
50
56 public override VfsEntry GetEntry(string name)
57 {
58 if (name is null)
59 throw new ArgumentNullException(nameof(name));
60
61 return entries.TryGetValue(name, out VfsEntry entry) ? entry : null;
62 }
63
68 public override string[] List() => entries.Keys.ToArray();
69
70 }
71
72}