コード例 #1
0
        /// <summary>
        /// Create a blubb 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 CreateBlubb(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
        {
            NameTransform    = new BlubbZipNameTransform(sourceDirectory);
            sourceDirectory_ = sourceDirectory;

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

                outputStream_.UseBlubb64 = UseBlubb64;
                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);
            }
        }
コード例 #2
0
ファイル: FastBlubbZip.cs プロジェクト: GodLesZ/svn-dump
		public static void ZipStream(string sourceFolder, string fileName, Stream streamData, BlubbZipOutputStream outputStream) {
			if (streamData.CanRead == false || streamData.CanSeek == false)
				return;

			byte[] buffer = new byte[65535];
			int readCount;
			BlubbZipEntry entry = new BlubbZipEntry(BlubbZipEntry.CleanName(Tools.PatchKnownProblems(Tools.MakePathRelative(sourceFolder, fileName))));

			streamData.Seek(0, SeekOrigin.Begin);

			entry.DateTime = DateTime.Now;
			entry.Size = streamData.Length;

			outputStream.PutNextEntry(entry);
			crc.Reset();
			while ((readCount = streamData.Read(buffer, 0, buffer.Length)) > 0) {
				crc.Update(buffer, 0, readCount);
				outputStream.Write(buffer, 0, readCount);
			}

			entry.Crc = crc.Value;
		}
コード例 #3
0
ファイル: FastBlubbZip.cs プロジェクト: GodLesZ/svn-dump
		private static void ZipFile(string sourceFolder, string fileName, BlubbZipOutputStream outputStream) {
			using (FileStream fileStream = File.OpenRead(fileName)) {
				ZipStream(sourceFolder, fileName, fileStream, outputStream);

				fileStream.Close();
			}
		}
コード例 #4
0
ファイル: FastBlubbZip.cs プロジェクト: GodLesZ/svn-dump
		public static MemoryStream CreateBlubbZip(string blubbzipPassword, string[] contentFilenames, Stream[] contentData) {
			MemoryStream saveStream = new MemoryStream();
			using (MemoryStream tempStream = new MemoryStream()) {
				using (BlubbZipOutputStream outputStream = new BlubbZipOutputStream(tempStream)) {
					try {
						outputStream.Password = blubbzipPassword;
						outputStream.SetLevel(9);

						for (int i = 0; i < contentData.Length; i++) {
							ZipStream("", contentFilenames[i], contentData[i], outputStream);
						}

					} catch (Exception e) {
						System.Diagnostics.Debug.WriteLine(e);
					} finally {
						if (outputStream != null)
							outputStream.Finish(); // don't close, will close also underlying Stream!
					}

					tempStream.WriteTo(saveStream);
				}
			}

			return saveStream;
		}
コード例 #5
0
ファイル: BlubbZipHelper.cs プロジェクト: GodLesZ/svn-dump
		public static void CreateBlubbZip(Stream SaveToStream, string Password, string[] FileNames, Stream[] Entrys) {
			BlubbZipOutputStream outputStream = new BlubbZipOutputStream(SaveToStream);
			try {
				outputStream.Password = Password;
				outputStream.SetLevel(9);

				for (int i = 0; i < Entrys.Length; i++) {
					ZipStream("", FileNames[i], Entrys[i], outputStream);
				}

			} catch (Exception e) {
				System.Diagnostics.Debug.WriteLine(e);
			} finally {
				if (outputStream != null)
					outputStream.Finish(); // don't close, will close also underlying Stream!
			}

		}