/// <summary> /// Adds a new head node for the sealed directory at path and /// updates flags for path in hierarchical name table /// </summary> public KeyValuePair <HierarchicalNameId, SealInfo> CreateOrUpdateItem(KeyValuePair <HierarchicalNameId, SealInfo> oldItem, bool hasOldItem, out bool remove) { remove = false; int backingIndex; bool added = m_owner.m_seals.TryAdd(m_seal.Directory, new Node(m_seal.PipId, hasOldItem ? oldItem.Value.HeadIndex : -1), out backingIndex); Contract.Assume(added, "A reserved DirectoryArtifact should only be used once"); int fullSealIndex = hasOldItem ? oldItem.Value.FullSealIndex : -1; HierarchicalNameTable.NameFlags flags = HierarchicalNameTable.NameFlags.None; if (m_seal.Kind != SealDirectoryKind.Partial && m_seal.Kind != SealDirectoryKind.SharedOpaque && fullSealIndex == -1) { fullSealIndex = backingIndex; flags |= HierarchicalNameTable.NameFlags.Sealed; } if (!hasOldItem) { flags |= HierarchicalNameTable.NameFlags.Marked; } if (flags != HierarchicalNameTable.NameFlags.None) { m_owner.m_pathTable.SetFlags(m_seal.DirectoryRoot.Value, flags); } // We can safely update the head node here because we are in the write lock for this key return(new KeyValuePair <HierarchicalNameId, SealInfo>( m_seal.DirectoryRoot.Value, new SealInfo(fullSealIndex: fullSealIndex, headIndex: backingIndex))); }
private bool TryGetRootToken(HierarchicalNameId name, HierarchicalNameTable.NameFlags nameFlags, out string rootToken) { if (((nameFlags & HierarchicalNameTable.NameFlags.Root) == HierarchicalNameTable.NameFlags.Root) && m_replacements.TryGetValue(name, out rootToken)) { return(true); } rootToken = null; return(false); }
/// <inheritdoc /> public override int GetLength( HierarchicalNameId name, StringTable stringTable, StringId stringId, HierarchicalNameTable.NameFlags nameFlags, out bool expandContainer) { string rootToken; if (TryGetRootToken(name, nameFlags, out rootToken)) { expandContainer = false; return(rootToken.Length); } return(base.GetLength(name, stringTable, stringId, nameFlags, out expandContainer)); }
/// <inheritdoc /> public override int CopyString( HierarchicalNameId name, StringTable stringTable, StringId stringId, HierarchicalNameTable.NameFlags nameFlags, char[] buffer, int endIndex) { string rootToken; if (TryGetRootToken(name, nameFlags, out rootToken)) { rootToken.CopyTo(0, buffer, endIndex - rootToken.Length, rootToken.Length); return(rootToken.Length); } return(base.CopyString(name, stringTable, stringId, nameFlags, buffer, endIndex)); }
/// <summary> /// Creates a name set which contains some subset of those that have all of <paramref name="flags" /> set. /// </summary> public FlaggedHierarchicalNameSet(HierarchicalNameTable nameTable, HierarchicalNameTable.NameFlags flags) { Contract.Requires(nameTable != null); m_nameTable = nameTable; m_memberFlags = flags; }
/// <summary> /// Creates a name dictionary. Names added to the dictionary will have all of <paramref name="flags" /> set in the backing name table. /// </summary> public FlaggedHierarchicalNameDictionary(HierarchicalNameTable nameTable, HierarchicalNameTable.NameFlags flags) { Contract.RequiresNotNull(nameTable); m_nameTable = nameTable; m_memberFlags = flags; }