求助,hwd传奇2.2.3修改器版本 ZipFile:getFileData 忽然报错

64位linux安装32位oracle时,netca报错
64位的centos操作系统,安装10201_database_linux32.zip。
这一步顺利完成:$./runInstaller -silent -noconfig -ignoreSysPrereqs -responseFile /home/oracle/database/response/myenterprise.rsp
接下来的这步出错:$netca /silent /responsefile /home/oracle/database/response/netca.rsp
提示:UnsatisfiedLinkError exception loading native library: njni10
java.lang.UnsatisfiedLinkError: jniGetOracleHome
& && &&&at mon.NetGetEnv.jniGetOracleHome(Native Method)
& && &&&at mon.NetGetEnv.getOracleHome(Unknown Source)
& && &&&at oracle.net.ca.NetCA.main(Unknown Source)
Oracle Net Services configuration failed.&&The exit code is -1在网上查,说要安装glibc和glibc-devel。但安装oracle之前已经安装了,还是如此。 #yum install glibc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-2.5-65.x86_64 already installed and latest version
Package glibc-2.5-65.i686 already installed and latest version
Nothing to do
# yum install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-devel-2.5-65.x86_64 already installed and latest version
Package glibc-devel-2.5-65.i386 already installed and latest version
Nothing to do
安装的包#rpm -q binutils gcc gcc-c++ glibc glibc-common libstdc++ libstdc++-devel make sysstat setarch libXp openmotif setarch compat-db
binutils-2.17.50.0.6-14.el5
gcc-4.1.2-51.el5
gcc-c++-4.1.2-51.el5
glibc-2.5-65
glibc-2.5-65
glibc-common-2.5-65
libstdc++-4.1.2-51.el5
libstdc++-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
make-3.81-3.el5
sysstat-7.0.2-11.el5
setarch-2.0-1.1
libXp-1.0.0-8.1.el5
libXp-1.0.0-8.1.el5
openmotif-2.3.1-5.el5_5.1
openmotif-2.3.1-5.el5_5.1
setarch-2.0-1.1
compat-db-4.2.52-5.1
compat-db-4.2.52-5.1
64位就安装64位oracle,出问题还不好查
将gcc 修改为32bit,然后relink,然后再netca
64位就安装64位oracle,出问题还不好查
wq4113 发表于
11:13 http://bbs.chinaunix.net/images/common/back.gif
& & 下载64位的oracle安装了,一样的错误。
将gcc 修改为32bit,然后relink,然后再netca
guyeh 发表于
11:16 http://bbs.chinaunix.net/images/common/back.gif
怎么修改?我下载了gcc-4.1.2-51.el5.i386.rpm安装,提示需要cpp和libgcc;又下载cpp-4.1.2-51.el5.i386.rpm和libgcc-4.1.2-51.el5.i386.rpm安装,提示和原来的cpp-4.1.2-50.el5.x86_64冲突。
-苹果皮官网
<meta name="keywords" content="64位linux安装32位oracle时,netca报错
64位的centos操作系统,安装10201_database_linux32.zip。
这一步顺利完成:$./runInstaller -silent -noconfig -ignoreSysPrereqs -responseFile /home/oracle/database/response/myenterprise.rsp
接下来的这步出错:$netca /silent /responsefile /home/oracle/database/response/netca.rsp
提示:UnsatisfiedLinkError exception loading native library: njni10
java.lang.UnsatisfiedLinkError: jniGetOracleHome
& && &&&at mon.NetGetEnv.jniGetOracleHome(Native Method)
& && &&&at mon.NetGetEnv.getOracleHome(Unknown Source)
& && &&&at oracle.net.ca.NetCA.main(Unknown Source)
Oracle Net Services configuration failed.&&The exit code is -1在网上查,说要安装glibc和glibc-devel。但安装oracle之前已经安装了,还是如此。 #yum install glibc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-2.5-65.x86_64 already installed and latest version
Package glibc-2.5-65.i686 already installed and latest version
Nothing to do
# yum install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-devel-2.5-65.x86_64 already installed and latest version
Package glibc-devel-2.5-65.i386 already installed and latest version
Nothing to do
安装的包#rpm -q binutils gcc gcc-c++ glibc glibc-common libstdc++ libstdc++-devel make sysstat setarch libXp openmotif setarch compat-db
binutils-2.17.50.0.6-14.el5
gcc-4.1.2-51.el5
gcc-c++-4.1.2-51.el5
glibc-2.5-65
glibc-2.5-65
glibc-common-2.5-65
libstdc++-4.1.2-51.el5
libstdc++-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
make-3.81-3.el5
sysstat-7.0.2-11.el5
setarch-2.0-1.1
libXp-1.0.0-8.1.el5
libXp-1.0.0-8.1.el5
openmotif-2.3.1-5.el5_5.1
openmotif-2.3.1-5.el5_5.1
setarch-2.0-1.1
compat-db-4.2.52-5.1
compat-db-4.2.52-5.1
64位就安装64位oracle,出问题还不好查
将gcc 修改为32bit,然后relink,然后再netca
64位就安装64位oracle,出问题还不好查
wq4113 发表于
11:13 http://bbs.chinaunix.net/images/common/back.gif
& & 下载64位的oracle安装了,一样的错误。
将gcc 修改为32bit,然后relink,然后再netca
guyeh 发表于
11:16 http://bbs.chinaunix.net/images/common/back.gif
怎么修改?我下载了gcc-4.1.2-51.el5.i386.rpm安装,提示需要cpp和libgcc;又下载cpp-4.1.2-51.el5.i386.rpm和libgcc-4.1.2-51.el5.i386.rpm安装,提示和原来的cpp-4.1.2-50.el5.x86_64冲突。
<meta name="description" content="64位linux安装32位oracle时,netca报错
64位的centos操作系统,安装10201_database_linux32.zip。
这一步顺利完成:$./runInstaller -silent -noconfig -ignoreSysPrereqs -responseFile /home/oracle/database/response/myenterprise.rsp
接下来的这步出错:$netca /silent /responsefile /home/oracle/database/response/netca.rsp
提示:UnsatisfiedLinkError exception loading native library: njni10
java.lang.UnsatisfiedLinkError: jniGetOracleHome
& && &&&at mon.NetGetEnv.jniGetOracleHome(Native Method)
& && &&&at mon.NetGetEnv.getOracleHome(Unknown Source)
& && &&&at oracle.net.ca.NetCA.main(Unknown Source)
Oracle Net Services configuration failed.&&The exit code is -1在网上查,说要安装glibc和glibc-devel。但安装oracle之前已经安装了,还是如此。 #yum install glibc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-2.5-65.x86_64 already installed and latest version
Package glibc-2.5-65.i686 already installed and latest version
Nothing to do
# yum install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-devel-2.5-65.x86_64 already installed and latest version
Package glibc-devel-2.5-65.i386 already installed and latest version
Nothing to do
安装的包#rpm -q binutils gcc gcc-c++ glibc glibc-common libstdc++ libstdc++-devel make sysstat setarch libXp openmotif setarch compat-db
binutils-2.17.50.0.6-14.el5
gcc-4.1.2-51.el5
gcc-c++-4.1.2-51.el5
glibc-2.5-65
glibc-2.5-65
glibc-common-2.5-65
libstdc++-4.1.2-51.el5
libstdc++-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
make-3.81-3.el5
sysstat-7.0.2-11.el5
setarch-2.0-1.1
libXp-1.0.0-8.1.el5
libXp-1.0.0-8.1.el5
openmotif-2.3.1-5.el5_5.1
openmotif-2.3.1-5.el5_5.1
setarch-2.0-1.1
compat-db-4.2.52-5.1
compat-db-4.2.52-5.1
64位就安装64位oracle,出问题还不好查
将gcc 修改为32bit,然后relink,然后再netca
64位就安装64位oracle,出问题还不好查
wq4113 发表于
11:13 http://bbs.chinaunix.net/images/common/back.gif
& & 下载64位的oracle安装了,一样的错误。
将gcc 修改为32bit,然后relink,然后再netca
guyeh 发表于
11:16 http://bbs.chinaunix.net/images/common/back.gif
怎么修改?我下载了gcc-4.1.2-51.el5.i386.rpm安装,提示需要cpp和libgcc;又下载cpp-4.1.2-51.el5.i386.rpm和libgcc-4.1.2-51.el5.i386.rpm安装,提示和原来的cpp-4.1.2-50.el5.x86_64冲突。
64位linux安装32位oracle时,netca报错
64位的centos操作系统,安装10201_database_linux32.zip。
这一步顺利完成:$./runInstaller -silent -noconfig -ignoreSysPrereqs -responseFile /home/oracle/database/response/myenterprise.rsp
接下来的这步出错:$netca /silent /responsefile /home/oracle/database/response/netca.rsp
提示:UnsatisfiedLinkError exception loading native library: njni10
java.lang.UnsatisfiedLinkError: jniGetOracleHome
& && &&&at mon.NetGetEnv.jniGetOracleHome(Native Method)
& && &&&at mon.NetGetEnv.getOracleHome(Unknown Source)
& && &&&at oracle.net.ca.NetCA.main(Unknown Source)
Oracle Net Services configuration failed.&&The exit code is -1在网上查,说要安装glibc和glibc-devel。但安装oracle之前已经安装了,还是如此。 #yum install glibc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-2.5-65.x86_64 already installed and latest version
Package glibc-2.5-65.i686 already installed and latest version
Nothing to do
# yum install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-devel-2.5-65.x86_64 already installed and latest version
Package glibc-devel-2.5-65.i386 already installed and latest version
Nothing to do
安装的包#rpm -q binutils gcc gcc-c++ glibc glibc-common libstdc++ libstdc++-devel make sysstat setarch libXp openmotif setarch compat-db
binutils-2.17.50.0.6-14.el5
gcc-4.1.2-51.el5
gcc-c++-4.1.2-51.el5
glibc-2.5-65
glibc-2.5-65
glibc-common-2.5-65
libstdc++-4.1.2-51.el5
libstdc++-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
make-3.81-3.el5
sysstat-7.0.2-11.el5
setarch-2.0-1.1
libXp-1.0.0-8.1.el5
libXp-1.0.0-8.1.el5
openmotif-2.3.1-5.el5_5.1
openmotif-2.3.1-5.el5_5.1
setarch-2.0-1.1
compat-db-4.2.52-5.1
compat-db-4.2.52-5.1
64位就安装64位oracle,出问题还不好查
将gcc 修改为32bit,然后relink,然后再netca
64位就安装64位oracle,出问题还不好查
wq4113 发表于
11:13 http://bbs.chinaunix.net/images/common/back.gif
& & 下载64位的oracle安装了,一样的错误。
将gcc 修改为32bit,然后relink,然后再netca
guyeh 发表于
11:16 http://bbs.chinaunix.net/images/common/back.gif
怎么修改?我下载了gcc-4.1.2-51.el5.i386.rpm安装,提示需要cpp和libgcc;又下载cpp-4.1.2-51.el5.i386.rpm和libgcc-4.1.2-51.el5.i386.rpm安装,提示和原来的cpp-4.1.2-50.el5.x86_64冲突。
数据库技术
综合交流区
站务及频道
查看完整版本:
64位linux安装32位oracle时,netca报错
64位的centos操作系统,安装10201_database_linux32.zip。
这一步顺利完成:$./runInstaller -silent -noconfig -ignoreSysPrereqs -responseFile /home/oracle/database/response/myenterprise.rsp
接下来的这步出错:$netca /silent /responsefile /home/oracle/database/response/netca.rsp
提示:UnsatisfiedLinkError exception loading native library: njni10
java.lang.UnsatisfiedLinkError: jniGetOracleHome
& && &&&at mon.NetGetEnv.jniGetOracleHome(Native Method)
& && &&&at mon.NetGetEnv.getOracleHome(Unknown Source)
& && &&&at oracle.net.ca.NetCA.main(Unknown Source)
Oracle Net Services configuration failed.&&The exit code is -1在网上查,说要安装glibc和glibc-devel。但安装oracle之前已经安装了,还是如此。 #yum install glibc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-2.5-65.x86_64 already installed and latest version
Package glibc-2.5-65.i686 already installed and latest version
Nothing to do
# yum install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* updates:
Setting up Install Process
Package glibc-devel-2.5-65.x86_64 already installed and latest version
Package glibc-devel-2.5-65.i386 already installed and latest version
Nothing to do
安装的包#rpm -q binutils gcc gcc-c++ glibc glibc-common libstdc++ libstdc++-devel make sysstat setarch libXp openmotif setarch compat-db
binutils-2.17.50.0.6-14.el5
gcc-4.1.2-51.el5
gcc-c++-4.1.2-51.el5
glibc-2.5-65
glibc-2.5-65
glibc-common-2.5-65
libstdc++-4.1.2-51.el5
libstdc++-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
libstdc++-devel-4.1.2-51.el5
make-3.81-3.el5
sysstat-7.0.2-11.el5
setarch-2.0-1.1
libXp-1.0.0-8.1.el5
libXp-1.0.0-8.1.el5
openmotif-2.3.1-5.el5_5.1
openmotif-2.3.1-5.el5_5.1
setarch-2.0-1.1
compat-db-4.2.52-5.1
compat-db-4.2.52-5.1
64位就安装64位oracle,出问题还不好查
将gcc 修改为32bit,然后relink,然后再netca
64位就安装64位oracle,出问题还不好查
wq4113 发表于
11:13 http://bbs.chinaunix.net/images/common/back.gif
& & 下载64位的oracle安装了,一样的错误。
将gcc 修改为32bit,然后relink,然后再netca
guyeh 发表于
11:16 http://bbs.chinaunix.net/images/common/back.gif
怎么修改?我下载了gcc-4.1.2-51.el5.i386.rpm安装,提示需要cpp和libgcc;又下载cpp-4.1.2-51.el5.i386.rpm和libgcc-4.1.2-51.el5.i386.rpm安装,提示和原来的cpp-4.1.2-50.el5.x86_64冲突。
64位操作系统安装64位oracle肯定不会出问题,如果有问题可以参考下面的办法:
1. cd /usr/bin (as root)
2. mv gcc gcc.2009
3. mv g++ g++.2009
4. ln -s gcc32 gcc
5. ln -s g++32 g++
6. login as oracle software owner (make sure environment is correct)
7. cd $ORACLE_HOME/bin
8. relink all
查看完整版本:6544人阅读
这篇文章是从我的另一个blog转过来的: /python23/&
zipfile是python里用来做zip格式编码的压缩和解压缩的,由于是很常见的zip格式,所以这个模块使用频率也是比较高的,在这里对zipfile的使用方法做一些记录。即方便自己也方便别人。 zipfile里有两个非常重要的class, 分别是ZipFile和ZipInfo, 在绝大多数的情况下,我们只需要使用这两个class就可以了。ZipFile是主要的类,用来创建和读取zip文件而ZipInfo是存储的zip文件的每个文件的信息的。 &&&
比如要读取一个zipfile,这里假设filename是一个文件的路径:
import&zipfilez&=&zipfile.ZipFile(filename,&'r')&#&这里的第二个参数用r表示是读取zip文件,w是创建一个zip文件for&f&in&z.namelist():&&&&print&f
上面的代码是读取一个zip压缩包里所有文件的名字。z.namelist() 会返回压缩包内所有文件名的列表。 再看看下面一个:
import&zipfilez&=&zipfile.ZipFile(filename,&'r')for&i&in&list():&&&&print&i.file_size,&i.header_offset
&&& 这里使用了z.infolist(), 它返回的就是压缩包内所有文件的信息,就是一个ZipInfo的列表。一个ZopInfo对象中包含了压缩包内一个文件的信息,其中比较常用的是 filename, file_size, header_offset, 分别为文件名,文件大小,文件数据在压缩包中的偏移。其实之前的z.namelist()就是读取的ZopInfo中的filename,组成一个 list返回的。 从压缩包里解压缩出一个文件的方法是使用ZipFile的read方法:
import&zipfilez&=&zipfile.ZipFile(filename,&'r')print&z.read(z.namelist()[0])
这样就读取出z.namelist()中的第一个文件,并且输出到屏幕,当然也可以把它存储到文件。
下面是创建zip压缩包的方法:
与读取的方法其实很类似的:
import&zipfile,&osz&=&zipfile.ZipFile(filename,&'w')&#&注意这里的第二个参数是w,这里的filename是压缩包的名字#假设要把一个叫testdir中的文件全部添加到压缩包里(这里只添加一级子目录中的文件):if&os.path.isdir(testdir):&&&&for&d&in&os.listdir(testdir):&&&&&&&&z.write(testdir+os.sep+d)#&close()&是必须调用的!z.close()
上面的代码非常的简单。 想想还有一个问题,如果我把一个test/111.txt 添加到压缩包里之后我希望在包里它放到test22/111.txt怎么办呢? 其实这个就是ZipFile的write方法中第二个参数的作用了。只需要这样调用:z.write(&test/111.txt&, &test22/111.txt&)&
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:180622次
积分:2334
积分:2334
排名:第6209名
原创:54篇
评论:44条
(1)(1)(1)(4)(21)(3)(5)(7)(4)(6)(1),下载次数:1 次
| 关键字:
Collections
Configuration
Diagnostics
Conversion
Converters
SharpZipLib
Encryption
Compression
Properties
Settings.settings[249B]
APIDemo.exe[1.43MB]
APIDemo.pdb[2.72MB]
APIDemo.vshost.exe[11KB]
APIDemo.vshost.exe.manifest[490B]
APIDemo.Properties.Resources.resources[180B]
APIDemo.csproj.FileListAbsolute.txt[1KB]
APIDemo.csproj.GenerateResource.Cache[789B]
APIDemo.exe[1.43MB]
APIDemo.pdb[2.72MB]
Properties
Settings.settings[249B]
TopSdk.dll[1.33MB]
taobaoAPI.exe[56KB]
taobaoAPI.pdb[115KB]
taobaoAPI.vshost.exe[11KB]
taobaoAPI.vshost.exe.manifest[490B]
topsdk.log[18KB]
taobaoAPI.Form1.resources[180B]
taobaoAPI.From淘宝库存.resources[180B]
taobaoAPI.Properties.Resources.resources[180B]
taobaoAPI.csproj.FileListAbsolute.txt[2KB]
taobaoAPI.csproj.GenerateResource.Cache[1KB]
taobaoAPI.exe[56KB]
taobaoAPI.pdb[115KB]
taobaoAPI.taobao商品.resources[180B]
taobaoAPI.taobao商品图片.resources[180B]
taobaoAPI.taobao商品库存分类.resources[180B]
taobaoAPI.taobao商品选择分类.resources[180B]
taobaoAPI.taobao更新商品.resources[180B]
taobaoAPI.taobao科目.resources[180B]
taobaoImage
5.jpg[5KB]
0.jpg[160KB]
8.jpg[333KB]
6.jpg[221KB]
taobaologs
File.Txt[72B]
Image.Txt[62B]
Log.Txt[0B]
SKu.Txt[20B]
from.gif[4KB]
taobaoAPI.sln[1KB]
最新Asp.Net源码下载.url[123B]
当前路径:APIDemo/Generated/SharpZipLib/Zip/ZipFile.cs
// ZipFile.cs
// Copyright (C) 2001 Mike Krueger
// Copyright (C) 2004 John Reilly
// This file was translated from java, it was part of the GNU Classpath
// Copyright (C) 2001 Free Software Foundation, Inc.
// This prog you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software F either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// alo if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// Linking this library statically or dynamically with other modules is
// making a combined work based on this library.
Thus, the terms and
// conditions of the GNU General Public License cover the whole
// combination.
// As a special exception, the copyright holders of this library give you
// permission to link this library with independent modules to produce an
// executable, regardless of the license terms of these independent
// modules, and to copy and distribute the resulting executable under
// terms of your choice, provided that you also meet, for each linked
// independent module, the terms and conditions of the license of that
// module.
An independent module is a module which is not derived from
// or based on this library.
If you modify this library, you may extend
// this exception to your version of the library, but you are not
// obligated to do so.
If you do not wish to do so, delete this
// exception statement from your version.
// HISTORY
Z-1649 Added AES support
Z-1650 Fixed updating ODT archives in memory. Exposed exceptions in updating.
Z-1663 Fixed exception when testing local header compressed size of -1
using System.C
using System.IO;
using System.T
using System.G
#if !NETCF_1_0
using System.Security.C
using ICSharpCode.SharpZipLib.E
using ICSharpCode.SharpZipLib.C
using ICSharpCode.SharpZipLib.C
using ICSharpCode.pression.S
using ICSharpCode.
namespace ICSharpCode.SharpZipLib.Zip
#region Keys Required Event Args
/// &summary&
/// Arguments used with KeysRequiredEvent
/// &/summary&
public class KeysRequiredEventArgs : EventArgs
#region Constructors
/// &summary&
/// Initialise a new instance of &see cref=&KeysRequiredEventArgs&&&/see&
/// &/summary&
/// &param name=&name&&The name of the file for which keys are required.&/param&
public KeysRequiredEventArgs(string name)
fileName =
/// &summary&
/// Initialise a new instance of &see cref=&KeysRequiredEventArgs&&&/see&
/// &/summary&
/// &param name=&name&&The name of the file for which keys are required.&/param&
/// &param name=&keyValue&&The current key value.&/param&
public KeysRequiredEventArgs(string name, byte[] keyValue)
fileName =
key = keyV
#endregion
#region Properties
/// &summary&
/// Gets the name of the file for which keys are required.
/// &/summary&
public string FileName
get { return fileN }
/// &summary&
/// Gets or sets the key value
/// &/summary&
public byte[] Key
set { key = }
#endregion
#region Instance Fields
string fileN
#endregion
#endregion
#region Test Definitions
/// &summary&
/// The strategy to apply to testing.
/// &/summary&
public enum TestStrategy
/// &summary&
/// Find the first error only.
/// &/summary&
FindFirstError,
/// &summary&
/// Find all possible errors.
/// &/summary&
FindAllErrors,
/// &summary&
/// The operation in progress reported by a &see cref=&ZipTestResultHandler&/& during testing.
/// &/summary&
/// &seealso cref=&ZipFile.TestArchive(bool)&&TestArchive&/seealso&
public enum TestOperation
/// &summary&
/// Setting up testing.
/// &/summary&
Initialising,
/// &summary&
/// Testing an individual entries header
/// &/summary&
EntryHeader,
/// &summary&
/// Testing an individual entries data
/// &/summary&
EntryData,
/// &summary&
/// Testing an individual entry has completed.
/// &/summary&
EntryComplete,
/// &summary&
/// Running miscellaneous tests
/// &/summary&
MiscellaneousTests,
/// &summary&
/// Testing is complete
/// &/summary&
/// &summary&
/// Status returned returned by &see cref=&ZipTestResultHandler&/& during testing.
/// &/summary&
/// &seealso cref=&ZipFile.TestArchive(bool)&&TestArchive&/seealso&
public class TestStatus
#region Constructors
/// &summary&
/// Initialise a new instance of &see cref=&TestStatus&/&
/// &/summary&
/// &param name=&file&&The &see cref=&ZipFile&/& this status applies to.&/param&
public TestStatus(ZipFile file)
#endregion
#region Properties
/// &summary&
/// Get the current &see cref=&TestOperation&/& in progress.
/// &/summary&
public TestOperation Operation
get { return operation_; }
/// &summary&
/// Get the &see cref=&ZipFile&/& this status is applicable to.
/// &/summary&
public ZipFile File
get { return file_; }
/// &summary&
/// Get the current/last entry tested.
/// &/summary&
public ZipEntry Entry
get { return entry_; }
/// &summary&
/// Get the number of errors detected so far.
/// &/summary&
public int ErrorCount
get { return errorCount_; }
/// &summary&
/// Get the number of bytes tested so far for the current entry.
/// &/summary&
public long BytesTested
get { return bytesTested_; }
/// &summary&
/// Get a value indicating wether the last entry test was valid.
/// &/summary&
public bool EntryValid
get { return entryValid_; }
#endregion
#region Internal API
internal void AddError()
errorCount_++;
entryValid_ =
internal void SetOperation(TestOperation operation)
operation_ =
internal void SetEntry(ZipEntry entry)
entryValid_ =
bytesTested_ = 0;
internal void SetBytesTested(long value)
bytesTested_ =
#endregion
#region Instance Fields
ZipFile file_;
ZipEntry entry_;
bool entryValid_;
int errorCount_;
long bytesTested_;
TestOperation operation_;
#endregion
/// &summary&
/// Delegate invoked during &see cref=&ZipFile.TestArchive(bool, TestStrategy, ZipTestResultHandler)&&testing&/see& if supplied indicating current progress and status.
/// &/summary&
/// &remarks&If the message is non-null an error has occured.
If the message is null
/// the operation as found in &see cref=&TestStatus&&status&/see& has started.&/remarks&
public delegate void ZipTestResultHandler(TestStatus status, string message);
#endregion
#region Update Definitions
/// &summary&
/// The possible ways of &see cref=&mitUpdate()&&applying updates&/see& to an archive.
/// &/summary&
public enum FileUpdateMode
/// &summary&
/// Perform all updates on temporary files ensuring that the original file is saved.
/// &/summary&
/// &summary&
/// Update the archive directly, which is faster but less safe.
/// &/summary&
#endregion
#region ZipFile Class
/// &summary&
/// This class represents a Zip archive.
You can ask for the contained
/// entries, or get an input stream for a file entry.
The entry is
/// automatically decompressed.
/// You can also update the archive adding or deleting entries.
/// This class is thread safe for input:
You can open input streams for arbitrary
/// entries in different threads.
/// &br/&Author of the original java version : Jochen Hoenicke
/// &/summary&
/// &example&
/// &code&
/// using S
/// using System.T
/// using System.C
/// using System.IO;
/// using ICSharpCode.SharpZipLib.Z
/// class MainClass
static public void Main(string[] args)
using (ZipFile zFile = new ZipFile(args[0])) {
Console.WriteLine(&Listing of : & + zFile.Name);
Console.WriteLine(&&);
Console.WriteLine(&Raw Size
Console.WriteLine(&--------
---------&);
foreach (ZipEntry e in zFile) {
if ( e.IsFile ) {
DateTime d = e.DateT
Console.WriteLine(&{0, -10}{1, -10}{2}
{4}&, e.Size, e.CompressedSize,
d.ToString(&dd-MM-yy&), d.ToString(&HH:mm&),
/// &/code&
/// &/example&
public class ZipFile : IEnumerable, IDisposable
#region KeyHandling
/// &summary&
/// Delegate for handling keys/password setting during compresion/decompression.
/// &/summary&
public delegate void KeysRequiredEventHandler(
object sender,
KeysRequiredEventArgs e
/// &summary&
/// Event handler for handling encryption keys.
/// &/summary&
public KeysRequiredEventHandler KeysR
/// &summary&
/// Handles getting of encryption keys when required.
/// &/summary&
/// &param name=&fileName&&The file for which encryption keys are required.&/param&
void OnKeysRequired(string fileName)
if (KeysRequired != null) {
KeysRequiredEventArgs krea = new KeysRequiredEventArgs(fileName, key);
KeysRequired(this, krea);
key = krea.K
/// &summary&
/// Get/set the encryption key value.
/// &/summary&
byte[] Key
set { key = }
#if !NETCF_1_0
/// &summary&
/// Password to be used for encrypting/decrypting files.
/// &/summary&
/// &remarks&Set to null if no password is required.&/remarks&
public string Password
if ( (value == null) || (value.Length == 0) ) {
rawPassword_ =
key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(value));
/// &summary&
/// Get a value indicating wether encryption keys are currently available.
/// &/summary&
bool HaveKeys
get { return key != }
#endregion
#region Constructors
/// &summary&
/// Opens a Zip file with the given name for reading.
/// &/summary&
/// &param name=&name&&The name of the file to open.&/param&
/// &exception cref=&ArgumentNullException&&The argument supplied is null.&/exception&
/// &exception cref=&IOException&&
/// An i/o error occurs
/// &/exception&
/// &exception cref=&ZipException&&
/// The file doesn&#39;t contain a valid zip archive.
/// &/exception&
public ZipFile(string name)
if ( name == null ) {
throw new ArgumentNullException(&name&);
baseStream_ = File.Open(name, FileMode.Open, FileAccess.Read, FileShare.Read);
isStreamOwner =
ReadEntries();
DisposeInternal(true);
/// &summary&
/// Opens a Zip file reading the given &see cref=&FileStream&/&.
/// &/summary&
/// &param name=&file&&The &see cref=&FileStream&/& to read archive data from.&/param&
/// &exception cref=&ArgumentNullException&&The supplied argument is null.&/exception&
/// &exception cref=&IOException&&
/// An i/o error occurs.
/// &/exception&
/// &exception cref=&ZipException&&
/// The file doesn&#39;t contain a valid zip archive.
/// &/exception&
public ZipFile(FileStream file)
if ( file == null ) {
throw new ArgumentNullException(&file&);
if ( !file.CanSeek ) {
throw new ArgumentException(&Stream is not seekable&, &file&);
baseStream_
name_ = file.N
isStreamOwner =
ReadEntries();
DisposeInternal(true);
/// &summary&
/// Opens a Zip file reading the given &see cref=&Stream&/&.
/// &/summary&
/// &param name=&stream&&The &see cref=&Stream&/& to read archive data from.&/param&
/// &exception cref=&IOException&&
/// An i/o error occurs
/// &/exception&
/// &exception cref=&ZipException&&
/// The stream doesn&#39;t contain a valid zip archive.&br/&
/// &/exception&
/// &exception cref=&ArgumentException&&
/// The &see cref=&Stream&&stream&/see& doesnt support seeking.
/// &/exception&
/// &exception cref=&ArgumentNullException&&
/// The &see cref=&Stream&&stream&/see& argument is null.
/// &/exception&
public ZipFile(Stream stream)
if ( stream == null ) {
throw new ArgumentNullException(&stream&);
if ( !stream.CanSeek ) {
throw new ArgumentException(&Stream is not seekable&, &stream&);
baseStream_
isStreamOwner =
if ( baseStream_.Length & 0 ) {
ReadEntries();
DisposeInternal(true);
entries_ = new ZipEntry[0];
isNewArchive_ =
/// &summary&
/// Initialises a default &see cref=&ZipFile&/& instance with no entries and no file storage.
/// &/summary&
internal ZipFile()
entries_ = new ZipEntry[0];
isNewArchive_ =
#endregion
#region Destructors and Closing
/// &summary&
/// Finalize this instance.
/// &/summary&
~ZipFile()
Dispose(false);
/// &summary&
/// Closes the ZipFile.
If the stream is &see cref=&IsStreamOwner&&owned&/see& then this also closes the underlying input stream.
/// Once closed, no further instance methods should be called.
/// &/summary&
/// &exception cref=&System.IO.IOException&&
/// An i/o error occurs.
/// &/exception&
public void Close()
DisposeInternal(true);
GC.SuppressFinalize(this);
#endregion
#region Creators
/// &summary&
/// Create a new &see cref=&ZipFile&/& whose data will be stored in a file.
/// &/summary&
/// &param name=&fileName&&The name of the archive to create.&/param&
/// &returns&Returns the newly created &see cref=&ZipFile&/&&/returns&
/// &exception cref=&ArgumentNullException&&&paramref name=&fileName&&&/paramref& is null&/exception&
public static ZipFile Create(string fileName)
if ( fileName == null ) {
throw new ArgumentNullException(&fileName&);
FileStream fs = File.Create(fileName);
ZipFile result = new ZipFile();
result.name_ = fileN
result.baseStream_ =
result.isStreamOwner =
/// &summary&
/// Create a new &see cref=&ZipFile&/& whose data will be stored on a stream.
/// &/summary&
/// &param name=&outStream&&The stream providing data storage.&/param&
/// &returns&Returns the newly created &see cref=&ZipFile&/&&/returns&
/// &exception cref=&ArgumentNullException&&&paramref name=&outStream&& is null&/paramref&&/exception&
/// &exception cref=&ArgumentException&&&paramref name=&outStream&& doesnt support writing.&/paramref&&/exception&
public static ZipFile Create(Stream outStream)
if ( outStream == null ) {
throw new ArgumentNullException(&outStream&);
if ( !outStream.CanWrite ) {
throw new ArgumentException(&Stream is not writeable&, &outStream&);
if ( !outStream.CanSeek ) {
throw new ArgumentException(&Stream is not seekable&, &outStream&);
ZipFile result = new ZipFile();
result.baseStream_ = outS
#endregion
#region Properties
/// &summary&
/// Get/set a flag indicating if the underlying stream is owned by the ZipFile instance.
/// If the flag is true then the stream will be closed when &see cref=&Close&&Close&/see& is called.
/// &/summary&
/// &remarks&
/// The default value is true in all cases.
/// &/remarks&
public bool IsStreamOwner
get { return isStreamO }
set { isStreamOwner = }
/// &summary&
/// Get a value indicating wether
/// this archive is embedded in another file or not.
/// &/summary&
public bool IsEmbeddedArchive
// Not strictly correct in all circumstances currently
get { return offsetOfFirstEntry & 0; }
/// &summary&
/// Get a value indicating that this archive is a new one.
/// &/summary&
public bool IsNewArchive
get { return isNewArchive_; }
/// &summary&
/// Gets the comment for the zip file.
/// &/summary&
public string ZipFileComment
get { return comment_; }
/// &summary&
/// Gets the name of this zip file.
/// &/summary&
public string Name
get { return name_; }
/// &summary&
/// Gets the number of entries in this zip file.
/// &/summary&
/// &exception cref=&InvalidOperationException&&
/// The Zip file has been closed.
/// &/exception&
[Obsolete(&Use the Count property instead&)]
public int Size
return entries_.L
/// &summary&
/// Get the number of entries contained in this &see cref=&ZipFile&/&.
/// &/summary&
public long Count
return entries_.L
/// &summary&
/// Indexer property for ZipEntries
/// &/summary&
[pilerServices.IndexerNameAttribute(&EntryByIndex&)]
public ZipEntry this[int index]
return (ZipEntry) entries_[index].Clone();
#endregion
#region Input Handling
/// &summary&
/// Gets an enumerator for the Zip entries in this Zip file.
/// &/summary&
/// &returns&Returns an &see cref=&IEnumerator&/& for this archive.&/returns&
/// &exception cref=&ObjectDisposedException&&
/// The Zip file has been closed.
/// &/exception&
public IEnumerator GetEnumerator()
if (isDisposed_) {
throw new ObjectDisposedException(&ZipFile&);
return new ZipEntryEnumerator(entries_);
/// &summary&
/// Return the index of the entry with a matching name
/// &/summary&
/// &param name=&name&&Entry name to find&/param&
/// &param name=&ignoreCase&&If true the comparison is case insensitive&/param&
/// &returns&The index position of the matching entry or -1 if not found&/returns&
/// &exception cref=&ObjectDisposedException&&
/// The Zip file has been closed.
/// &/exception&
public int FindEntry(string name, bool ignoreCase)
if (isDisposed_) {
throw new ObjectDisposedException(&ZipFile&);
// TODO: This will be slow as the next ice age for huge archives!
for (int i = 0; i & entries_.L i++) {
if (pare(name, entries_[i].Name, ignoreCase, CultureInfo.InvariantCulture) == 0) {
return -1;
/// &summary&
/// Searches for a zip entry in this archive with the given name.
/// String comparisons are case insensitive
/// &/summary&
/// &param name=&name&&
/// The name to find. May contain directory components separated by slashes (&#39;/&#39;).
/// &/param&
/// &returns&
/// A clone of the zip entry, or null if no entry with that name exists.
/// &/returns&
/// &exception cref=&ObjectDisposedException&&
/// The Zip file has been closed.
/// &/exception&
public ZipEntry GetEntry(string name)
if (isDisposed_) {
throw new ObjectDisposedException(&ZipFile&);
int index = FindEntry(name, true);
return (index &= 0) ? (ZipEntry) entries_[index].Clone() :
/// &summary&
/// Gets an input stream for reading the given zip entry data in an uncompressed form.
/// Normally the &see cref=&ZipEntry&/& should be an entry returned by GetEntry().
/// &/summary&
/// &param name=&entry&&The &see cref=&ZipEntry&/& to obtain a data &see cref=&Stream&/& for&/param&
/// &returns&An input &see cref=&Stream&/& containing data for this &see cref=&ZipEntry&/&&/returns&
/// &exception cref=&ObjectDisposedException&&
/// The ZipFile has already been closed
/// &/exception&
/// &exception cref=&ICSharpCode.SharpZipLib.Zip.ZipException&&
/// The compression method for the entry is unknown
/// &/exception&
/// &exception cref=&IndexOutOfRangeException&&
/// The entry is not found in the ZipFile
/// &/exception&
public Stream GetInputStream(ZipEntry entry)
if ( entry == null ) {
throw new ArgumentNullException(&entry&);
if ( isDisposed_ ) {
throw new ObjectDisposedException(&ZipFile&);
long index = entry.ZipFileI
if ( (index & 0) || (index &= entries_.Length) || (entries_[index].Name != entry.Name) ) {
index = FindEntry(entry.Name, true);
if (index & 0) {
throw new ZipException(&Entry cannot be found&);
return GetInputStream(index);
/// &summary&
/// Creates an input stream reading a zip entry
/// &/summary&
/// &param name=&entryIndex&&The index of the entry to obtain an input stream for.&/param&
/// &returns&
/// An input &see cref=&Stream&/& containing data for this &paramref name=&entryIndex&/&
/// &/returns&
/// &exception cref=&ObjectDisposedException&&
/// The ZipFile has already been closed
/// &/exception&
/// &exception cref=&ICSharpCode.SharpZipLib.Zip.ZipException&&
/// The compression method for the entry is unknown
/// &/exception&
/// &exception cref=&IndexOutOfRangeException&&
/// The entry is not found in the ZipFile
/// &/exception&
public Stream GetInputStream(long entryIndex)
if ( isDisposed_ ) {
throw new ObjectDisposedException(&ZipFile&);
long start = LocateEntry(entries_[entryIndex]);
CompressionMethod method = entries_[entryIndex].CompressionM
Stream result = new PartialInputStream(this, start, entries_[entryIndex].CompressedSize);
if (entries_[entryIndex].IsCrypted == true) {
#if NETCF_1_0
throw new ZipException(&decryption not supported for Compact Framework 1.0&);
result = CreateAndInitDecryptionStream(result, entries_[entryIndex]);
if (result == null) {
throw new ZipException(&Unable to decrypt this entry&);
switch (method) {
case CompressionMethod.Stored:
// read as is.
case CompressionMethod.Deflated:
// No need to worry about ownership and closing as underlying stream close does nothing.
result = new InflaterInputStream(result, new Inflater(true));
throw new ZipException(&Unsupported compression method & + method);
#endregion
#region Archive Testing
/// &summary&
/// Test an archive for integrity/validity
/// &/summary&
/// &param name=&testData&&Perform low level data Crc check&/param&
/// &returns&true if all tests pass, false otherwise&/returns&
/// &remarks&Testing will terminate on the first error found.&/remarks&
public bool TestArchive(bool testData)
return TestArchive(testData, TestStrategy.FindFirstError, null);
/// &summary&
/// Test an archive for integrity/validity
/// &/summary&
/// &param name=&testData&&Perform low level data Crc check&/param&
/// &param name=&strategy&&The &see cref=&TestStrategy&&&/see& to apply.&/param&
/// &param name=&resultHandler&&The &see cref=&ZipTestResultHandler&&&/see& handler to call during testing.&/param&
/// &returns&true if all tests pass, false otherwise&/returns&
/// &exception cref=&ObjectDisposedException&&The object has already been closed.&/exception&
public bool TestArchive(bool testData, TestStrategy strategy, ZipTestResultHandler resultHandler)
if (isDisposed_) {
throw new ObjectDisposedException(&ZipFile&);
TestStatus status = new TestStatus(this);
if ( resultHandler != null ) {
resultHandler(status, null);
HeaderTest test = testData ? (HeaderTest.Header | HeaderTest.Extract) : HeaderTest.H
bool testing =
int entryIndex = 0;
while ( testing && (entryIndex & Count) ) {
if ( resultHandler != null ) {
status.SetEntry(this[entryIndex]);
status.SetOperation(TestOperation.EntryHeader);
resultHandler(status, null);
TestLocalHeader(this[entryIndex], test);
catch(ZipException ex) {
status.AddError();
if ( resultHandler != null ) {
resultHandler(status,
string.Format(&Exception during test - &#39;{0}&#39;&, ex.Message));
if ( strategy == TestStrategy.FindFirstError ) {
if ( testing && testData && this[entryIndex].IsFile ) {
if ( resultHandler != null ) {
status.SetOperation(TestOperation.EntryData);
resultHandler(status, null);
Crc32 crc = new Crc32();
using (Stream entryStream = this.GetInputStream(this[entryIndex]))
byte[] buffer = new byte[4096];
long totalBytes = 0;
int bytesR
while ((bytesRead = entryStream.Read(buffer, 0, buffer.Length)) & 0)
crc.Update(buffer, 0, bytesRead);
if (resultHandler != null)
totalBytes += bytesR
status.SetBytesTested(totalBytes);
resultHandler(status, null);
if (this[entryIndex].Crc != crc.Value) {
status.AddError();
if ( resultHandler != null ) {
resultHandler(status, &CRC mismatch&);
if ( strategy == TestStrategy.FindFirstError ) {
if (( this[entryIndex].Flags & (int)GeneralBitFlags.Descriptor) != 0 ) {
ZipHelperStream helper = new ZipHelperStream(baseStream_);
DescriptorData data = new DescriptorData();
helper.ReadDataDescriptor(this[entryIndex].LocalHeaderRequiresZip64, data);
if (this[entryIndex].Crc != data.Crc) {
status.AddError();
if (this[entryIndex].CompressedSize != pressedSize) {
status.AddError();
if (this[entryIndex].Size != data.Size) {
status.AddError();
if ( resultHandler != nu...

我要回帖

更多关于 同步助手2.2.3 的文章

 

随机推荐