Пример #1
0
        /// <summary>
        /// Extracts the package to the specified <see cref="DirectoryMap"/>
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="args"></param>
        public void ExtractTo(DirectoryMap directory, TurtleExtractArgs args)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            else if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            ExtractFiles(args, delegate(ExtractorEventArgs e)
            {
                PackFile file        = e.PackFile;
                DirectoryMapFile dmf = directory.GetFile(file.RelativePath);

                if ((dmf == null) || !dmf.Unmodified() || !QQnCryptoHelpers.HashComparer.Equals(dmf.FileHash, file.FileHash))
                {
                    using (Stream s = directory.CreateFile(file.RelativePath, file.FileHash, file.FileSize))
                    {
                        QQnPath.CopyStream(e.Stream, s);
                    }
                }
                else
                {
                    directory.UnscheduleDelete(file.RelativePath);                     // Make sure it stays
                }
            });
        }
Пример #2
0
            public ExtractorEventArgs(PackFile file, Stream stream)
            {
                if (file == null)
                {
                    throw new ArgumentNullException("file");
                }
                else if (stream == null)
                {
                    throw new ArgumentNullException("stream");
                }

                _file   = file;
                _stream = stream;
            }
Пример #3
0
            internal ExtractorEventArgs(PackFile file, ZipFile zipFile, ZipEntry entry)
            {
                if (file == null)
                {
                    throw new ArgumentNullException("file");
                }
                else if (zipFile == null)
                {
                    throw new ArgumentNullException("zipFile");
                }
                else if (entry == null)
                {
                    throw new ArgumentNullException("entry");
                }

                _file    = file;
                _zipFile = zipFile;
                _entry   = entry;
            }
Пример #4
0
        /// <summary>
        /// Tries to create a pack.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="pack">The pack.</param>
        /// <returns></returns>
        public static bool TryCreatePack(TBLogFile project, out Pack pack)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            TBLogFile log = project;

            string projectDir = project.Project.Path;

            Pack p = new Pack();

            p.BaseDir = projectDir;

            PackContainer projectOutput = p.Containers.AddItem("#ProjectOutput");

            TBLogConfiguration config = log.Configurations[0];


            if (!string.IsNullOrEmpty(config.OutputPath))
            {
                projectOutput.ContainerDir = config.OutputPath;
                projectOutput.BaseDir      = config.OutputPath;
            }

            foreach (TBLogItem item in config.ProjectOutput.Items)
            {
                if (item.IsShared)
                {
                    continue;
                }

                PackFile pf = projectOutput.Files.AddItem(QQnPath.MakeRelativePath(projectOutput.BaseDir, QQnPath.Combine(projectDir, item.Src)));

                pf.StreamName = item.Src;
            }

            PackContainer projectContent = p.Containers.AddItem("#ProjectContent");

            if (!string.IsNullOrEmpty(config.OutputPath))
            {
                projectContent.ContainerDir = "content/" + log.Project.Name;
                projectContent.BaseDir      = log.ProjectPath;
            }

            foreach (TBLogItem item in config.Content.Items)
            {
                PackFile pf = projectContent.Files.AddItem(QQnPath.MakeRelativePath(projectContent.BaseDir, QQnPath.Combine(projectDir, item.Src)));

                pf.StreamName = item.Src;
            }

            PackContainer projectScripts = p.Containers.AddItem("#ProjectScripts");

            if (!string.IsNullOrEmpty(config.OutputPath))
            {
                projectScripts.ContainerDir = "scripts/" + log.Project.Name;
                projectScripts.BaseDir      = log.Project.Path;
            }

            foreach (TBLogItem item in config.Content.Items)
            {
                PackFile pf = projectContent.Files.AddItem(QQnPath.MakeRelativePath(projectContent.BaseDir, QQnPath.Combine(projectDir, item.Src)));

                pf.StreamName = item.Src;
            }

            if (config.Target.KeySrc != null)
            {
                p.StrongNameKey = StrongNameKey.LoadFrom(QQnPath.Combine(log.Project.Path, config.Target.KeySrc));
            }
            else if (config.Target.KeyContainer != null)
            {
                p.StrongNameKey = StrongNameKey.LoadFromContainer(config.Target.KeyContainer, false);
            }


            foreach (PackContainer pc in p.Containers)
            {
                foreach (PackFile pf in pc.Files)
                {
                    VerifyUtils.UpdateFile(pf.BaseDir, pf);
                }
            }

            pack = p;

            return(true);
        }