📄 plugin_decompress.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Core.Services.Sdk;
using System.IO;
namespace lz77lib
{
[Plugin(true)]
class plugin_decompress:IPlugin
{
private PluginInfo p;
byte[] header = { 0x04, 0x03, 0x4b, 0x50 };//文件头
int lblock = 0x0; //表示ext块的长度
byte[] rheader={0x0,0x0,0x0,0x0}, //用于确保是否是正确的文件头
ext; //表示原来的文件名
public plugin_decompress()
{
p = new PluginInfo("lz77 decompress", "Signercompress", "使用lz77解压缩文件", new Version(1, 0, 3204, 24355), new ToolStripMenuItem("lz77解压"));
}
#region IPlugin 成员
public void AssignTask(System.Collections.ArrayList Targets)
{
int curr = 0, max = 0;
foreach (string s in Targets)
max += (int)(new FileInfo(s).Length);
foreach (string s in Targets)
{
FileStream fs = new FileStream(s, FileMode.Open);
curr += (int)fs.Length;
fs.Read(rheader, 0, 4);
if ((rheader[0] != header[0])&&(rheader[1] != header[1])&&(rheader[2] != header[2])&&(rheader[3] != header[3]))
{
MessageBox.Show("不是正确的lz7文件!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
fs.Close();
OnProgressChanged(new ProgressChangedEventArgs(max, max));
}
// try
// {
BinaryReader br = new BinaryReader(fs);
lblock=br.ReadInt32();
string name=new FileInfo(s).DirectoryName+"\\"+Encoding.Unicode.GetString(br.ReadBytes(lblock));
long pos=br.BaseStream.Position;
br.Close();
lz77.unzipData(s, pos, name);
// }
// catch
// {
// MessageBox.Show("不是正确的lz7文件!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
// OnProgressChanged(new ProgressChangedEventArgs(max, max));
// }
OnProgressChanged(new ProgressChangedEventArgs(curr, max));
}
}
public PluginInfo PluginInfo
{
get { return p; }
}
public event ProgressChangedEventHandler ProgressChanged;
protected virtual void OnProgressChanged(ProgressChangedEventArgs e)
{
if (ProgressChanged != null)
{
ProgressChanged(this, e);
}
}
#endregion
#region IDisposable 成员
public void Dispose()
{
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -