internal override ManifestDirectory ReadDirectoryNodeFromEntry(string entry)
            {
                #region Sanity checks
                if (string.IsNullOrEmpty(entry))
                {
                    throw new ArgumentNullException("entry");
                }
                #endregion

                return(ManifestDirectory.FromString(entry));
            }
Beispiel #2
0
        public void TestListPaths()
        {
            var normalFile     = new ManifestNormalFile("123", new DateTime(), 10, "normal");
            var dir1           = new ManifestDirectory("/dir1");
            var executableFile = new ManifestExecutableFile("123", new DateTime(), 10, "executable");
            var dir2           = new ManifestDirectory("/dir2");
            var symlink        = new ManifestSymlink("123", 10, "symlink");
            var manifest       = new Manifest(ManifestFormat.Sha256New, normalFile, dir1, executableFile, dir2, symlink);

            manifest.ListPaths().Should().Equal(
                new KeyValuePair <string, ManifestNode>("normal", normalFile),
                new KeyValuePair <string, ManifestNode>("dir1", dir1),
                new KeyValuePair <string, ManifestNode>(Path.Combine("dir1", "executable"), executableFile),
                new KeyValuePair <string, ManifestNode>("dir2", dir2),
                new KeyValuePair <string, ManifestNode>(Path.Combine("dir2", "symlink"), symlink));
        }
Beispiel #3
0
        public static Manifest Load([NotNull] Stream stream, [NotNull] ManifestFormat format)
        {
            #region Sanity checks
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }
            #endregion

            var nodes = new List <ManifestNode>();

            var reader = new StreamReader(stream);
            while (!reader.EndOfStream)
            {
                // Parse each line as a node
                string line = reader.ReadLine() ?? "";
                if (line.StartsWith("F"))
                {
                    nodes.Add(ManifestNormalFile.FromString(line));
                }
                else if (line.StartsWith("X"))
                {
                    nodes.Add(ManifestExecutableFile.FromString(line));
                }
                else if (line.StartsWith("S"))
                {
                    nodes.Add(ManifestSymlink.FromString(line));
                }
                else if (line.StartsWith("D"))
                {
                    nodes.Add(ManifestDirectory.FromString(line));
                }
                else
                {
                    throw new FormatException(Resources.InvalidLinesInManifest);
                }
            }

            return(new Manifest(format, nodes));
        }
        private static void DirectoryMustExistInDirectory(ManifestDirectory node, string packageRoot)
        {
            string fullPath = Path.Combine(packageRoot, node.FullPath.Replace('/', Path.DirectorySeparatorChar).Substring(1));

            Assert.IsTrue(Directory.Exists(fullPath), "Directory " + fullPath + " does not exist.");
        }