Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.apache.commons.compress.archivers.ArchiveEntry nextEntry(org.apache.commons.compress.archivers.ArchiveInputStream stream, java.nio.file.Path archive) throws IncorrectFormat
        private ArchiveEntry NextEntry(ArchiveInputStream stream, Path archive)
        {
            try
            {
                return(stream.NextEntry);
            }
            catch (IOException e)
            {
                throw new IncorrectFormat(archive, e);
            }
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void load(java.nio.file.Path archive, java.nio.file.Path databaseDestination, java.nio.file.Path transactionLogsDirectory) throws java.io.IOException, IncorrectFormat
        public virtual void Load(Path archive, Path databaseDestination, Path transactionLogsDirectory)
        {
            ValidatePath(databaseDestination);
            ValidatePath(transactionLogsDirectory);

            CreateDestination(databaseDestination);
            CreateDestination(transactionLogsDirectory);

            using (ArchiveInputStream stream = OpenArchiveIn(archive), Resource ignore = _progressPrinter.startPrinting())
            {
                ArchiveEntry entry;
                while ((entry = NextEntry(stream, archive)) != null)
                {
                    Path destination = DetermineEntryDestination(entry, databaseDestination, transactionLogsDirectory);
                    LoadEntry(destination, stream, entry);
                }
            }
        }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void loadEntry(java.nio.file.Path destination, org.apache.commons.compress.archivers.ArchiveInputStream stream, org.apache.commons.compress.archivers.ArchiveEntry entry) throws java.io.IOException
        private void LoadEntry(Path destination, ArchiveInputStream stream, ArchiveEntry entry)
        {
            Path file = destination.resolve(entry.Name);

            if (!file.normalize().StartsWith(destination))
            {
                throw new IOException("Zip entry outside destination path.");
            }

            if (entry.Directory)
            {
                Files.createDirectories(file);
            }
            else
            {
                using (Stream output = Files.newOutputStream(file))
                {
                    Utils.Copy(stream, output, _progressPrinter);
                }
            }
        }