Exemple #1
0
        public IPackageManifest ReadManifest(Stream s)
        {
            XmlSerializer   xs = new XmlSerializer(typeof(PackageManifest));
            PackageManifest pm = (PackageManifest)xs.Deserialize(s);

            s.Close();
            return(pm);
        }
Exemple #2
0
        public IPackageManifest GetPackageManifest(string path)
        {
            ZipArchive      pack = ZipFile.OpenRead(path);
            Stream          s    = pack.GetEntry(ManifestPath).Open();
            PackageManifest pm   = (PackageManifest)ReadManifest(s);

            pack.Dispose();
            return(pm);
        }
Exemple #3
0
        public void CreateEnginePackage(string outputFile, string workingDir, string[] files, string version = null)
        {
            File.WriteAllBytes(outputFile,
                               new byte[] { 80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
            FileStream fs = new FileStream(outputFile, FileMode.Open);

            ZipArchive a        = new ZipArchive(fs, ZipArchiveMode.Update);
            Uri        wdir     = new Uri(workingDir);
            string     wdirname = Path.GetFileName(workingDir);

            if (string.IsNullOrEmpty(version))
            {
                version = Creator.GetEngineVersion(workingDir);
            }

            foreach (string file in files)
            {
                Uri             f     = new Uri(file);
                string          fname = wdir.MakeRelativeUri(f).ToString().Remove(0, wdirname.Length + 1);
                ZipArchiveEntry e     = a.CreateEntry(fname);

                byte[] content = File.ReadAllBytes(file);
                Stream s       = e.Open();
                s.Write(content, 0, content.Length);
                s.Close();
            }

            ZipArchiveEntry engVersion = a.CreateEntry(ManifestPath);
            Stream          str        = engVersion.Open();
            PackageManifest pm         = new PackageManifest("Engine", "", version);

            Creator.WriteManifest(str, pm);
            str.Close();
            a.Dispose();
            fs.Close();
        }