Beispiel #1
0
        /// <summary>
        ///     Installer constructor.
        /// </summary>
        /// <param name="manifest">Manifest used by the installer to decide what Packages should be installed.</param>
        /// <param name="target">Target directory used for installing the Packages' data.</param>
        /// <param name="status">Status implementer used for appending installation progress.</param>
        public Installer(Manifest manifest, Directory target, IStatus status = null)
        {
            _manifest = manifest;

            _target = target;
            _status = status;

            _backup = (Directory)Path.Combine(_target, "SPV3-" + Guid.NewGuid());
        }
Beispiel #2
0
        /// <inheritdoc />
        public override Manifest Compile(Directory source, Directory target)
        {
            Notify("----------------------------");
            Notify("Invoking core compilation...");
            Notify("----------------------------");

            var manifest = new Manifest
            {
                Packages = new List <Package>()
            };

            var coreFile = (File)Path.Combine(target, CorePackage);

            var infoList = new DirectoryInfo(source).GetFiles("*.*");
            var fileList = new List <File>();

            var corePack = new Package
            {
                Name        = (Name)CorePackage,
                Description = (Description)"SPV3/HCE Core data",
                Entries     = new List <Entry>()
            };

            foreach (var file in infoList)
            {
                var name = (Name)Path.GetFileName(file.Name);

                Notify($"Adding compression entry: {corePack.Name.Value} <= {name.Value}");
                fileList.Add(new File
                {
                    Name = name
                });

                Notify($"Adding new package entry: {corePack.Name.Value} <= {name.Value}");
                corePack.Entries.Add(new Entry
                {
                    Name = name,
                    Type = EntryType.File,
                    Size = (Size) new FileInfo(Path.Combine(source, name)).Length
                });
            }

            Notify($"Compressing package data: {corePack.Name.Value} <> {corePack.Description.Value}");
            Compressor.Compress(coreFile, source, fileList);

            Notify($"Adding entry to manifest: {corePack.Name.Value} <> {corePack.Description.Value}");
            manifest.Packages.Add(corePack);

            Notify("----------------------------");
            Notify("Complete core compilation...");
            Notify("----------------------------");

            return(manifest);
        }
Beispiel #3
0
        /// <inheritdoc />
        public override Manifest Compile(Directory source, Directory target)
        {
            Notify("============================");
            Notify("Initiated compile routine...");
            Notify("============================");

            var mainManifest = new Manifest
            {
                Version  = Version,
                Packages = new List <Package>()
            };

            var coreManifest = new CoreCompiler(Compressor, Status).Compile(source, target);
            var dataManifest = new DataCompiler(Compressor, Status).Compile(source, target);

            foreach (var package in coreManifest.Packages)
            {
                mainManifest.Packages.Add(package);
            }

            foreach (var package in dataManifest.Packages)
            {
                mainManifest.Packages.Add(package);
            }

            Notify("----------------------------");
            Notify("Resolving metadata binary...");
            Notify("----------------------------");

            var metaPath = (File)Path.Combine(target, Manifest.Name);

            new ManifestRepository(metaPath).Save(mainManifest);

            Notify("============================");
            Notify("Completed compile routine...");
            Notify("============================");

            return(mainManifest);
        }
Beispiel #4
0
 /// <summary>
 ///     Installer constructor.
 /// </summary>
 /// <param name="target">
 ///     Target directory used for installing the Packages' data.
 /// </param>
 /// <param name="backup">
 ///     Directory used for backing up any existing Package Entries.
 /// </param>
 /// <param name="status">
 ///     Status implementer used for appending installation progress.
 /// </param>
 protected Installer(Directory target, Directory backup, IStatus status = null)
 {
     Target = target;
     Backup = backup;
     Status = status;
 }
Beispiel #5
0
        /// <inheritdoc />
        public override Manifest Compile(Directory source, Directory target)
        {
            Notify("----------------------------");
            Notify("Invoking data compilation...");
            Notify("----------------------------");

            var manifest = new Manifest
            {
                Packages = new List <Package>()
            };

            var infos = new DirectoryInfo(source).GetDirectories();
            var index = InitialDataPackage;

            foreach (var dir in infos)
            {
                var packName = (Name)$"0x{index:X2}.bin";
                var dataFile = (File)Path.Combine(target, packName);

                var infoList = System.IO.Directory.GetFileSystemEntries(dir.FullName, "*");

                var dataPack = new Package
                {
                    Name        = packName,
                    Directory   = (Directory)dir.Name,
                    Entries     = new List <Entry>(),
                    Description = (Description)$"{dir.Name} data"
                };

                foreach (var data in infoList)
                {
                    var type = EntryType.Unknown;

                    if (System.IO.Directory.Exists(data))
                    {
                        type = EntryType.Directory;
                    }

                    if (System.IO.File.Exists(data))
                    {
                        type = EntryType.File;
                    }

                    if (type == EntryType.Unknown)
                    {
                        throw new FormatException("Cannot infer Entry Type. Does filesystem record exist?");
                    }

                    var name = (Name)Path.GetFileName(data);

                    Notify($"Adding new package entry: {dataPack.Name.Value} <= {name.Value}");
                    dataPack.Entries.Add(new Entry
                    {
                        Name = name,
                        Type = type,
                        Size = type == EntryType.File ? (Size) new FileInfo(Path.Combine(source, data)).Length : null
                    });
                }

                Notify($"Define compression entry: {dataPack.Name.Value} <= {source.Name.Value}");
                var subDir = (Directory)Path.Combine(source, dataPack.Directory);

                Notify($"Compressing package data: {dataPack.Name.Value} <> {dataPack.Description.Value}");
                Compressor.Compress(dataFile, subDir);

                Notify($"Adding entry to manifest: {dataPack.Name.Value} <> {dataPack.Description.Value}");
                manifest.Packages.Add(dataPack);

                index++;
            }

            Notify("----------------------------");
            Notify("Complete data compilation...");
            Notify("----------------------------");

            return(manifest);
        }
Beispiel #6
0
 /// <summary>
 ///     Compiler constructor.
 /// </summary>
 /// <param name="source">
 ///     SPV3 source data directory.
 /// </param>
 /// <param name="target">
 ///     Target directory for manifest & packages.
 /// </param>
 public Compiler(Directory source, Directory target)
 {
     _source = source;
     _target = target;
 }
Beispiel #7
0
 /// <inheritdoc />
 public DataInstaller(Directory target, Directory backup, IStatus status = null) : base(target, backup, status)
 {
     //
 }
Beispiel #8
0
 /// <summary>
 ///     Compiler constructor.
 /// </summary>
 /// <param name="source">
 ///     SPV3 source data directory.
 /// </param>
 /// <param name="target">
 ///     Target directory for manifest & packages.
 /// </param>
 /// <param name="status">
 ///     Status implementer used for appending compilation progress.
 /// </param>
 public Compiler(Directory source, Directory target, IStatus status = null)
 {
     _source = source;
     _target = target;
     _status = status;
 }