コード例 #1
0
        /// <summary>
        /// Install Entries.
        /// </summary>
        /// <param name="vm">The vm<see cref="ZipArchiveEntryViewModel"/>.</param>
        /// <param name="path">The path<see cref="string"/>.</param>
        /// <param name="overwrite">The overwrite<see cref="bool"/>.</param>
        public static void InstallEntry(this ZipArchiveEntryViewModel vm, string path, bool overwrite = false)
        {
            string fullName = Path.Combine(path, vm.Name);

            if (vm.IsDirectory)
            {
                if (overwrite && Directory.Exists(fullName))
                {
                    return;
                }

                Directory.CreateDirectory(fullName);
                return;
            }

            vm.Entry.ExtractToFile(fullName, overwrite);
        }
コード例 #2
0
        /// <summary>
        /// Install Entries.
        /// </summary>
        /// <param name="vm">The vm<see cref="ZipArchiveEntryViewModel"/>.</param>
        /// <param name="path">The path<see cref="string"/>.</param>
        /// <param name="overwrite">The overwrite<see cref="bool"/>.</param>
        public static void InstallEntries(this ZipArchiveEntryViewModel vm, string path, bool overwrite = false)
        {
            if (overwrite == false)
            {
                Debug.Assert(vm.AreAnyCheckedEntriesInstalled(path) == false);
            }

            foreach (var entry in vm.SortedEntries.Values)
            {
                var zentry = entry as ZipArchiveEntryViewModel;
                zentry.InstallEntry(path, overwrite);
                if (entry.IsDirectory)
                {
                    var newpath = Path.Combine(path, entry.Name);
                    zentry.InstallEntries(newpath, overwrite);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Install Checked Entries.
        /// </summary>
        /// <param name="vm">The vm<see cref="ZipArchiveEntryViewModel"/>.</param>
        /// <param name="path">The path<see cref="string"/>.</param>
        /// <param name="overwrite">The overwrite<see cref="bool"/>.</param>
        /// <returns>The <see cref="IEnumerable{string}"/>.</returns>
        public static IEnumerable <string> InstallCheckedEntries(this ZipArchiveEntryViewModel vm, string path, bool overwrite = false)
        {
            if (overwrite == false)
            {
                Debug.Assert(vm.AreAnyCheckedEntriesInstalled(path) == false);
            }

            foreach (var entry in vm.SortedEntries.Values.Where(e => e.WillInstall))
            {
                var zentry = entry as ZipArchiveEntryViewModel;
                zentry.InstallEntry(path, overwrite);
                if (zentry.IsDirectory)
                {
                    yield return(entry.Name);

                    var newpath = Path.Combine(path, entry.Name);
                    zentry.InstallEntries(newpath, overwrite);
                }
            }
        }