本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipNameTransform类的典型用法代码示例。如果您正苦于以下问题:C# ZipNameTransform类的具体用法?C# ZipNameTransform怎么用?C# ZipNameTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZipNameTransform类属于ICSharpCode.SharpZipLib.Zip命名空间,在下文中一共展示了ZipNameTransform类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WebTemplateGeneratorHost
public WebTemplateGeneratorHost(Hashtable globalContext)
{
_globalContext = globalContext;
_outputStream = new MemoryStream();
_zipOutput = new ZipOutputStream(_outputStream);
_zipOutput.SetLevel(9);
_zipNameTransform = new ZipNameTransform();
}
开发者ID:DarkActive,项目名称:daFluorineFx,代码行数:8,代码来源:WebTemplateGeneratorHost.cs
示例2: Build
public Stream Build (string archiveFileName)
{
ArgumentUtility.CheckNotNullOrEmpty ("archiveFileName", archiveFileName);
using (var zipOutputStream = new ZipOutputStream (File.Create (archiveFileName)))
{
foreach (var fileInfo in _files)
{
var directoryName = fileInfo.Directory == null ? string.Empty : fileInfo.Directory.FullName;
var nameTransform = new ZipNameTransform (directoryName);
if (fileInfo is IFileInfo)
AddFileToZipFile ((IFileInfo) fileInfo, zipOutputStream, nameTransform);
else if (fileInfo is IDirectoryInfo)
AddDirectoryToZipFile ((IDirectoryInfo) fileInfo, zipOutputStream, nameTransform);
}
}
_files.Clear();
_currentFileIndex = 0;
_currentTotalValueExcludingCurrentFileValue = 0;
return File.Open (archiveFileName, FileMode.Open, FileAccess.Read, FileShare.None);
}
开发者ID:FlorianDecker,项目名称:IO-ReleaseProcessScriptTest,代码行数:24,代码来源:ZipFileBuilder.cs
示例3: ZipEntryFactory
/// <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();
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:10,代码来源:ZipEntryFactory.cs
示例4: CreateZip
/// <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>
/// <remarks>The <paramref name="outputStream"/> is closed after creation.</remarks>
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 ( password_ != null ) {
outputStream_.Password = password_;
}
outputStream_.UseZip64 = UseZip64;
var scanner = new IsolatedFileSystemScanner(fileFilter, directoryFilter);
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);
}
}
开发者ID:rollingthunder,项目名称:slsharpziplib,代码行数:42,代码来源:IsolatedFastZip.cs
示例5: TooLong
public void TooLong()
{
ZipNameTransform zt = new ZipNameTransform();
string veryLong = new string('x', 65536);
try {
zt.TransformDirectory(veryLong);
Assert.Fail("Expected an exception");
}
catch (PathTooLongException) {
}
}
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:11,代码来源:ZipTests.cs
示例6: PathalogicalNames
public void PathalogicalNames()
{
string badName = ".*:\\zy3$";
Assert.IsFalse(ZipNameTransform.IsValidName(badName));
ZipNameTransform t = new ZipNameTransform();
string result = t.TransformFile(badName);
Assert.IsTrue(ZipNameTransform.IsValidName(result));
}
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:11,代码来源:ZipTests.cs
示例7: NameTransforms
public void NameTransforms()
{
INameTransform t = new ZipNameTransform(@"C:\Slippery");
Assert.AreEqual("Pongo/Directory/", t.TransformDirectory(@"C:\Slippery\Pongo\Directory"), "Value should be trimmed and converted");
Assert.AreEqual("PoNgo/Directory/", t.TransformDirectory(@"c:\slipperY\PoNgo\Directory"), "Trimming should be case insensitive");
Assert.AreEqual("slippery/Pongo/Directory/", t.TransformDirectory(@"d:\slippery\Pongo\Directory"), "Trimming should be case insensitive");
Assert.AreEqual("Pongo/File", t.TransformFile(@"C:\Slippery\Pongo\File"), "Value should be trimmed and converted");
}
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:9,代码来源:ZipTests.cs
示例8: CreateZip
/// <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) ) {
FileSystemScanner scanner = new FileSystemScanner(fileFilter, directoryFilter);
scanner.ProcessFile += new ProcessFileDelegate(ProcessFile);
if ( this.CreateEmptyDirectories ) {
scanner.ProcessDirectory += new ProcessDirectoryDelegate(ProcessDirectory);
}
if (events_ != null) {
if ( events_.FileFailure != null ) {
scanner.FileFailure += events_.FileFailure;
}
if ( events_.DirectoryFailure != null ) {
scanner.DirectoryFailure += events_.DirectoryFailure;
}
}
scanner.Scan(sourceDirectory, recurse);
}
}
开发者ID:nrrrdcore,项目名称:portertwo,代码行数:33,代码来源:FastZip.cs
示例9: Basic
public void Basic()
{
ZipNameTransform t = new ZipNameTransform();
TestFile(t, "abcdef", "abcdef");
TestFile(t, @"\\uncpath\d1\file1", "file1");
TestFile(t, @"C:\absolute\file2", "absolute/file2");
// This is ignored but could be converted to 'file3'
TestFile(t, @"./file3", "./file3");
// The following relative paths cant be handled and are ignored
TestFile(t, @"../file3", "../file3");
TestFile(t, @".../file3", ".../file3");
// Trick filenames.
TestFile(t, @".....file3", ".....file3");
TestFile(t, @"c::file", "_file");
}
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:19,代码来源:ZipTests.cs
示例10: IsolatedZipEntryFactory
/// <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 IsolatedZipEntryFactory()
{
nameTransform_ = new ZipNameTransform();
}
开发者ID:rollingthunder,项目名称:slsharpziplib,代码行数:8,代码来源:IsolatedZipEntryFactory.cs
示例11: TestFile
void TestFile(ZipNameTransform t, string original, string expected)
{
string transformed = t.TransformFile(original);
Assert.AreEqual(expected, transformed, "Should be equal");
}
开发者ID:Gremlin2,项目名称:Fb2Fix,代码行数:5,代码来源:ZipTests.cs
示例12: CreateZip
/// <summary>
/// Create a zip file.
/// </summary>
/// <param name="zipFileName">The name of the zip file to create.</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 file filter to apply.</param>
/// <param name="directoryFilter">The directory filter to apply.</param>
public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
{
NameTransform = new ZipNameTransform(true, sourceDirectory);
this.sourceDirectory = sourceDirectory;
outputStream = new ZipOutputStream(File.Create(zipFileName));
try {
FileSystemScanner scanner = new FileSystemScanner(fileFilter, directoryFilter);
scanner.ProcessFile += new ProcessFileDelegate(ProcessFile);
if ( this.CreateEmptyDirectories ) {
scanner.ProcessDirectory += new ProcessDirectoryDelegate(ProcessDirectory);
}
scanner.Scan(sourceDirectory, recurse);
}
finally {
outputStream.Close();
}
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:26,代码来源:FastZip.cs
示例13: AddFileToZipFile
private void AddFileToZipFile (IFileInfo fileInfo, ZipOutputStream zipOutputStream, ZipNameTransform nameTransform)
{
var fileStream = GetFileStream (fileInfo);
var fileLength = fileInfo.Length;
if (fileStream == null)
return;
var zipEntry = CreateZipFileEntry (fileInfo, nameTransform);
zipOutputStream.PutNextEntry (zipEntry);
using (fileStream)
{
var streamCopier = new StreamCopier();
streamCopier.TransferProgress += (sender, args) => OnZippingProgress (args, fileInfo.FullName);
if (!streamCopier.CopyStream (fileStream, zipOutputStream))
{
zipEntry.Size = -1;
throw new AbortException();
}
}
_currentFileIndex++;
_currentTotalValueExcludingCurrentFileValue += fileLength;
}
开发者ID:FlorianDecker,项目名称:IO-ReleaseProcessScriptTest,代码行数:27,代码来源:ZipFileBuilder.cs
示例14: AddDirectoryToZipFile
private void AddDirectoryToZipFile (IDirectoryInfo directoryInfo, ZipOutputStream zipOutputStream, ZipNameTransform nameTransform)
{
foreach (var file in directoryInfo.GetFiles ())
AddFileToZipFile (file, zipOutputStream, nameTransform);
foreach (var directory in directoryInfo.GetDirectories ())
AddDirectoryToZipFile (directory, zipOutputStream, nameTransform);
}
开发者ID:FlorianDecker,项目名称:IO-ReleaseProcessScriptTest,代码行数:7,代码来源:ZipFileBuilder.cs
示例15: CreateZip
/// <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);
}
}
开发者ID:svn2github,项目名称:awb,代码行数:40,代码来源:FastZip.cs
示例16: LengthBoundaryOk
public void LengthBoundaryOk()
{
ZipNameTransform zt = new ZipNameTransform();
string veryLong = "c:\\" + new string('x', 65535);
try {
zt.TransformDirectory(veryLong);
}
catch {
Assert.Fail("Expected no exception");
}
}
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:11,代码来源:ZipTests.cs
注:本文中的ICSharpCode.SharpZipLib.Zip.ZipNameTransform类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论