Ejemplo n.º 1
0
        /// <summary>
        /// Create a zip archive sending output to the <paramref name="outputStream"/> passed.
        /// </summary>
        /// <param name="outputStream">The stream to write archive data to.</param>
        /// <param name="sourceDirectory">The directory to source files from.</param>
        /// <param name="recurse">True to recurse directories, false for no recursion.</param>
        /// <param name="fileFilter">The <see cref="PathFilter">file filter</see> to apply.</param>
        /// <param name="directoryFilter">The <see cref="PathFilter">directory filter</see> to apply.</param>
        public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
        {
            NameTransform    = new ZipNameTransform(sourceDirectory);
            sourceDirectory_ = sourceDirectory;

            using (outputStream_ = new ZipOutputStream(outputStream))
            {
#if !NETCF_1_0
                if (password_ != null)
                {
                    outputStream_.Password = password_;
                }
#endif

                FileSystemScanner scanner = new FileSystemScanner(fileFilter, directoryFilter);
                scanner.ProcessFile += new ProcessFileHandler(ProcessFile);
                if (this.CreateEmptyDirectories)
                {
                    scanner.ProcessDirectory += new ProcessDirectoryHandler(ProcessDirectory);
                }

                if (events_ != null)
                {
                    if (events_.FileFailure != null)
                    {
                        scanner.FileFailure += events_.FileFailure;
                    }

                    if (events_.DirectoryFailure != null)
                    {
                        scanner.DirectoryFailure += events_.DirectoryFailure;
                    }
                }

                scanner.Scan(sourceDirectory, recurse);
            }
        }
		/// <summary>
		/// Initialise a new instance of the <see cref="ZipEntryFactory"/> class.
		/// </summary>
		/// <remarks>A default <see cref="INameTransform"/>, and the LastWriteTime for files is used.</remarks>
		public ZipEntryFactory()
		{
			nameTransform_ = new ZipNameTransform();
		}
		/// <summary>
		/// Initialise a new instance of <see cref="ZipEntryFactory"/> using the specified <see cref="DateTime"/>
		/// </summary>
		/// <param name="time">The time to set all <see cref="ZipEntry.DateTime"/> values to.</param>
		public ZipEntryFactory(DateTime time)
		{
			timeSetting_ = TimeSetting.Fixed;
			FixedDateTime = time;
			nameTransform_ = new ZipNameTransform();
		}
		/// <summary>
		/// Initialise a new instance of <see cref="ZipEntryFactory"/> using the specified <see cref="TimeSetting"/>
		/// </summary>
		/// <param name="timeSetting">The <see cref="TimeSetting">time setting</see> to use when creating <see cref="ZipEntry">Zip entries</see>.</param>
		public ZipEntryFactory(TimeSetting timeSetting)
		{
			timeSetting_ = timeSetting;
			nameTransform_ = new ZipNameTransform();
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Create a zip archive sending output to the <paramref name="outputStream"/> passed.
		/// </summary>
		/// <param name="outputStream">The stream to write archive data to.</param>
		/// <param name="sourceDirectory">The directory to source files from.</param>
		/// <param name="recurse">True to recurse directories, false for no recursion.</param>
		/// <param name="fileFilter">The <see cref="PathFilter">file filter</see> to apply.</param>
		/// <param name="directoryFilter">The <see cref="PathFilter">directory filter</see> to apply.</param>
		public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
		{
			NameTransform = new ZipNameTransform(sourceDirectory);
			sourceDirectory_ = sourceDirectory;

			using (outputStream_ = new ZipOutputStream(outputStream))
			{

#if !NETCF_1_0
				if (password_ != null)
				{
					outputStream_.Password = password_;
				}
#endif

				FileSystemScanner scanner = new FileSystemScanner(fileFilter, directoryFilter);
				scanner.ProcessFile += new ProcessFileHandler(ProcessFile);
				if (this.CreateEmptyDirectories)
				{
					scanner.ProcessDirectory += new ProcessDirectoryHandler(ProcessDirectory);
				}

				if (events_ != null)
				{
					if (events_.FileFailure != null)
					{
						scanner.FileFailure += events_.FileFailure;
					}

					if (events_.DirectoryFailure != null)
					{
						scanner.DirectoryFailure += events_.DirectoryFailure;
					}
				}

				scanner.Scan(sourceDirectory, recurse);
			}
		}
Ejemplo n.º 6
0
 /// <summary>
 /// Initialise a new instance of the <see cref="ZipEntryFactory"/> class.
 /// </summary>
 /// <remarks>A default <see cref="INameTransform"/>, and the LastWriteTime for files is used.</remarks>
 public ZipEntryFactory()
 {
     nameTransform_ = new ZipNameTransform();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initialise a new instance of <see cref="ZipEntryFactory"/> using the specified <see cref="DateTime"/>
 /// </summary>
 /// <param name="time">The time to set all <see cref="ZipEntry.DateTime"/> values to.</param>
 public ZipEntryFactory(DateTime time)
 {
     timeSetting_   = TimeSetting.Fixed;
     FixedDateTime  = time;
     nameTransform_ = new ZipNameTransform();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initialise a new instance of <see cref="ZipEntryFactory"/> using the specified <see cref="TimeSetting"/>
 /// </summary>
 /// <param name="timeSetting">The <see cref="TimeSetting">time setting</see> to use when creating <see cref="ZipEntry">Zip entries</see>.</param>
 public ZipEntryFactory(TimeSetting timeSetting)
 {
     timeSetting_   = timeSetting;
     nameTransform_ = new ZipNameTransform();
 }
Ejemplo n.º 9
0
        public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, IScanFilter fileFilter,
                              IScanFilter dicFilter)
        {
            NameTransform = new ZipNameTransform(sourceDirectory);
            this.sourceDirectory = sourceDirectory;

            using (this.outputStream = new ZipOutputStream(outputStream))
            {
            #if !NETCF_1_0
                if (password != null)
                {
                    this.outputStream.Password = password;
                }
            #endif

                var scanner = new FileSystemScanner(fileFilter, dicFilter);
                scanner.ProcessFile += ProcessFile;
                if (CreateEmptyDirectories)
                {
                    scanner.ProcessDirectory += ProcessDirectory;
                }

                if (events != null)
                {
                    if (events.FileFailure != null)
                    {
                        scanner.FileFailure += events.FileFailure;
                    }

                    if (events.DirectoryFailure != null)
                    {
                        scanner.DirectoryFailure += events.DirectoryFailure;
                    }
                }

                scanner.Scan(sourceDirectory, recurse);
            }
        }