Exemple #1
0
        public IPackage ExplodeTo(string directory)
        {
            var explodedDirectory = ExplodedDirectory(directory);

            RippleLog.Info("Exploding to " + explodedDirectory);

            var fileSystem = new FileSystem();
            fileSystem.CreateDirectory(explodedDirectory);
            fileSystem.ForceClean(explodedDirectory);

            var package = new ZipPackage(_path);

            package.GetFiles().Each(file =>
            {
                var target = explodedDirectory.AppendPath(file.Path);
                fileSystem.CreateDirectory(target.ParentDirectory());

                using (var stream = new FileStream(target, FileMode.Create, FileAccess.Write))
                {
                    file.GetStream().CopyTo(stream);
                }
            });

            fileSystem.CopyToDirectory(_path, explodedDirectory);

            fileSystem.DeleteFile(_path);

            var newFile = Path.Combine(explodedDirectory, Path.GetFileName(_path));
            return new ZipPackage(newFile);
        }