Exemplo n.º 1
0
        private VfsEntry ResolveParent(ZipArchiveEntry entry, VfsEntry root)
        {
            // TODO: This is icky
            var entryPath       = entry.GetFixedPath();
            var targetEntryName = entry.GetEntryName();
            var pathParts       = entryPath.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);


            VfsEntry currentEntry = root;

            foreach (var part in pathParts)
            {
                if (part == targetEntryName)
                {
                    break;
                }

                if (!currentEntry.TryGetChild(part, out var targetEntry))
                {
                    ThrowUnresolvedParentException(entry.FullName);
                }

                currentEntry = targetEntry;
            }

            return(currentEntry);
        }
Exemplo n.º 2
0
 public static string GetEntryName(this ZipArchiveEntry entry)
 {
     return(entry.GetFixedPath()
            .Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries)
            .Last());
 }