mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a00b9074aa | ||
|
|
0ebcdf59d3 |
No files matched your search
@@ -1,81 +1,3 @@
|
||||
|
||||
Mon Jun 14 18:38:34 CEST 2004 Paolo Molaro <[email protected]>
|
||||
|
||||
* configure.in: better explain that --with-nptl is not related to
|
||||
NPTL, but to __thread support. Set sigaltstack support to off by
|
||||
default.
|
||||
|
||||
2004-06-12 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (populate-runtime-subdir): Add _tmpinst directory
|
||||
to the PATH.
|
||||
|
||||
2004-06-11 Jackson Harper <[email protected]>
|
||||
|
||||
* runtime/net_2_0/Makefile.am:
|
||||
* runtime/net_1_1/Makefile.am: Remove signing patches
|
||||
|
||||
2004-06-11 Jackson Harper <[email protected]>
|
||||
|
||||
* man/mono.1: Add documentation for MONO_GAC_PREFIX.
|
||||
* runtime/net_2_0/Makefile.am:
|
||||
* runtime/net_1_1/Makefile.am: Sign assemblies before
|
||||
installing. Do not sign ziplib, npgsql, or nunit assemblies. Sign mscorlib.
|
||||
|
||||
2004-06-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (populate-runtime-subdir): New target. Does a
|
||||
controlled "make install" in the 'mcs/' directory to populate the
|
||||
'runtime' directory.
|
||||
(fasterstrap): Use it.
|
||||
|
||||
2004-06-10 Raja R Harinath <[email protected]>
|
||||
|
||||
* runtime/Makefile.am ($(monoone_DATA),$(monotwo_DATA),$(monobins_DATA)):
|
||||
Don't copy from prefix. Use $(LN_S) to point to the mcs/ tree.
|
||||
* runtime/net_1_1/Makefile.am (mscorlib.dll,$(gac_assemblies)):
|
||||
Use $(LN_S) to point to the mcs/ tree, rather than copying.
|
||||
* runtime/net_2_0/Makefile.am (mscorlib.dll,$(gac_assemblies)): Likewise.
|
||||
|
||||
2004-06-10 Raja R Harinath <[email protected]>
|
||||
|
||||
Support the new assembly signing setup in mcs/.
|
||||
* Makefile.am (mcs-do-basic-build): Pass 'USE_BOOT_COMPILE' to sub-makes.
|
||||
($(tmpinst)/etc/mono/machine.config): New target.
|
||||
(tmpinst-dir.stamp): Remove and rewrite into ...
|
||||
($(tmpinst)/bin/mcs): ... this and ...
|
||||
($(tmpinst)/bin/mono): ... this. Update to use the in-tree machine.config.
|
||||
(tmpinst-dir): Rewrite to invoke above $(tmpinst)/... targets directly.
|
||||
* configure.in (AC_PROG_LN_S): New check to define $(LN_S).
|
||||
|
||||
Thu Jun 3 14:39:17 CEST 2004 Paolo Molaro <[email protected]>
|
||||
|
||||
* configure.in: libc setting for NetBSD (patch from [email protected]).
|
||||
|
||||
2004-06-01 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (bootstrap,faststrap,fasterstrap): Refactor.
|
||||
Fix 'faststrap' to be corlib-version-change-safe.
|
||||
(one-stage-strap,two-stage-strap,three-stage-strap): Remove.
|
||||
(monolite-bootstrap): Update.
|
||||
|
||||
2004-05-31 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* configure.in: fixlets for windows.
|
||||
|
||||
2004-05-29 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: export CC instead of passing it to libgc/configure.
|
||||
|
||||
2004-05-28 Duncan Mak <[email protected]>
|
||||
|
||||
* runtime/Makefile.am:
|
||||
* scripts/Makefile.am: Include mono-find-provides and
|
||||
mono-find-requires.
|
||||
|
||||
* scripts/mono-find-provides.in:
|
||||
* scripts/mono-find-requires.in: New wrapper scripts.
|
||||
|
||||
2004-05-27 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: Pass CC to libgc configure.
|
||||
|
||||
+82
-94
@@ -1,5 +1,4 @@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I .
|
||||
|
||||
SUBDIRS = @libgc_dir@ mono @ikvm_jni_dir@ docs runtime scripts man data samples support web
|
||||
|
||||
@@ -18,16 +17,16 @@ endif
|
||||
DISTCLEANFILES= mono.pc mint.pc
|
||||
|
||||
#
|
||||
# The following targets are used to compile and install
|
||||
# The following target is used to compile and install
|
||||
# mono and mcs without running into the out-of-sync
|
||||
# problems by doing the compilation in the right order.
|
||||
#
|
||||
|
||||
mcs_topdir=$(top_srcdir)/../mcs
|
||||
|
||||
.PHONY: bootstrap faststrap fasterstrap bootstrap-clean bootstrap-check get-monolite-latest monolite-bootstrap
|
||||
.PHONY: tmpinst-dir tmpinst-mcs-basic-build tmpinst-mcs-short-build tmpinst-mcs-full-build tmpinst-monolite
|
||||
.PHONY: mono-do-runtime-only mcs-do-basic-build mcs-do-short-build mcs-do-full-build mcs-do-clean-profiles mcs-do-run-test
|
||||
.PHONY: tmpinst-dir tmpinst-basic-build tmpinst-short-build tmpinst-full-build
|
||||
.PHONY: bootstrap faststrap fasterstrap one-stage-strap two-stage-strap three-stage-strap bootstrap-clean bootstrap-check
|
||||
.PHONY: mono-do-basic-build mcs-do-basic-build mcs-do-short-build mcs-do-full-build mcs-do-clean-profiles mcs-do-run-test
|
||||
|
||||
if USE_JIT
|
||||
mono_runtime = mono/mini/mono
|
||||
@@ -35,99 +34,74 @@ else
|
||||
mono_runtime = mono/interpreter/mint
|
||||
endif
|
||||
|
||||
# Minimal set of directories to build, and files used to run the 'mcs' compiler
|
||||
MCS_BASIC_DIRS = jay mcs class/corlib class/System
|
||||
MCS_BASIC_FILES = \
|
||||
$(mcs_topdir)/mcs/mcs.exe \
|
||||
$(mcs_topdir)/class/lib/default/mscorlib.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.dll
|
||||
bootstrap: three-stage-strap
|
||||
|
||||
# Set of directories and files the 'mcs' compiler can use
|
||||
## We build class/System twice to resolve the cyclic dependency of class/System.XML
|
||||
MCS_DIRS = $(MCS_BASIC_DIRS) class/System.XML class/System class/Mono.CSharp.Debugger
|
||||
MCS_FILES = $(MCS_BASIC_FILES) \
|
||||
$(mcs_topdir)/class/lib/default/System.Xml.dll \
|
||||
$(mcs_topdir)/class/lib/default/Mono.CSharp.Debugger.dll
|
||||
faststrap: mono-do-basic-build
|
||||
$(MAKE) two-stage-strap
|
||||
|
||||
tmpinst = _tmpinst
|
||||
fasterstrap: mono-do-basic-build
|
||||
$(MAKE) one-stage-strap
|
||||
|
||||
bootstrap: tmpinst-mcs-basic-build mono-do-runtime-only
|
||||
$(MAKE) tmpinst-mcs-short-build
|
||||
$(MAKE) fasterstrap
|
||||
three-stage-strap: tmpinst-basic-build
|
||||
$(MAKE) two-stage-strap
|
||||
|
||||
faststrap: tmpinst-mcs-short-build
|
||||
$(MAKE) mono-do-runtime-only
|
||||
$(MAKE) fasterstrap
|
||||
two-stage-strap: tmpinst-short-build
|
||||
$(MAKE) one-stage-strap
|
||||
|
||||
.PHONY: populate-runtime-subdir
|
||||
## *** warning ***: tested only with GNU make
|
||||
populate-runtime-subdir:
|
||||
srcdir=`cd $(srcdir) && pwd`; tmpinst=`pwd`/$(tmpinst) ; \
|
||||
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
|
||||
cd $(mcs_topdir) \
|
||||
&& $(MAKE) PROGRAM_INSTALL_DIR=$$srcdir/runtime LIBRARY_INSTALL_DIR=$$srcdir/runtime/net_1_1 prefix=$$tmpinst/prefix PROFILE=default install \
|
||||
&& $(MAKE) PROGRAM_INSTALL_DIR=$$srcdir/runtime LIBRARY_INSTALL_DIR=$$srcdir/runtime/net_2_0 prefix=$$tmpinst/prefix PROFILE=net_2_0 install
|
||||
test -z "`find $(tmpinst)/prefix -name '*.dll'`"
|
||||
test -z "`find $(tmpinst)/prefix -name '*.exe'`"
|
||||
set fnord `find $(tmpinst)/prefix -type f | wc -l` ; test "$$2" = 9
|
||||
rm -rf $(tmpinst)/prefix
|
||||
|
||||
fasterstrap: tmpinst-mcs-full-build
|
||||
$(MAKE) populate-runtime-subdir
|
||||
one-stage-strap: tmpinst-full-build
|
||||
rm -f $(top_srcdir)/runtime/*/*.dll $(top_srcdir)/runtime/*.exe
|
||||
$(MAKE)
|
||||
|
||||
bootstrap-clean: clean mcs-do-clean-profiles
|
||||
bootstrap-check: check mcs-do-run-test
|
||||
|
||||
# building with monolite
|
||||
# (takes advantage of 'make -j': independent subtasks are separate dependencies)
|
||||
tmpinst-basic-build: mcs-do-basic-build mono-do-basic-build tmpinst-dir
|
||||
mv -f $(mcs_topdir)/mcs/mcs.exe \
|
||||
$(mcs_topdir)/class/lib/default/mscorlib.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.dll \
|
||||
_tmpinst/lib
|
||||
|
||||
get-monolite-latest:
|
||||
wget -O $(srcdir)/../monolite-latest.tar.gz http://www.go-mono.com/daily/monolite-latest.tar.gz
|
||||
tmpinst-short-build: mcs-do-short-build
|
||||
mv -f $(mcs_topdir)/mcs/mcs.exe \
|
||||
$(mcs_topdir)/class/lib/default/mscorlib.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.Xml.dll \
|
||||
$(mcs_topdir)/class/lib/default/Mono.CSharp.Debugger.dll \
|
||||
_tmpinst/lib
|
||||
|
||||
monolite-bootstrap: tmpinst-monolite mono-do-runtime-only
|
||||
rm -f $(MCS_FILES)
|
||||
$(MAKE) tmpinst-mcs-short-build
|
||||
$(MAKE) fasterstrap
|
||||
|
||||
# internal targets
|
||||
|
||||
tmpinst-mcs-basic-build: mcs-do-basic-build tmpinst-dir
|
||||
mv -f $(MCS_BASIC_FILES) $(tmpinst)/lib
|
||||
|
||||
tmpinst-mcs-short-build: mcs-do-short-build tmpinst-dir
|
||||
mv -f $(MCS_FILES) $(tmpinst)/lib
|
||||
|
||||
tmpinst-mcs-full-build: mcs-do-full-build tmpinst-dir
|
||||
cp -f $(MCS_FILES) $(tmpinst)/lib
|
||||
|
||||
tmpinst-monolite: tmpinst-dir
|
||||
-rm -f $(tmpinst)/lib/mcs.exe $(tmpinst)/lib/*.dll
|
||||
-rm -fr $(tmpinst)/monolite-*
|
||||
srcdir=`cd $(srcdir) && pwd` && cd $(tmpinst) && ( gzip -d -c $$srcdir/../monolite-latest.tar.gz | tar xf - )
|
||||
mv -f $(tmpinst)/monolite-*/mcs.exe $(tmpinst)/monolite-*/*.dll $(tmpinst)/lib
|
||||
rm -fr $(tmpinst)/monolite-*
|
||||
tmpinst-full-build: mcs-do-full-build
|
||||
cp -f $(mcs_topdir)/mcs/mcs.exe \
|
||||
$(mcs_topdir)/class/lib/default/mscorlib.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.Xml.dll \
|
||||
$(mcs_topdir)/class/lib/default/Mono.CSharp.Debugger.dll \
|
||||
_tmpinst/lib
|
||||
|
||||
# Build enough of 'mono' to run the stage1 mcs.exe
|
||||
mono-do-runtime-only: $(CONFIG_HEADER)
|
||||
for dir in $(libgc_dir) mono data; do \
|
||||
(cd $$dir && $(MAKE)) || exit 1 ; \
|
||||
done
|
||||
mono-do-basic-build: $(CONFIG_HEADER)
|
||||
if test -z "$(libgc_dir)"; then :; else cd libgc && $(MAKE) ; fi
|
||||
cd mono && $(MAKE)
|
||||
|
||||
mcs-do-basic-build:
|
||||
rm -f $(MCS_FILES)
|
||||
for dir in $(MCS_BASIC_DIRS); do \
|
||||
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default USE_BOOT_COMPILE=yes BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB") || exit 1 ; \
|
||||
done
|
||||
# Build stripped down versions of 'mcs', 'mscorlib.dll' and 'System.dll' with installed 'mcs'
|
||||
## remove System.Xml.dll since it's a soft-dependency of System.dll
|
||||
mcs-do-basic-build:
|
||||
rm -f $(mcs_topdir)/mcs/mcs.exe $(mcs_topdir)/class/lib/default/mscorlib.dll
|
||||
rm -f $(mcs_topdir)/class/lib/default/System.dll $(mcs_topdir)/class/lib/default/System.Xml.dll
|
||||
cd $(mcs_topdir)/jay && $(MAKE)
|
||||
cd $(mcs_topdir)/mcs && $(MAKE) PROFILE=default BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB"
|
||||
cd $(mcs_topdir)/class/corlib && $(MAKE) PROFILE=default BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB"
|
||||
cd $(mcs_topdir)/class/System && $(MAKE) PROFILE=default BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB"
|
||||
|
||||
mcs-do-short-build:
|
||||
tmpinst=`cd $(tmpinst) && pwd` ; \
|
||||
tmpinst=`cd _tmpinst && pwd` ; \
|
||||
PATH=$$tmpinst/bin:$$PATH; export PATH ; \
|
||||
for dir in $(MCS_DIRS); do \
|
||||
for dir in jay mcs class/corlib class/System class/System.XML class/System class/Mono.CSharp.Debugger; do \
|
||||
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default) || exit 1 ; \
|
||||
done
|
||||
|
||||
mcs-do-full-build:
|
||||
tmpinst=`cd $(tmpinst) && pwd` ; \
|
||||
tmpinst=`cd _tmpinst && pwd` ; \
|
||||
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
|
||||
cd $(mcs_topdir) && $(MAKE) all-profiles
|
||||
|
||||
@@ -135,30 +109,44 @@ mcs-do-clean-profiles:
|
||||
cd $(mcs_topdir) && $(MAKE) clean-profiles
|
||||
|
||||
mcs-do-run-test: tmpinst-dir
|
||||
tmpinst=`cd $(tmpinst) && pwd` ; \
|
||||
tmpinst=`cd _tmpinst && pwd` ; \
|
||||
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
|
||||
cd $(mcs_topdir) && $(MAKE) PROFILE=default run-test
|
||||
|
||||
tmpinst-dir:
|
||||
mkdir -p $(tmpinst) $(tmpinst)/bin $(tmpinst)/lib $(tmpinst)/etc/mono
|
||||
$(MAKE) $(tmpinst)/bin/mono $(tmpinst)/bin/mcs $(tmpinst)/etc/mono/machine.config
|
||||
tmpinst-dir.stamp: Makefile.am
|
||||
set -e ; \
|
||||
rootme=`pwd`; tmpinst=$$rootme/_tmpinst ; \
|
||||
mkdir -p $$tmpinst $$tmpinst/bin $$tmpinst/lib ; \
|
||||
echo '#! /bin/sh' > $$tmpinst/bin/mono ; \
|
||||
echo 'if test -z "$$MONO_PATH" ; then MONO_PATH="'"$$tmpinst/lib"'"' >> $$tmpinst/bin/mono ; \
|
||||
echo 'else MONO_PATH=$${MONO_PATH}:"'"$$tmpinst/lib"'" ; fi' >> $$tmpinst/bin/mono ; \
|
||||
echo 'export MONO_PATH' >> $$tmpinst/bin/mono ; \
|
||||
echo 'exec "'"$$rootme/libtool"'" --mode=execute "'"$$rootme/$(mono_runtime)"'" "$$@"' >> $$tmpinst/bin/mono ; \
|
||||
echo '#! /bin/sh' > $$tmpinst/bin/mcs ; \
|
||||
echo 'exec "'"$$tmpinst/bin/mono"'" "'"$$tmpinst/lib/mcs.exe"'" "$$@"' >> $$tmpinst/bin/mcs ; \
|
||||
chmod +x $$tmpinst/bin/mono $$tmpinst/bin/mcs
|
||||
echo "stamp" > $@
|
||||
|
||||
$(tmpinst)/bin/mono: $(srcdir)/Makefile.am
|
||||
echo '#! /bin/sh' > $@
|
||||
echo 'builddir="'`pwd`'"; tmpinst=$$builddir/$(tmpinst)' >> $@
|
||||
echo 'if test -z "$$MONO_PATH" ; then MONO_PATH=$$tmpinst/lib; else MONO_PATH=$${MONO_PATH}:$$tmpinst/lib ; fi' >> $@
|
||||
echo 'MONO_CFG_DIR=$$tmpinst/etc' >> $@
|
||||
echo 'export MONO_PATH MONO_CFG_DIR' >> $@
|
||||
echo 'exec "$$builddir/libtool" --mode=execute "$$builddir/$(mono_runtime)" --config "$$builddir/data/config" "$$@"' >> $@
|
||||
chmod +x $@
|
||||
tmpinst-dir: tmpinst-dir.stamp
|
||||
@if test -d _tmpinst; then :; else rm -f tmpinst-dir.stamp; $(MAKE) tmpinst-dir.stamp; fi
|
||||
|
||||
$(tmpinst)/bin/mcs: $(srcdir)/Makefile.am
|
||||
(t=`cd $(tmpinst) && pwd`; echo '#! /bin/sh'; echo 'exec "'"$$t/bin/mono"'" "'"$$t/lib/mcs.exe"'" "$$@"') > $@
|
||||
chmod +x $@
|
||||
|
||||
$(tmpinst)/etc/mono/machine.config: $(srcdir)/data/machine.config
|
||||
rm -f $@
|
||||
srcdir=`cd $(srcdir) && pwd`; cd $(tmpinst)/etc/mono && $(LN_S) $$srcdir/data/machine.config machine.config
|
||||
# building with monolite
|
||||
|
||||
get-monolite-latest:
|
||||
wget -O $(srcdir)/../monolite-latest.tar.gz http://www.go-mono.com/daily/monolite-latest.tar.gz
|
||||
|
||||
tmpinst-monolite: tmpinst-dir
|
||||
-rm -f _tmpinst/lib/mcs.exe _tmpinst/lib/*.dll
|
||||
-rm -fr _tmpinst/monolite-*
|
||||
srcdir=`cd $(srcdir) && pwd` && cd _tmpinst && ( gzip -d -c $$srcdir/../monolite-latest.tar.gz | tar xf - )
|
||||
mv -f _tmpinst/monolite-*/mcs.exe _tmpinst/monolite-*/*.dll _tmpinst/lib
|
||||
rm -fr _tmpinst/monolite-*
|
||||
|
||||
monolite-bootstrap: tmpinst-monolite mono-do-basic-build
|
||||
rm -f $(mcs_topdir)/mcs/mcs.exe $(mcs_topdir)/class/lib/default/mscorlib.dll
|
||||
rm -f $(mcs_topdir)/class/lib/default/System.dll $(mcs_topdir)/class/lib/default/System.Xml.dll Mono.CSharp.Debugger.dll
|
||||
$(MAKE) two-stage-strap
|
||||
|
||||
# Obsolete target -- don't use.
|
||||
.PHONY: fullbuild
|
||||
|
||||
+9
-22
@@ -1,11 +1,9 @@
|
||||
AC_INIT(README)
|
||||
AC_CANONICAL_SYSTEM
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,0.96)
|
||||
AM_INIT_AUTOMAKE(mono,0.92)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_LN_S
|
||||
|
||||
dnl
|
||||
dnl libgc checks
|
||||
dnl
|
||||
@@ -44,18 +42,12 @@ case "$host" in
|
||||
AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
|
||||
CC="gcc -mno-cygwin"
|
||||
HOST_CC="gcc"
|
||||
# So libgc configure gets -mno-cygwin
|
||||
export CC
|
||||
# latest libgc already defines GC_WIN32_THREADS
|
||||
# CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
|
||||
CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
|
||||
libdl=
|
||||
libgc_threads=win32
|
||||
gc_default=boehm
|
||||
with_nptl=no
|
||||
with_sigaltstack=no
|
||||
LN_S=cp
|
||||
|
||||
;;
|
||||
*-*-*netbsd*)
|
||||
platform_win32=no
|
||||
@@ -246,15 +238,14 @@ AC_SUBST(GMODULE_LIBS)
|
||||
|
||||
AC_ARG_WITH(gc, [ --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
|
||||
|
||||
# Enable support for fast thread-local storage
|
||||
# Some systems have broken support, so we allow to disable it.
|
||||
# This is misnamed: __thread support has no relation to NPTL,
|
||||
# but people already use it...
|
||||
AC_ARG_WITH(nptl, [ --with-nptl=yes,no enable/disable support for __thread support],[],[with_nptl=yes])
|
||||
# Enable support for NPTL only features like fast thread-local storage
|
||||
# We can't reliably detect nptl at compile & run time
|
||||
# so this option will stay until nptl becomes more widespread
|
||||
AC_ARG_WITH(nptl, [ --with-nptl=yes,no enable/disable support for NPTL],[],[with_nptl=yes])
|
||||
|
||||
# Enable support for using sigaltstack for SIGSEGV and stack overflow handling
|
||||
# This does not work on some platforms (bug #55253)
|
||||
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack],[],[with_sigaltstack=no])
|
||||
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack],[],[with_sigaltstack=yes])
|
||||
|
||||
# assembly bundle support, see metadata/make-bundle.pl for more info
|
||||
AC_ARG_WITH(bundle, [ --with-bundle=bundle_template],[
|
||||
@@ -326,7 +317,7 @@ esac
|
||||
|
||||
|
||||
# tell libgc/configure about what we want
|
||||
ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
|
||||
ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads CC=$CC"
|
||||
|
||||
AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
|
||||
AC_SUBST(LIBGC_CFLAGS)
|
||||
@@ -905,7 +896,6 @@ if test x$platform_win32 = xno; then
|
||||
AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
|
||||
fi
|
||||
else
|
||||
jdk_headers_found=no
|
||||
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
|
||||
AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
|
||||
fi
|
||||
@@ -957,7 +947,7 @@ case "{$target}" in
|
||||
dnl Win32 does not have /dev/random, they have their own method...
|
||||
|
||||
*-*-mingw*|*-*-cygwin*)
|
||||
ac_cv_have_dev_random=no
|
||||
ac_cv_have_dev_random = no
|
||||
;;
|
||||
|
||||
dnl Everywhere else, it's /dev/random
|
||||
@@ -1142,9 +1132,6 @@ case "$host" in
|
||||
libsuffix=".dylib"
|
||||
LIBC="libc.dylib"
|
||||
;;
|
||||
*-*-*netbsd*)
|
||||
LIBC="libc.so.12"
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(libsuffix)
|
||||
|
||||
@@ -1259,7 +1246,7 @@ echo "
|
||||
|
||||
GC: $gc
|
||||
ICU: $enable_icu
|
||||
__thread: $with_nptl
|
||||
NPTL: $with_nptl
|
||||
SIGALTSTACK: $with_sigaltstack
|
||||
Engine: $jit_status
|
||||
2.0 Alpha: $PREVIEW
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
type="System.Web.Configuration.CustomErrorsConfigHandler, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<section name="pages"
|
||||
type="System.Web.Configuration.PagesConfigurationHandler, System.Web, Version=1.0.5000.0, Culture=neutral" />
|
||||
<section name="clientTarget"
|
||||
type="System.Web.Configuration.ClientTargetSectionHandler, System.Web, Version=1.0.5000.0, Culture=neutral" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="system.net">
|
||||
<section name="settings"
|
||||
@@ -192,19 +190,6 @@
|
||||
</system.diagnostics>
|
||||
<system.drawing>
|
||||
</system.drawing>
|
||||
|
||||
<strongNames>
|
||||
<pubTokenMapping>
|
||||
<!-- ECMA key -->
|
||||
<map Token="b77a5c561934e089" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
<!-- Microsoft (final) key -->
|
||||
<map Token="b03f5f7f11d50a3a" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
<!-- Microsoft (Web Service Enhancement) key -->
|
||||
<map Token="31bf3856ad364e35" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
<!-- IBM (DB2 Data Provider) key -->
|
||||
<map Token="7c307b91aa13d208" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
</pubTokenMapping>
|
||||
</strongNames>
|
||||
</configuration>
|
||||
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
System.Object
|
||||
System.Exception
|
||||
System.ValueType
|
||||
System.Delegate
|
||||
System.MulticastDelegate
|
||||
System.Enum
|
||||
System.Activator
|
||||
System.ArgIterator
|
||||
System.__ComObject
|
||||
System.TypedReference
|
||||
System.Security.AllowPartiallyTrustedCallersAttribute
|
||||
System.Runtime.Serialization.Formatter
|
||||
System.Runtime.Serialization.FormatterConverter
|
||||
System.Runtime.Serialization.FormatterServices
|
||||
System.Runtime.Serialization.ObjectIDGenerator
|
||||
System.Runtime.Serialization.ObjectManager
|
||||
System.Reflection.ModuleResolveEventHandler
|
||||
System.Reflection.Pointer
|
||||
System.Globalization.CompareInfo
|
||||
System.Globalization.HebrewCalendar
|
||||
System.Globalization.HijriCalendar
|
||||
System.Globalization.JapaneseCalendar
|
||||
System.Globalization.KoreanCalendar
|
||||
System.Globalization.SortKey
|
||||
System.Globalization.StringInfo
|
||||
System.Globalization.TaiwanCalendar
|
||||
System.Globalization.TextElementEnumerator
|
||||
System.Globalization.TextInfo
|
||||
System.Globalization.ThaiBuddhistCalendar
|
||||
System.IO.IsolatedStorage.IsolatedStorageFile
|
||||
System.Reflection.Emit.MethodRental
|
||||
System.Runtime.CompilerServices.AccessedThroughPropertyAttribute
|
||||
System.Runtime.CompilerServices.CallConvCdecl
|
||||
System.Runtime.CompilerServices.CallConvStdcall
|
||||
System.Runtime.CompilerServices.CallConvThiscall
|
||||
System.Runtime.CompilerServices.CallConvFastcall
|
||||
System.Runtime.CompilerServices.CustomConstantAttribute
|
||||
System.Runtime.CompilerServices.DateTimeConstantAttribute
|
||||
System.Runtime.CompilerServices.DiscardableAttribute
|
||||
System.Runtime.CompilerServices.DecimalConstantAttribute
|
||||
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
|
||||
System.Runtime.CompilerServices.CompilerGlobalScopeAttribute
|
||||
System.Runtime.CompilerServices.IDispatchConstantAttribute
|
||||
System.Runtime.CompilerServices.IsVolatile
|
||||
System.Runtime.CompilerServices.IUnknownConstantAttribute
|
||||
System.Runtime.CompilerServices.RequiredAttributeAttribute
|
||||
System.Runtime.InteropServices.ArrayWithOffset
|
||||
System.Runtime.InteropServices.DispIdAttribute
|
||||
System.Runtime.InteropServices.ClassInterfaceType
|
||||
System.Runtime.InteropServices.ClassInterfaceAttribute
|
||||
System.Runtime.InteropServices.ComVisibleAttribute
|
||||
System.Runtime.InteropServices.LCIDConversionAttribute
|
||||
System.Runtime.InteropServices.ComRegisterFunctionAttribute
|
||||
System.Runtime.InteropServices.ComUnregisterFunctionAttribute
|
||||
System.Runtime.InteropServices.ProgIdAttribute
|
||||
System.Runtime.InteropServices.ImportedFromTypeLibAttribute
|
||||
System.Runtime.InteropServices.IDispatchImplType
|
||||
System.Runtime.InteropServices.IDispatchImplAttribute
|
||||
System.Runtime.InteropServices.ComSourceInterfacesAttribute
|
||||
System.Runtime.InteropServices.ComConversionLossAttribute
|
||||
System.Runtime.InteropServices.TypeLibTypeFlags
|
||||
System.Runtime.InteropServices.TypeLibFuncFlags
|
||||
System.Runtime.InteropServices.TypeLibVarFlags
|
||||
System.Runtime.InteropServices.TypeLibTypeAttribute
|
||||
System.Runtime.InteropServices.TypeLibFuncAttribute
|
||||
System.Runtime.InteropServices.TypeLibVarAttribute
|
||||
System.Runtime.InteropServices.ComImportAttribute
|
||||
System.Runtime.InteropServices.PreserveSigAttribute
|
||||
System.Runtime.InteropServices.ComAliasNameAttribute
|
||||
System.Runtime.InteropServices.AutomationProxyAttribute
|
||||
System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute
|
||||
System.Runtime.InteropServices.CoClassAttribute
|
||||
System.Runtime.InteropServices.ComEventInterfaceAttribute
|
||||
System.Runtime.InteropServices.COMException
|
||||
System.Runtime.InteropServices.ComMemberType
|
||||
System.Runtime.InteropServices.CurrencyWrapper
|
||||
System.Runtime.InteropServices.DispatchWrapper
|
||||
System.Runtime.InteropServices.ErrorWrapper
|
||||
System.Runtime.InteropServices.ExtensibleClassFactory
|
||||
System.Runtime.InteropServices.HandleRef
|
||||
System.Runtime.InteropServices.InvalidComObjectException
|
||||
System.Runtime.InteropServices.InvalidOleVariantTypeException
|
||||
System.Runtime.InteropServices.TypeLibImporterFlags
|
||||
System.Runtime.InteropServices.ExporterEventKind
|
||||
System.Runtime.InteropServices.ITypeLibExporterNotifySink
|
||||
System.Runtime.InteropServices.ITypeLibConverter
|
||||
System.Runtime.InteropServices.MarshalDirectiveException
|
||||
System.Runtime.InteropServices.ObjectCreationDelegate
|
||||
System.Runtime.InteropServices.RuntimeEnvironment
|
||||
System.Runtime.InteropServices.RegistrationServices
|
||||
System.Runtime.InteropServices.SafeArrayRankMismatchException
|
||||
System.Runtime.InteropServices.SafeArrayTypeMismatchException
|
||||
System.Runtime.InteropServices.SEHException
|
||||
System.Runtime.InteropServices.TypeLibConverter
|
||||
System.Runtime.InteropServices.BIND_OPTS
|
||||
System.Runtime.InteropServices.UCOMIBindCtx
|
||||
System.Runtime.InteropServices.UCOMIConnectionPointContainer
|
||||
System.Runtime.InteropServices.UCOMIConnectionPoint
|
||||
System.Runtime.InteropServices.UCOMIEnumMoniker
|
||||
System.Runtime.InteropServices.CONNECTDATA
|
||||
System.Runtime.InteropServices.UCOMIEnumConnections
|
||||
System.Runtime.InteropServices.UCOMIEnumConnectionPoints
|
||||
System.Runtime.InteropServices.UCOMIEnumString
|
||||
System.Runtime.InteropServices.UCOMIEnumVARIANT
|
||||
System.Runtime.InteropServices.FILETIME
|
||||
System.Runtime.InteropServices.UCOMIMoniker
|
||||
System.Runtime.InteropServices.UCOMIPersistFile
|
||||
System.Runtime.InteropServices.UCOMIRunningObjectTable
|
||||
System.Runtime.InteropServices.STATSTG
|
||||
System.Runtime.InteropServices.UCOMIStream
|
||||
System.Runtime.InteropServices.DESCKIND
|
||||
System.Runtime.InteropServices.BINDPTR
|
||||
System.Runtime.InteropServices.UCOMITypeComp
|
||||
System.Runtime.InteropServices.TYPEKIND
|
||||
System.Runtime.InteropServices.TYPEFLAGS
|
||||
System.Runtime.InteropServices.IMPLTYPEFLAGS
|
||||
System.Runtime.InteropServices.TYPEATTR
|
||||
System.Runtime.InteropServices.FUNCDESC
|
||||
System.Runtime.InteropServices.IDLFLAG
|
||||
System.Runtime.InteropServices.IDLDESC
|
||||
System.Runtime.InteropServices.PARAMFLAG
|
||||
System.Runtime.InteropServices.PARAMDESC
|
||||
System.Runtime.InteropServices.TYPEDESC
|
||||
System.Runtime.InteropServices.ELEMDESC
|
||||
System.Runtime.InteropServices.VARDESC
|
||||
System.Runtime.InteropServices.DISPPARAMS
|
||||
System.Runtime.InteropServices.EXCEPINFO
|
||||
System.Runtime.InteropServices.FUNCKIND
|
||||
System.Runtime.InteropServices.INVOKEKIND
|
||||
System.Runtime.InteropServices.CALLCONV
|
||||
System.Runtime.InteropServices.FUNCFLAGS
|
||||
System.Runtime.InteropServices.VARFLAGS
|
||||
System.Runtime.InteropServices.UCOMITypeInfo
|
||||
System.Runtime.InteropServices.SYSKIND
|
||||
System.Runtime.InteropServices.LIBFLAGS
|
||||
System.Runtime.InteropServices.TYPELIBATTR
|
||||
System.Runtime.InteropServices.UCOMITypeLib
|
||||
System.Runtime.InteropServices.UnknownWrapper
|
||||
System.Runtime.Remoting.IObjectHandle
|
||||
System.Runtime.Remoting.IRemotingTypeInfo
|
||||
System.Runtime.Remoting.IChannelInfo
|
||||
System.Runtime.Remoting.IEnvoyInfo
|
||||
System.Runtime.Remoting.RemotingConfiguration
|
||||
System.Runtime.Remoting.TypeEntry
|
||||
System.Runtime.Remoting.ActivatedClientTypeEntry
|
||||
System.Runtime.Remoting.ActivatedServiceTypeEntry
|
||||
System.Runtime.Remoting.WellKnownClientTypeEntry
|
||||
System.Runtime.Remoting.WellKnownServiceTypeEntry
|
||||
System.Runtime.Remoting.RemotingException
|
||||
System.Runtime.Remoting.ServerException
|
||||
System.Runtime.Remoting.RemotingTimeoutException
|
||||
System.Runtime.Remoting.RemotingServices
|
||||
System.Runtime.Remoting.InternalRemotingServices
|
||||
System.Runtime.Remoting.SoapServices
|
||||
System.Runtime.Remoting.Activation.UrlAttribute
|
||||
System.Runtime.Remoting.Messaging.IMessageSink
|
||||
System.Runtime.Remoting.Messaging.AsyncResult
|
||||
System.Runtime.Remoting.Messaging.CallContext
|
||||
System.Runtime.Remoting.Messaging.ILogicalThreadAffinative
|
||||
System.Runtime.Remoting.Messaging.InternalMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.IMethodCallMessage
|
||||
System.Runtime.Remoting.Messaging.MethodCallMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.HeaderHandler
|
||||
System.Runtime.Remoting.Messaging.IMessageCtrl
|
||||
System.Runtime.Remoting.Messaging.IRemotingFormatter
|
||||
System.Runtime.Remoting.Messaging.ReturnMessage
|
||||
System.Runtime.Remoting.Messaging.MethodCall
|
||||
System.Runtime.Remoting.Messaging.ConstructionCall
|
||||
System.Runtime.Remoting.Messaging.MethodResponse
|
||||
System.Runtime.Remoting.Messaging.ConstructionResponse
|
||||
System.Runtime.Remoting.Messaging.MethodReturnMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.OneWayAttribute
|
||||
System.Runtime.Remoting.Messaging.MessageSurrogateFilter
|
||||
System.Runtime.Remoting.Messaging.RemotingSurrogateSelector
|
||||
System.Runtime.Remoting.Contexts.CrossContextDelegate
|
||||
System.Runtime.Remoting.Contexts.ContextProperty
|
||||
System.Runtime.Remoting.Contexts.IContextPropertyActivator
|
||||
System.Runtime.Remoting.Contexts.IContributeClientContextSink
|
||||
System.Runtime.Remoting.Contexts.IContributeDynamicSink
|
||||
System.Runtime.Remoting.Contexts.IContributeEnvoySink
|
||||
System.Runtime.Remoting.Contexts.IContributeObjectSink
|
||||
System.Runtime.Remoting.Contexts.IContributeServerContextSink
|
||||
System.Runtime.Serialization.Formatters.InternalRM
|
||||
System.Runtime.Serialization.Formatters.InternalST
|
||||
System.Runtime.Serialization.Formatters.SoapMessage
|
||||
System.Runtime.Serialization.Formatters.SoapFault
|
||||
System.Runtime.Serialization.Formatters.ServerFault
|
||||
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
System.Security.Cryptography.CryptoConfig
|
||||
System.Security.Cryptography.KeyedHashAlgorithm
|
||||
System.Security.Cryptography.HMACSHA1
|
||||
System.Security.Cryptography.MACTripleDES
|
||||
System.Security.Cryptography.MaskGenerationMethod
|
||||
System.Security.Cryptography.PasswordDeriveBytes
|
||||
System.Security.Cryptography.PKCS1MaskGenerationMethod
|
||||
System.Security.Cryptography.RC2
|
||||
System.Security.Cryptography.RC2CryptoServiceProvider
|
||||
System.Security.Cryptography.RSACryptoServiceProvider
|
||||
System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter
|
||||
System.Security.Cryptography.RSAOAEPKeyExchangeFormatter
|
||||
System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter
|
||||
System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter
|
||||
System.Security.Cryptography.RSAPKCS1SignatureDeformatter
|
||||
System.Security.Cryptography.RSAPKCS1SignatureFormatter
|
||||
System.Security.Cryptography.SHA1Managed
|
||||
System.Security.Cryptography.TripleDES
|
||||
System.Security.Cryptography.TripleDESCryptoServiceProvider
|
||||
System.Security.Permissions.EnvironmentPermission
|
||||
System.Security.Permissions.FileDialogPermission
|
||||
System.Security.Permissions.IsolatedStorageFilePermission
|
||||
System.Security.Permissions.PrincipalPermissionAttribute
|
||||
System.Security.Permissions.SecurityPermissionAttribute
|
||||
System.Security.Permissions.PublisherIdentityPermissionAttribute
|
||||
System.Security.Permissions.PublisherIdentityPermission
|
||||
System.Security.Permissions.ReflectionPermission
|
||||
System.Security.Permissions.RegistryPermission
|
||||
System.Security.Permissions.PrincipalPermission
|
||||
System.Security.Permissions.SiteIdentityPermission
|
||||
System.Security.Permissions.StrongNameIdentityPermission
|
||||
System.Security.Permissions.StrongNamePublicKeyBlob
|
||||
System.Security.Permissions.UIPermission
|
||||
System.Security.Permissions.UrlIdentityPermission
|
||||
System.Security.Permissions.ZoneIdentityPermission
|
||||
System.Security.Policy.ApplicationDirectory
|
||||
System.Security.Policy.ApplicationDirectoryMembershipCondition
|
||||
System.Security.Policy.FirstMatchCodeGroup
|
||||
System.Security.Policy.Hash
|
||||
System.Security.Policy.HashMembershipCondition
|
||||
System.Security.Policy.NetCodeGroup
|
||||
System.Security.Policy.PermissionRequestEvidence
|
||||
System.Security.Policy.Publisher
|
||||
System.Security.Policy.PublisherMembershipCondition
|
||||
System.Security.Policy.Site
|
||||
System.Security.Policy.SiteMembershipCondition
|
||||
System.Security.Policy.StrongName
|
||||
System.Security.Policy.StrongNameMembershipCondition
|
||||
System.Security.Policy.UnionCodeGroup
|
||||
System.Security.Policy.Url
|
||||
System.Security.Policy.UrlMembershipCondition
|
||||
System.Security.Policy.Zone
|
||||
System.Security.Policy.ZoneMembershipCondition
|
||||
System.Security.Principal.WindowsIdentity
|
||||
System.Security.Principal.WindowsImpersonationContext
|
||||
System.Security.Principal.WindowsPrincipal
|
||||
System.Threading.CompressedStack
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<h1>Mono 1.0 Release Notes</h1>
|
||||
|
||||
<h2>What does Mono Include</h2>
|
||||
|
||||
<h2>Missing functionality</h2>
|
||||
|
||||
<p>COM support.
|
||||
|
||||
<p>EnterpriseServices are non-existant.
|
||||
|
||||
<p>Windows.Forms is only available as a preview, it is not
|
||||
completed nor stable.
|
||||
|
||||
<h3>Assembly: System.Drawing</h3>
|
||||
|
||||
<p>System.Drawing.Printing is not supported.
|
||||
+20
-28
@@ -238,10 +238,10 @@ Finally, namespaces can be specified using the N: prefix:
|
||||
Turns off the garbage collection in Mono. This should be only used
|
||||
for debugging purposes
|
||||
.TP
|
||||
.I "MONO_ASPNET_NODELETE"
|
||||
If set to any value, temporary source files generated by ASP.NET support
|
||||
classes will not be removed. They will be kept in the user's temporary
|
||||
directory.
|
||||
.I "MONO_PATH"
|
||||
Provides a search path to the runtime where to look for library files.
|
||||
Directories are separated by the platform path separator (colons on unix). Example:
|
||||
.B /home/username/lib:/usr/local/mono/lib
|
||||
.TP
|
||||
.I "MONO_CFG_DIR"
|
||||
If set, this variable overrides the default system configuration directory
|
||||
@@ -269,41 +269,18 @@ Windows I/O Emulation layer, and handles (files, events, mutexes,
|
||||
pipes) will not be shared across processes. Process creation is also
|
||||
disabled. This option is only available on Unix.
|
||||
.TP
|
||||
.I "MONO_EGD_SOCKET"
|
||||
For platforms that do not otherwise have a way of obtaining random bytes
|
||||
this can be set to the name of a file system socket on which an egd or
|
||||
prngd daemon is listening.
|
||||
.TP
|
||||
.I "MONO_EXTERNAL_ENCODINGS"
|
||||
If set, contains a colon-separated list of text encodings to try when
|
||||
turning externally-generated text (e.g. command-line arguments or
|
||||
filenames) into Unicode. The encoding names come from the list
|
||||
provided by iconv, and the special case "default_locale" which refers
|
||||
to the current locale's default encoding.
|
||||
.IP
|
||||
.TP
|
||||
When reading externally-generated text strings UTF-8 is tried first,
|
||||
and then this list is tried in order with the first successful
|
||||
conversion ending the search. When writing external text (e.g. new
|
||||
filenames or arguments to new processes) the first item in this list
|
||||
is used, or UTF-8 if the environment variable is not set.
|
||||
.TP
|
||||
.I "MONO_MANAGED_WATCHER"
|
||||
If set to any value, System.IO.FileSystemWatcher will use the default
|
||||
managed implementation (slow). If unset, mono will try to use FAM under
|
||||
Unix systems and native API calls on Windows, falling back to the
|
||||
managed implementation on error.
|
||||
.TP
|
||||
.I "MONO_PATH"
|
||||
Provides a search path to the runtime where to look for library files.
|
||||
Directories are separated by the platform path separator (colons on unix). Example:
|
||||
.B /home/username/lib:/usr/local/mono/lib
|
||||
.TP
|
||||
.I "MONO_GAC_PREFIX"
|
||||
Provides a prefix the runtime uses to look for Global Assembly Caches.
|
||||
Directories are separated by the platform path separator (colons on
|
||||
unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
|
||||
install. Or to the directory provided in the gacutil /gacdir command. Example:
|
||||
.B /home/username/.mono:/usr/local/mono/
|
||||
.TP
|
||||
.I "MONO_SHARED_DIR"
|
||||
If set its the directory where the ".wapi" handle state is stored.
|
||||
@@ -319,6 +296,21 @@ new and might have some bugs. Basically we recommend Managed XSLT
|
||||
solution, but if it contains some blocking bugs, then you can also
|
||||
use traditional libxslt. If you want to use msxsl:script, you have
|
||||
to select Managed XSLT.
|
||||
.TP
|
||||
.I "MONO_MANAGED_WATCHER"
|
||||
If set to any value, System.IO.FileSystemWatcher will use the default
|
||||
managed implementation (slow). If unset, mono will try to use FAM under
|
||||
Unix systems and native API calls on Windows, falling back to the
|
||||
managed implementation on error.
|
||||
.TP
|
||||
.I "MONO_CODEDOM_NODELETE"
|
||||
If set to any value, the C# CodeDom compiler will not remove the temporary
|
||||
source files generated.
|
||||
.TP
|
||||
.I "MONO_EGD_SOCKET"
|
||||
For platforms that do not otherwise have a way of obtaining random bytes
|
||||
this can be set to the name of a file system socket on which an egd or
|
||||
prngd daemon is listening.
|
||||
.SH FILES
|
||||
On Unix assemblies are loaded from the installation lib directory. If you set
|
||||
`prefix' to /usr, the assemblies will be located in /usr/lib. On
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
.\"
|
||||
.\" sn manual page.
|
||||
.\" Copyright 2003 Motus Technologies
|
||||
.\" Copyright 2004 Novell
|
||||
.\" Author:
|
||||
.\" Sebastien Pouliot <sebastien@ximian.com>
|
||||
.\" Sebastien Pouliot (spouliot@motus.com)
|
||||
.\"
|
||||
.TH Mono "sn"
|
||||
.SH NAME
|
||||
@@ -14,33 +13,24 @@ sn \- Digitally sign/verify/compare strongname on CLR assemblies.
|
||||
.SH DESCRIPTION
|
||||
Digitally sign, verify or compare, CLR assemblies using strongnames.
|
||||
.SH CONFIGURATION OPTIONS
|
||||
Configuration options are stored in the machine.config configuration file
|
||||
under /configuration/strongNames.
|
||||
.TP
|
||||
.I "-c provider"
|
||||
Change the default CSP (Crypto Service Provider). Currently not supported
|
||||
in Mono.
|
||||
Change the default CSP (Crypto Service Provider).
|
||||
.TP
|
||||
.I "-m [y|n]"
|
||||
Use a machine [y] key container or a user [n] key container. Currently not
|
||||
supported in Mono.
|
||||
Use a machine [y] key container or a user [n] key container.
|
||||
.TP
|
||||
.I "-Vl"
|
||||
List the verification options. The list is kept under /configuration/
|
||||
strongNames/verificationSettings in machine.config.
|
||||
List the verification options.
|
||||
.TP
|
||||
.I "-Vr assembly [userlist]"
|
||||
Exempt the specified assembly from verification for the specified user list.
|
||||
Currently not supported by sn, you must edit machine.config manually if you
|
||||
require this.
|
||||
.TP
|
||||
.I "-Vu assembly"
|
||||
Remove the exemption entry for the specified assembly. Currently not
|
||||
supported by sn, you must edit machine.config manually if you require this.
|
||||
Remove the exemption entry for the specified assembly.
|
||||
.TP
|
||||
.I "-Vx"
|
||||
Remove all exemptions entries. Currently not supported by sn, you must edit
|
||||
machine.config manually if you require this.
|
||||
Remove all exemptions entries.
|
||||
.SH CSP RELATED OPTIONS
|
||||
.TP
|
||||
.I "-d container"
|
||||
@@ -72,14 +62,11 @@ Compare if assembly1 and assembly are the same exception for their signature.
|
||||
This is done by comparing the hash of the metadata of both assembly.
|
||||
.TP
|
||||
.I "-k keypair.snk"
|
||||
Create a new strongname keypair (a 1024 bits RSA keypair) in the specified
|
||||
file.
|
||||
Create a new strongname keypair in the specified file.
|
||||
.TP
|
||||
.I "-R assembly keypair.snk"
|
||||
Resign the specified assembly using the specified strongname keypair file
|
||||
(SNK). You can only sign an assembly with the private key (SNK) that match
|
||||
the public key inside the assembly (unless it's public key token has been
|
||||
remapped in machine.config).
|
||||
(SNK).
|
||||
.TP
|
||||
.I "-Rc assembly container"
|
||||
Resign the specified assembly using the specified strongname container.
|
||||
@@ -96,10 +83,10 @@ Show the public key from the specified assembly.
|
||||
.I "-Tp assembly"
|
||||
Show the public key and the public key token from the specified assembly.
|
||||
.TP
|
||||
.I "-v assembly"
|
||||
.I "-V assembly"
|
||||
Verify the specified assembly signature.
|
||||
.TP
|
||||
.I "-vf assembly"
|
||||
.I "-Vf assembly"
|
||||
Verify the specified assembly signature (even if disabled).
|
||||
.SH HELP OPTIONS
|
||||
.TP
|
||||
@@ -117,35 +104,10 @@ Display convertion related help about this tool.
|
||||
.TP
|
||||
.I "-h sn", "-? sn"
|
||||
Display strongname related help about this tool.
|
||||
.SH CONFIGURATION FILE
|
||||
.TP
|
||||
Strongnames configuration is kept in "machine.config" file. Currently two
|
||||
features can be configured.
|
||||
.TP
|
||||
.I "/configuration/strongNames/pubTokenMapping"
|
||||
This mechanism let Mono remap a public key token, like the ECMA token, to
|
||||
another public key for verification. This is useful in two scenarios. First
|
||||
assemblies signed with the "ECMA key" needs to be verified by the "runtime"
|
||||
key (as the ECMA key isn't a public key). Second, many assemblies are signed
|
||||
with private keys that Mono can't use (e.g. System.Security.dll assembly).
|
||||
A new key cannot be used because it should change thr strongname (a new key
|
||||
pair would have a new public key which would produce a new token). Public
|
||||
key token remapping is the solution for both problems. Each token must be
|
||||
configured in a "map" entry similar to this one: <map Token="b77a5c561934e089"
|
||||
PublicKey="00..." />
|
||||
.TP
|
||||
.I "/configuration/strongNames/verificationSettings"
|
||||
It is often useful during development to use delay signed assemblies.
|
||||
Normally* the runtime wouldn't allow delay-signed assemblies to be loaded.
|
||||
This feature allows some delay-signed assemblies (based on their public key
|
||||
token, optionally assembly name and user name) to be used like they were
|
||||
fully signed assemblies. [*] Note that Mono 1.0 "runtime" doesn't validate
|
||||
strongname signatures so this option shouldn't be required in most scenarios.
|
||||
.SH AUTHOR
|
||||
Written by Sebastien Pouliot
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2003 Motus Technologies.
|
||||
Copyright (C) 2004 Novell.
|
||||
Released under BSD license.
|
||||
.SH MAILING LISTS
|
||||
Visit http://mail.ximian.com/mailman/mono-list for details.
|
||||
|
||||
@@ -50,7 +50,7 @@ Specifies the namespace of the XML schema element for which a class or a dataset
|
||||
Specifies the programming language to use for the generated code. The only supported languages are CS (C#) and VB (Visual Basic.NET).
|
||||
.TP
|
||||
.I "/generator:type,assembly" "/g:type,assembly"
|
||||
Indicates xsd.exe to use custom CodeDomProvider to generate code. The type name must be full name. Assembly name is a local file name that is going to be loaded. The specified Type must have the default constructor.
|
||||
Indicates xsd.exe to use custom CodeDomProvider to generate code. Type name must be full name. Assembly name is file name that xsd.exe tries to load.
|
||||
.TP
|
||||
.I "/outputdir:path" "/o:path"
|
||||
Specifies the directory where to generate the code or schemas.
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
2004-06-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (all-profiles, clean-profiles): Simplify slightly.
|
||||
|
||||
2004-06-05 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Makefile: added target run-test-ondotnet.
|
||||
|
||||
2004-05-26 Raja R Harinath <[email protected]>
|
||||
|
||||
* nunit20/util/Makefile (EXTRA_DISTFILES): Remove
|
||||
|
||||
+4
-6
@@ -19,19 +19,17 @@ test: platform-check profile-check test-recursive #test-local
|
||||
|
||||
run-test: run-test-recursive #run-test-local
|
||||
|
||||
run-test-ondotnet: run-test-ondotnet-recursive # run-test-ondotnet-local
|
||||
|
||||
clean: clean-recursive #clean-local
|
||||
|
||||
# fun specialty targets
|
||||
|
||||
all-profiles:
|
||||
$(MAKE) PROFILE=default all
|
||||
$(MAKE) PROFILE=net_2_0 all
|
||||
$(MAKE) PROFILE=default all || exit 1 ; \
|
||||
$(MAKE) PROFILE=net_2_0 all || exit 1 ;
|
||||
|
||||
clean-profiles:
|
||||
$(MAKE) PROFILE=default clean
|
||||
$(MAKE) PROFILE=net_2_0 clean
|
||||
$(MAKE) PROFILE=default clean || exit 1 ; \
|
||||
$(MAKE) PROFILE=net_2_0 clean || exit 1 ;
|
||||
|
||||
testcorlib:
|
||||
@cd class/corlib && $(MAKE) test run-test
|
||||
|
||||
+7
-12
@@ -1,12 +1,7 @@
|
||||
2004-06-11 Anirban Bhattacharjee <banirban@novell.com>
|
||||
* Makefile: Removed inclusion of rules.make from Makefile for two reasons :
|
||||
- This Makefile as of now has no dependency on rules.make what so ever
|
||||
- Because of inclusion of INTENAL_MBAS in rules.make it was causing confliction with existing INTERNAL_MBAS in this makefile and causing lots of tests to fail
|
||||
|
||||
2004-05-15 Rafael Teixeira ([email protected])
|
||||
* Makefile: corrected /libpath: compiler flag (parameter) to point to ../class/lib/default/ the new location of libraries
|
||||
|
||||
2004-03-16 Rafael Teixeira ([email protected])
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
2004-05-15 Rafael Teixeira (rafaelteixeira@hotmail.com)
|
||||
* Makefile: corrected /libpath: compiler flag (parameter) to point to ../class/lib/default/ the new location of libraries
|
||||
|
||||
2004-03-16 Rafael Teixeira ([email protected])
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
+7
-12
@@ -1,12 +1,7 @@
|
||||
2004-06-11 Anirban Bhattacharjee <banirban@novell.com>
|
||||
* Makefile: Removed inclusion of rules.make from Makefile for two reasons :
|
||||
- This Makefile as of now has no dependency on rules.make what so ever
|
||||
- Because of inclusion of INTENAL_MBAS in rules.make it was causing confliction with existing INTERNAL_MBAS in this makefile and causing lots of tests to fail
|
||||
|
||||
2004-05-15 Rafael Teixeira ([email protected])
|
||||
* Makefile: corrected /libpath: compiler flag (parameter) to point to ../class/lib/default/ the new location of libraries
|
||||
|
||||
2004-03-16 Rafael Teixeira ([email protected])
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
2004-05-15 Rafael Teixeira (rafaelteixeira@hotmail.com)
|
||||
* Makefile: corrected /libpath: compiler flag (parameter) to point to ../class/lib/default/ the new location of libraries
|
||||
|
||||
2004-03-16 Rafael Teixeira ([email protected])
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
@@ -1,34 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Module M
|
||||
Delegate Sub SD()
|
||||
sub f()
|
||||
End sub
|
||||
|
||||
Public Delegate Function SF(a as integer) as Integer
|
||||
Public Function f1(a as integer) as Integer
|
||||
return a
|
||||
End Function
|
||||
|
||||
Sub Main()
|
||||
dim d1 as SD
|
||||
d1 = new SD(AddressOf f)
|
||||
d1.Invoke()
|
||||
|
||||
dim d2 as SD
|
||||
d2 = AddressOf f
|
||||
d2.Invoke()
|
||||
|
||||
dim d3 as new SD(AddressOf f)
|
||||
d3.Invoke()
|
||||
|
||||
dim d4 as SF
|
||||
d4 = new SF(AddressOf f1)
|
||||
Dim i as Integer = d4.Invoke(10)
|
||||
if i <> 10 then
|
||||
Throw new System.Exception ("#A1, Unexpected result")
|
||||
end if
|
||||
|
||||
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,14 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Module M
|
||||
Delegate Sub SD()
|
||||
sub f(i as integer)
|
||||
End sub
|
||||
|
||||
|
||||
Sub Main()
|
||||
dim d1 as SD
|
||||
d1= new SD(AddressOf f)
|
||||
d1.Invoke()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,18 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Module M
|
||||
Delegate Sub SD()
|
||||
sub f()
|
||||
End sub
|
||||
|
||||
Public Delegate Function SF(a as integer) as Integer
|
||||
Public Function f1(a as integer) as Integer
|
||||
return a
|
||||
End Function
|
||||
|
||||
Sub Main()
|
||||
dim d1 as SD
|
||||
d1= new SD(AddressOf f1)
|
||||
d1.Invoke()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,27 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Public Event E
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH() Handles x.E
|
||||
Console.WriteLine("event called")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,28 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Delegate Sub EH()
|
||||
Public Event E as EH
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH() Handles x.E
|
||||
Console.WriteLine("event called")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,30 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Public Event E (ByVal i as integer)
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E(10)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH(i as Integer) Handles x.E
|
||||
Console.WriteLine("event called : " + i)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Delegate Sub EH(ByVal i as integer)
|
||||
Public Event E as EH
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E(10)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH(i as Integer) Handles x.E
|
||||
Console.WriteLine("event called : " + i)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Public Class C
|
||||
Public Event E()
|
||||
|
||||
Sub S()
|
||||
RaiseEvent E()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Module M
|
||||
Sub S1()
|
||||
Dim x As New C()
|
||||
AddHandler x.E, AddressOf EH
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH()
|
||||
Console.WriteLine("Event fired")
|
||||
End Sub
|
||||
|
||||
Sub Main()
|
||||
S1()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Delegate Sub EH()
|
||||
Public Event E as EH
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
Sub call_S()
|
||||
dim x as C = new C()
|
||||
AddHandler x.E, AddressOf xh
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub xh()
|
||||
Console.WriteLine("event called")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
+1
-4
@@ -6,10 +6,7 @@ INTERNAL_MBAS = $(TEST_RUNTIME) --debug ../mbas/mbas.exe --stacktrace $(COMPILER
|
||||
#INTERNAL_MBAS = vbc $(COMPILER_FLAGS)
|
||||
all: test-compiler-jit
|
||||
|
||||
# removed this cause INTERNAL_MBAS now getting set in
|
||||
# rules.make which is conflicting with this instance of
|
||||
# INTERNAL_MBAS
|
||||
#include ../build/rules.make
|
||||
include ../build/rules.make
|
||||
|
||||
DISTFILES = README.tests $(wildcard *.vb)
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
protected Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,17 +0,0 @@
|
||||
Class C1
|
||||
'property that do not override any other
|
||||
'property should not be declared 'notoverridable'
|
||||
|
||||
Public NotOverridable Property p() as Integer
|
||||
GET
|
||||
END GET
|
||||
|
||||
SET (val as Integer)
|
||||
End SET
|
||||
End Property
|
||||
|
||||
End Class
|
||||
Module OverrideC2
|
||||
Sub Main()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,19 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public WriteOnly Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,19 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public ReadOnly Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,11 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public MustOverride Property p() as Integer
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,15 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Public Struct s
|
||||
public MustOverride Property p() as Integer
|
||||
End Struct
|
||||
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,22 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Structure S
|
||||
private i as integer
|
||||
|
||||
protected Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
End Structure
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
+2
-18
@@ -132,14 +132,7 @@ PropertyA \
|
||||
PropertyB \
|
||||
PropertyC \
|
||||
PropertyD \
|
||||
PropertyE \
|
||||
DelegateA \
|
||||
EventA \
|
||||
EventB \
|
||||
EventC \
|
||||
EventD \
|
||||
EventE \
|
||||
EventF
|
||||
PropertyE
|
||||
|
||||
# All negetive test cases which should
|
||||
# fail during compilation goes here
|
||||
@@ -288,16 +281,7 @@ EnumC7 \
|
||||
PropertyC1 \
|
||||
PropertyC2 \
|
||||
PropertyC3 \
|
||||
PropertyC4 \
|
||||
PropertyC5 \
|
||||
PropertyC6 \
|
||||
PropertyC7 \
|
||||
PropertyC8 \
|
||||
PropertyC9 \
|
||||
PropertyC10 \
|
||||
PropertyC11 \
|
||||
DelegateC1 \
|
||||
DelegateC2
|
||||
PropertyC4
|
||||
|
||||
# All negetive test cases which should fail at
|
||||
# runtime goes here
|
||||
|
||||
@@ -1,112 +1,3 @@
|
||||
2004-06-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* platforms/linux.make (PLATFORM_CHANGE_SEPARATOR_CMD): Define to 'cat'.
|
||||
(PLATFORM_TWEAK_CORLIB_SOURCES): Remove.
|
||||
(platform-check): Avoid bash-ism.
|
||||
* library.make: Simplify uses of $(patsubst x,y,$(foo)) to $(foo:x=y).
|
||||
(core_sourcefile): Rename back to ...
|
||||
(sourcefile): ... this. Remove creation of redundant intermediate file.
|
||||
(response): Change test for optimization, now that
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD is unconditional. Combine with
|
||||
platform-exclude handling.
|
||||
(library_CLEAN_FILES): New variable to specify clean:-able files
|
||||
close to where they're defined.
|
||||
(test_response, btest_response): Simplify.
|
||||
* executable.make (response): Change test for optimization.
|
||||
(executable_CLEAN_FILES): New define.
|
||||
|
||||
2004-06-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (uninstall-local): Fix typo.
|
||||
|
||||
2004-06-11 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* library.make : HAVE_CS_TESTS fixie.
|
||||
|
||||
2004-06-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (HAVE_CS_TESTS, HAVE_VB_TESTS): Allow to be
|
||||
overriden. Useful if the tests sourcefile is generated.
|
||||
(TEST_COMPILE, BTEST_COMPILE): Allow these to be customized too.
|
||||
|
||||
* platforms/win32.make (PLATFORM_TWEAK_CORLIB_SOURCES): Remove.
|
||||
|
||||
Support enough features to build mscorlib.dll.
|
||||
* library.make (core_sourcefile): New renamed from $(sourcefile).
|
||||
(PLATFORM_excludes): Auto-detecting define that sees if
|
||||
$(LIBRARY).$(PLATFORM)-excludes file exists.
|
||||
(sourcefile): New. Possibly-built file that removes
|
||||
PLATFORM_excluded files from core_sourcefile.
|
||||
(test_against, test_dep): New. Allow the test assembly to be
|
||||
built against a different library.
|
||||
(test_lib): Allow makefile to override the name of the test
|
||||
assembly.
|
||||
(LIBRARY_INSTALL_DIR): If defined, switch to using $(INSTALL_LIB)
|
||||
rather than $(gacutil).
|
||||
(DISTFILES, dist-local): Use core_sourcefile.
|
||||
(clean-local): Remove sourcefile if it was generated.
|
||||
(test_lib, btest_lib): Depend on $(test_dep).
|
||||
|
||||
2004-06-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* library.make: fixed PLATFORM_CHANGE_SEPARATOR_CHAR on windows.
|
||||
|
||||
2004-06-09 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* library.make: Added support to fully sign assemblies when doing a
|
||||
"make install" (thanks to Jackson :-).
|
||||
|
||||
2004-06-09 Raja R Harinath <[email protected]>
|
||||
|
||||
Do away with stampfiles.
|
||||
Introduce support for VB test cases.
|
||||
* library.make (HAVE_CS_TESTS, HAVE_VB_TESTS): New auto-detecting
|
||||
defines.
|
||||
(stampfile, test_stampfile): Remove.
|
||||
(clean-local): Don't mention them.
|
||||
(test-local, run-test-local, run-test-ondotnet-local):
|
||||
Make unconditional.
|
||||
($(makefrag), $(test_makefrag)): Simplify.
|
||||
($(btest_lib)): New. Support for VB testcases.
|
||||
|
||||
2004-06-09 Raja R Harinath <[email protected]>
|
||||
|
||||
Partial support for writing Visual Basic source files.
|
||||
* rules.make (USE_MBAS_FLAGS,BASCOMPILE,INTERNAL_MBAS): New.
|
||||
* config-default.make (MBAS_FLAGS, DEFAULT_MBAS_FLAGS): New.
|
||||
* profiles/default.make (MBAS): New.
|
||||
|
||||
2004-06-09 Raja R Harinath <[email protected]>
|
||||
|
||||
Do away with stampfiles.
|
||||
* executable.make (stampfile): Remove.
|
||||
(clean-local): Remove mention of $(stampfile).
|
||||
(test-local, run-test-local, run-test-ondotnet-local):
|
||||
Make unconditional. Add dummy rule to prevent other makefiles
|
||||
from defining rules on these.
|
||||
($(PROGRAM)): Depend directly on $(BUILT_SOURCES).
|
||||
($(makefrag)): Simplify.
|
||||
|
||||
2004-06-03 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* README.makefiles : added description for run-test-ondotnet.
|
||||
|
||||
2004-06-03 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Makefile, executable.make, library.make, rules.make :
|
||||
Added new target "run-test-ondotnet" that works what "run-test"
|
||||
used to be on windows (i.e. tests our libs under MS.NET).
|
||||
|
||||
2004-06-01 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* platforms/win32.make : TEST_RUNTIME should be always mono we can't
|
||||
test our libs against MS.NET runtime. Think about internal call).
|
||||
|
||||
2004-05-30 Jackson Harper <[email protected]>
|
||||
|
||||
* library.make: Install to 2.0 package if building with the
|
||||
net_2_0 profile.
|
||||
|
||||
2004-05-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* library.make: reference nunti.core.dll and nunit.util.dll when
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ thisdir = build
|
||||
SUBDIRS =
|
||||
include ../build/rules.make
|
||||
|
||||
all-local install-local test-local run-test-local run-test-ondotnet-local clean-local uninstall-local:
|
||||
all-local install-local test-local run-test-local clean-local uninstall-local:
|
||||
|
||||
DISTFILES = \
|
||||
README.makefiles \
|
||||
|
||||
@@ -40,9 +40,6 @@ test-local: my_test_program.exe
|
||||
run-test-local:
|
||||
$(RUNTIME) my_test_program.exe
|
||||
|
||||
run-test-ondotnet-local:
|
||||
$(RUNTIME) my_test_program.exe
|
||||
|
||||
DISTFILES = myfile.txt my_test_source.cs
|
||||
|
||||
dist-local: dist-default
|
||||
@@ -52,7 +49,7 @@ my_test_program.exe: my_test_source.cs
|
||||
========================================
|
||||
|
||||
Each makefile follows the same pattern: it does some setup, includes
|
||||
the standard make rules, and provides rules for seven standard targets:
|
||||
the standard make rules, and provides rules for six standard targets:
|
||||
all, install, test, run-test, clean, and dist.
|
||||
|
||||
"Some setup" is defining two variables: $(thisdir) and
|
||||
@@ -60,7 +57,7 @@ $(SUBDIRS). $(thisdir) is the directory that the makefile lives in,
|
||||
relative to the top directory (ie, class/corlib) and $(SUBDIRS)
|
||||
defines the subdirectories that should be built in.
|
||||
|
||||
The seven targets do the following:
|
||||
The six targets do the following:
|
||||
|
||||
* all-local builds whatever someone would expect to be built
|
||||
when they just type 'make'. Most likely Foo.dll or Foo.exe
|
||||
@@ -78,8 +75,6 @@ target. The idea is that 'make run-test' from the toplevel should be
|
||||
able to proceed unsupervised and test everything that can be tested in
|
||||
such a manner.
|
||||
|
||||
* run-test-ondotnet-local is a variant of run-test-local. It is used only to validate if our tests themselves works fine under Microsoft runtime (on Windows). Basically, in this target, we should not use $(TEST_RUNTIME) to test our libraries.
|
||||
|
||||
* clean-local removes built files; 'make clean' should leave
|
||||
only files that go into a distribution tarball. (But it is not necessarily
|
||||
true that all files that go into a tarball need to be left after a make clean.)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
RUNTIME_FLAGS =
|
||||
TEST_HARNESS = $(topdir)/class/lib/nunit-console.exe
|
||||
MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)
|
||||
MBAS_FLAGS = $(PLATFORM_DEBUG_FLAGS)
|
||||
LIBRARY_FLAGS = /noconfig
|
||||
CFLAGS = -g -O2
|
||||
INSTALL = /usr/bin/install
|
||||
@@ -21,7 +20,6 @@ prefix = /usr/local
|
||||
# keep track of the default value
|
||||
|
||||
DEFAULT_MCS_FLAGS := $(MCS_FLAGS)
|
||||
DEFAULT_MBAS_FLAGS := $(MBAS_FLAGS)
|
||||
|
||||
# You shouldn't need to set these but might on a
|
||||
# weird platform.
|
||||
|
||||
+30
-16
@@ -8,17 +8,14 @@
|
||||
|
||||
base_prog = $(shell basename $(PROGRAM))
|
||||
sourcefile = $(base_prog).sources
|
||||
|
||||
ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
|
||||
response = $(sourcefile)
|
||||
else
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
response = $(depsdir)/$(base_prog).response
|
||||
executable_CLEAN_FILES += $(response)
|
||||
else
|
||||
response = $(sourcefile)
|
||||
endif
|
||||
|
||||
stampfile = $(depsdir)/$(base_prog).stamp
|
||||
makefrag = $(depsdir)/$(base_prog).makefrag
|
||||
pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
|
||||
executable_CLEAN_FILES += $(makefrag) $(pdb)
|
||||
|
||||
ifndef PROGRAM_INSTALL_DIR
|
||||
PROGRAM_INSTALL_DIR = $(prefix)/bin
|
||||
@@ -34,14 +31,16 @@ uninstall-local:
|
||||
-rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog)
|
||||
|
||||
clean-local:
|
||||
-rm -f *.exe $(BUILT_SOURCES) $(executable_CLEAN_FILES) $(CLEAN_FILES)
|
||||
-rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(pdb) $(stampfile) $(makefrag)
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
-rm -f $(response)
|
||||
endif
|
||||
|
||||
ifndef HAS_TEST
|
||||
test-local: $(PROGRAM)
|
||||
@:
|
||||
|
||||
run-test-local:
|
||||
@:
|
||||
run-test-ondotnet-local:
|
||||
@:
|
||||
endif
|
||||
|
||||
DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
|
||||
|
||||
@@ -51,21 +50,36 @@ dist-local: dist-default
|
||||
$(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
|
||||
done
|
||||
|
||||
# Changing makefile probably means changing the
|
||||
# sources, so let's be safe and add a Makefile dep
|
||||
|
||||
ifndef PROGRAM_COMPILE
|
||||
PROGRAM_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
|
||||
$(PROGRAM): $(makefrag) $(BUILT_SOURCES) $(response)
|
||||
$(PROGRAM): $(makefrag) $(response) $(stampfile)
|
||||
$(PROGRAM_COMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
|
||||
|
||||
# warning: embedded tab in the 'echo touch' line
|
||||
$(makefrag): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(PROGRAM): ,' $< > $@
|
||||
@echo "HAVE_MAKEFRAG = yes" >$@.new
|
||||
@echo "$(stampfile): $(BUILT_SOURCES) \\" >>[email protected]
|
||||
@cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>[email protected]
|
||||
@cat [email protected] |sed -e '$$s, \\$$,,' >$@
|
||||
@echo " touch \$$@" >>$@
|
||||
@rm -rf [email protected]
|
||||
|
||||
ifneq ($(response),$(sourcefile))
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
$(response): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@( $(PLATFORM_CHANGE_SEPARATOR_CMD) ) <$< >$@
|
||||
@cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
endif
|
||||
|
||||
-include $(makefrag)
|
||||
|
||||
ifndef HAVE_MAKEFRAG
|
||||
$(stampfile):
|
||||
touch $@
|
||||
endif
|
||||
|
||||
+70
-152
@@ -9,17 +9,10 @@
|
||||
# munge in the library name to keep the files from clashing.
|
||||
|
||||
sourcefile = $(LIBRARY).sources
|
||||
PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
|
||||
|
||||
ifndef PLATFORM_excludes
|
||||
ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
|
||||
response = $(sourcefile)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef response
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
|
||||
library_CLEAN_FILES += $(response)
|
||||
else
|
||||
response = $(sourcefile)
|
||||
endif
|
||||
|
||||
ifndef LIBRARY_NAME
|
||||
@@ -27,151 +20,76 @@ LIBRARY_NAME = $(LIBRARY)
|
||||
endif
|
||||
|
||||
makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
|
||||
stampfile = $(depsdir)/$(PROFILE)_$(LIBRARY).stamp
|
||||
the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
|
||||
the_pdb = $(the_lib:.dll=.pdb)
|
||||
library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb)
|
||||
the_pdb = $(patsubst %.dll,%.pdb,$(the_lib))
|
||||
|
||||
ifndef NO_TEST
|
||||
test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
|
||||
test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
|
||||
test_nunit_ref = $(test_nunit_dep:%=-r:%)
|
||||
library_CLEAN_FILES += TestResult.xml
|
||||
|
||||
ifndef test_against
|
||||
test_against = $(the_lib)
|
||||
test_dep = $(the_lib)
|
||||
endif
|
||||
|
||||
ifndef test_lib
|
||||
test_lib = $(LIBRARY:.dll=_test.dll)
|
||||
endif
|
||||
test_pdb = $(test_lib:.dll=.pdb)
|
||||
test_lib = $(patsubst %.dll,%_test.dll,$(LIBRARY))
|
||||
test_pdb = $(patsubst %.dll,%.pdb,$(test_lib))
|
||||
test_sourcefile = $(test_lib).sources
|
||||
test_response = $(depsdir)/$(PROFILE)_$(test_lib).response
|
||||
test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
|
||||
test_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
|
||||
library_CLEAN_FILES += $(test_lib) $(test_pdb) $(test_response) $(test_makefrag)
|
||||
|
||||
ifndef btest_lib
|
||||
btest_lib = $(LIBRARY:.dll=_btest.dll)
|
||||
endif
|
||||
btest_pdb = $(btest_lib:.dll=.pdb)
|
||||
btest_sourcefile = $(btest_lib).sources
|
||||
btest_response = $(depsdir)/$(btest_lib).response
|
||||
btest_makefrag = $(depsdir)/$(btest_lib).makefrag
|
||||
btest_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
|
||||
library_CLEAN_FILES += $(btest_lib) $(btest_pdb) $(btest_response) $(btest_makefrag)
|
||||
|
||||
ifndef HAVE_CS_TESTS
|
||||
HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
|
||||
endif
|
||||
ifndef HAVE_VB_TESTS
|
||||
HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
|
||||
endif
|
||||
|
||||
test_stampfile = $(depsdir)/$(PROFILE)_$(test_lib).stamp
|
||||
test_nunitfw = $(topdir)/class/lib/$(PROFILE)/nunit.framework.dll
|
||||
test_nunitcore = $(topdir)/class/lib/$(PROFILE)/nunit.core.dll
|
||||
test_nunitutil = $(topdir)/class/lib/$(PROFILE)/nunit.util.dll
|
||||
test_nunit_ref = -r:$(test_nunitfw) -r:$(test_nunitcore) -r:$(test_nunitutil)
|
||||
test_flags = /r:$(the_lib) $(test_nunit_ref) $(TEST_MCS_FLAGS)
|
||||
endif
|
||||
|
||||
gacutil = $(topdir)/tools/gacutil/gacutil.exe
|
||||
sn = $(topdir)/tools/security/sn.exe
|
||||
|
||||
PACKAGE = 1.0
|
||||
|
||||
ifeq ($(PROFILE), net_2_0)
|
||||
PACKAGE = 2.0
|
||||
PACKAGE = 1.1
|
||||
endif
|
||||
|
||||
all-local: $(the_lib)
|
||||
|
||||
install-local: $(the_lib) maybe-sign-lib
|
||||
|
||||
ifdef LIBRARY_INSTALL_DIR
|
||||
install-local:
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
|
||||
$(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
|
||||
|
||||
uninstall-local:
|
||||
-rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
|
||||
|
||||
else
|
||||
|
||||
install-local: $(gacutil)
|
||||
$(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package $(PACKAGE)
|
||||
install-local: $(the_lib) $(gacutil)
|
||||
$(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package 1.0
|
||||
|
||||
uninstall-local: $(gacutil)
|
||||
$(RUNTIME) $(gacutil) /u $(LIBRARY_NAME:.dll=)
|
||||
$(RUNTIME) $(gacutil) /u $$(basename $(the_lib) .dll) ; \
|
||||
|
||||
$(gacutil):
|
||||
cd $(topdir)/tools/gacutil && $(MAKE)
|
||||
|
||||
endif
|
||||
|
||||
maybe-sign-lib:
|
||||
ifndef NO_SIGN_ASSEMBLY
|
||||
maybe-sign-lib: $(sn)
|
||||
$(RUNTIME) $(sn) -q -R $(the_lib) $(topdir)/class/mono.snk
|
||||
endif
|
||||
|
||||
$(sn):
|
||||
cd $(topdir)/tools/security && $(MAKE) sn.exe
|
||||
cd $(topdir)/tools/gacutil && $(MAKE) || exit 1 ;
|
||||
|
||||
clean-local:
|
||||
-rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
|
||||
|
||||
test-local: $(the_lib)
|
||||
@:
|
||||
run-test-local:
|
||||
@:
|
||||
run-test-ondotnet-local:
|
||||
@:
|
||||
|
||||
ifndef NO_TEST
|
||||
$(test_nunit_dep): $(topdir)/build/deps/nunit.stamp
|
||||
@if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
|
||||
$(topdir)/build/deps/nunit.stamp:
|
||||
cd ${topdir}/nunit20 && $(MAKE)
|
||||
echo "stamp" >$@
|
||||
-rm -f $(the_lib) $(makefrag) $(test_lib) \
|
||||
$(test_makefrag) $(test_response) \
|
||||
$(stampfile) $(test_stampfile) \
|
||||
$(the_pdb) $(test_pdb) $(CLEAN_FILES) \
|
||||
TestResult.xml
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
-rm -rf $(response)
|
||||
endif
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
ifndef NO_TEST
|
||||
$(test_nunitfw):
|
||||
(cd ${topdir}/nunit20 && make)
|
||||
|
||||
test-local: $(test_lib)
|
||||
test-local: $(test_nunitfw) $(the_lib) $(test_lib)
|
||||
|
||||
run-test-local: run-test-lib
|
||||
|
||||
run-test-lib: test-local
|
||||
$(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
|
||||
|
||||
run-test-ondotnet-local: run-test-ondotnet-lib
|
||||
|
||||
run-test-ondotnet-lib: test-local
|
||||
$(TEST_HARNESS) $(test_lib)
|
||||
endif
|
||||
|
||||
ifdef HAVE_VB_TESTS
|
||||
|
||||
test-local: $(btest_lib)
|
||||
|
||||
run-test-local: run-btest-lib
|
||||
|
||||
run-btest-lib: test-local
|
||||
$(TEST_RUNTIME) $(TEST_HARNESS) $(btest_lib)
|
||||
|
||||
run-test-ondotnet-local: run-btest-ondotnet-lib
|
||||
|
||||
run-btest-ondotnet-lib: test-local
|
||||
$(TEST_HARNESS) $(btest_lib)
|
||||
else
|
||||
test-local: $(the_lib)
|
||||
|
||||
run-test-local:
|
||||
endif
|
||||
|
||||
DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
|
||||
|
||||
ifdef NO_TEST
|
||||
TEST_FILES =
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
TEST_FILES += `sed 's,^,Test/,' $(test_sourcefile)`
|
||||
endif
|
||||
ifdef HAVE_VB_TESTS
|
||||
TEST_FILES += `sed 's,^,Test/,' $(btest_sourcefile)`
|
||||
else
|
||||
TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
|
||||
endif
|
||||
|
||||
dist-local: dist-default
|
||||
@@ -184,64 +102,64 @@ ifndef LIBRARY_COMPILE
|
||||
LIBRARY_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
|
||||
ifndef TEST_COMPILE
|
||||
TEST_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
|
||||
ifndef BTEST_COMPILE
|
||||
BTEST_COMPILE = $(BASCOMPILE)
|
||||
endif
|
||||
|
||||
# Fun with dependency tracking
|
||||
|
||||
$(the_lib): $(makefrag) $(response)
|
||||
$(the_lib): $(makefrag) $(stampfile) $(response)
|
||||
$(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
|
||||
|
||||
# warning: embedded tab in the 'echo touch' line
|
||||
$(makefrag): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(the_lib): ,' $< >$@
|
||||
@echo "HAVE_MAKEFRAG = yes" >[email protected]
|
||||
@echo "$(stampfile): \\" >>[email protected]
|
||||
@cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>[email protected]
|
||||
@cat [email protected] |sed -e '$$s, \\$$,,' >$@
|
||||
@echo " touch \$$@" >>$@
|
||||
@rm -rf [email protected]
|
||||
|
||||
ifneq ($(response),$(sourcefile))
|
||||
$(response): $(sourcefile) $(PLATFORM_excludes)
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
$(response): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
@cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
endif
|
||||
|
||||
-include $(makefrag)
|
||||
|
||||
ifndef HAVE_MAKEFRAG
|
||||
$(stampfile):
|
||||
touch $@
|
||||
endif
|
||||
|
||||
# for now, don't give any /lib flags or set MONO_PATH, since we
|
||||
# give a full path to the assembly.
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
|
||||
$(test_lib): $(test_makefrag) $(test_dep) $(test_response) $(test_nunit_dep)
|
||||
$(TEST_COMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
|
||||
ifndef NO_TEST
|
||||
$(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
|
||||
$(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
|
||||
|
||||
$(test_response): $(test_sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
@cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
else
|
||||
@cat $< |sed -e 's,^\(.\),Test/\1,' >$@
|
||||
endif
|
||||
|
||||
# warning: embedded tab in the 'echo touch' line
|
||||
$(test_makefrag): $(test_response)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(test_lib): ,' $< >$@
|
||||
@echo "HAVE_TEST_MAKEFRAG = yes" >[email protected]
|
||||
@echo "$(test_stampfile): \\" >>[email protected]
|
||||
@cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>[email protected]
|
||||
@cat [email protected] |sed -e '$$s, \\$$,,' >$@
|
||||
@echo " touch \$$@" >>$@
|
||||
@rm -rf [email protected]
|
||||
|
||||
-include $(test_makefrag)
|
||||
|
||||
endif
|
||||
|
||||
ifdef HAVE_VB_TESTS
|
||||
|
||||
$(btest_lib): $(btest_makefrag) $(test_dep) $(btest_response) $(test_nunit_dep)
|
||||
$(BTEST_COMPILE) /target:library /out:$@ $(btest_flags) @$(btest_response)
|
||||
|
||||
$(btest_response): $(btest_sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
|
||||
$(btest_makefrag): $(btest_response)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(btest_lib): ,' $< >$@
|
||||
|
||||
-include $(btest_makefrag)
|
||||
|
||||
ifndef HAVE_TEST_MAKEFRAG
|
||||
$(test_stampfile):
|
||||
touch $@
|
||||
endif
|
||||
|
||||
@@ -16,20 +16,28 @@ PLATFORM_PATH_SEPARATOR = :
|
||||
# Define this if this ever will work on Linux
|
||||
# PLATFORM_MAKE_CORLIB_CMP = yes
|
||||
|
||||
# This is for the security permission attribute problem
|
||||
# on windows
|
||||
PLATFORM_TWEAK_CORLIB_SOURCES = cat
|
||||
|
||||
# This is for changing / to \ on windows
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD = cat
|
||||
# Don't define it so we don't needlessly copy the sources
|
||||
# file. This command is handy for testing:
|
||||
#
|
||||
# PLATFORM_CHANGE_SEPARATOR_CMD=sed -e 's,/,/./,g'
|
||||
|
||||
hidden_prefix = .
|
||||
hidden_suffix =
|
||||
|
||||
platform-check:
|
||||
@set fnord $(BOOTSTRAP_MCS) ; if type $$2 >/dev/null 2>&1 ; then :; else \
|
||||
echo "*** You need a C# compiler installed to build MCS. (make sure mcs works from the command line)" ; \
|
||||
@if ! type $(BOOTSTRAP_MCS) >/dev/null 2>&1 ; then \
|
||||
echo "*** You need a C# compiler installed to build MCS." ; \
|
||||
echo "*** Read INSTALL.txt for information on how to bootstrap" ; \
|
||||
echo "*** a Mono installation." ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
|
||||
# I tried this but apparently Make's version strings aren't that
|
||||
# ... consistent between releases. Whatever.
|
||||
#
|
||||
|
||||
@@ -13,11 +13,10 @@ MCS = $(BOOTSTRAP_MCS)
|
||||
RESGEN = resgen.exe
|
||||
|
||||
PLATFORM_MAKE_CORLIB_CMP = yes
|
||||
PLATFORM_TWEAK_CORLIB_SOURCES=cat - corlib.dll.win32-excludes |sort |uniq -u
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD=tr '/' '\\\\'
|
||||
PLATFORM_PATH_SEPARATOR = ;
|
||||
|
||||
TEST_RUNTIME = mono
|
||||
|
||||
hidden_prefix =
|
||||
hidden_suffix = .tmp
|
||||
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
|
||||
ifdef PLATFORM_MONO_NATIVE
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(INTERNAL_MCS)
|
||||
MBAS = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(INTERNAL_MBAS)
|
||||
TEST_RUNTIME = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) --debug
|
||||
else
|
||||
MCS = $(PLATFORM_RUNTIME) $(BOOTSTRAP_MCS) /lib:$(topdir)/class/lib/$(PROFILE)
|
||||
MBAS = $(PLATFORM_RUNTIME) $(BOOTSTRAP_MBAS) /lib:$(topdir)/class/lib/$(PROFILE)
|
||||
endif
|
||||
|
||||
# nuttzing!
|
||||
@@ -28,4 +26,3 @@ endif
|
||||
profile-check:
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:ONLY_1_1
|
||||
PROFILE_MBAS_FLAGS = -d:NET_1_1 -d:ONLY_1_1
|
||||
@@ -13,13 +13,11 @@
|
||||
dots := $(shell echo $(thisdir) |sed -e 's,[^./][^/]*,..,g')
|
||||
topdir := $(dots)
|
||||
|
||||
VERSION = 0.93
|
||||
VERSION = 0.91.99
|
||||
|
||||
USE_MCS_FLAGS = $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
|
||||
USE_MBAS_FLAGS = $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
|
||||
USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
|
||||
CSCOMPILE = $(MCS) $(USE_MCS_FLAGS)
|
||||
BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
|
||||
CCOMPILE = $(CC) $(USE_CFLAGS)
|
||||
BOOT_COMPILE = $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
@@ -27,7 +25,6 @@ INSTALL_BIN = $(INSTALL) -m 755
|
||||
INSTALL_LIB = $(INSTALL_BIN)
|
||||
MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
|
||||
INTERNAL_MCS = $(RUNTIME) $(topdir)/mcs/mcs.exe
|
||||
INTERNAL_MBAS = $(RUNTIME) $(topdir)/mbas/mbas.exe
|
||||
INTERNAL_GMCS = $(RUNTIME) $(topdir)/gmcs/gmcs.exe
|
||||
INTERNAL_ILASM = $(RUNTIME) $(topdir)/ilasm/ilasm.exe
|
||||
INTERNAL_RESGEN = $(RUNTIME) $(topdir)/monoresgen/monoresgen.exe
|
||||
@@ -127,8 +124,6 @@ test: test-recursive test-local
|
||||
|
||||
run-test: run-test-recursive test-local run-test-local
|
||||
|
||||
run-test-ondotnet: run-test-ondotnet-recursive test-local run-test-ondotnet-local
|
||||
|
||||
clean: clean-recursive clean-local
|
||||
|
||||
uninstall: uninstall-recursive uninstall-local
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
2004-06-11 Duncan Mak <[email protected]>
|
||||
|
||||
* IBM.Data.DB2/IBM.Data.DB2.dll.sources:
|
||||
* Makefile: Add IBM.Data.DB2.
|
||||
|
||||
2004-05-07 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (SUBDIRS): Build 'corlib' and first pass of 'System'
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
2004-06-07 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RncParser.jay : removed unused code. Fixed LookupNamespace() to
|
||||
pass atomized name always.
|
||||
|
||||
2004-05-31 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RncParser.jay : now error output is disabled.
|
||||
* RncTokenizer.cs : It should not be public class.
|
||||
|
||||
2004-05-30 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RncParser.jay :
|
||||
Now RncParser.Parse() returns RelaxngPattern, not RelaxngGrammar.
|
||||
Fixed many "confusing RelaxngPattern and RelaxngPatternList"
|
||||
problems, and ditto for other "List" stuff.
|
||||
To avoid complex situations, mostly removed unused annotation stuff.
|
||||
|
||||
2004-05-09 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RncParser.jay :
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -16,7 +16,7 @@ using Commons.Xml.Relaxng;
|
||||
|
||||
namespace Commons.Xml.Relaxng.Rnc
|
||||
{
|
||||
internal class RncTokenizer : Commons.Xml.Relaxng.Rnc.yyParser.yyInput
|
||||
public class RncTokenizer : Commons.Xml.Relaxng.Rnc.yyParser.yyInput
|
||||
{
|
||||
TextReader source;
|
||||
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
2004-05-31 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Misc.cs : made Util class internal.
|
||||
* RelaxngDatatypeProvider.cs : looks commit was missing.
|
||||
* RelaxngException.cs : made one .ctor() internal that accepts
|
||||
RdpPattern.
|
||||
* RelaxngNameClas.cs : Names list should not be settable.
|
||||
* RelaxngPattern.cs : RelaxngRefPattern class is internal use only.
|
||||
* RelaxngPatternType.cs : there is not "Include" pattern.
|
||||
|
||||
2004-05-30 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RelaxngDatatypeProvider.cs : removed meaningless using alias.
|
||||
* RelaxngGrammar.cs : modified ArrayList to RelaxngGrammarContentList.
|
||||
RelaxngMergedProvider.cs : Added #if PNET switch to support non-
|
||||
xmlschema available environment.
|
||||
* RelaxngPattern.cs : added IGrammarContent and
|
||||
RelaxngGrammarContentList.
|
||||
|
||||
2004-03-17 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RelaxngNameClass.cs : Introduced RelaxngNameClassList class.
|
||||
|
||||
@@ -14,7 +14,7 @@ using Commons.Xml.Relaxng.Derivative;
|
||||
|
||||
namespace Commons.Xml.Relaxng
|
||||
{
|
||||
internal class Util
|
||||
public class Util
|
||||
{
|
||||
public static string ResolveUri (string baseUri, string href)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using Commons.Xml.Relaxng.XmlSchema;
|
||||
|
||||
using XSchema = System.Xml.Schema.XmlSchema;
|
||||
|
||||
namespace Commons.Xml.Relaxng
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Commons.Xml.Relaxng
|
||||
public RelaxngException (string message) : base (message) {}
|
||||
public RelaxngException (string message, Exception innerException)
|
||||
: base (message, innerException) {}
|
||||
internal RelaxngException (string message, RdpPattern invalidatedPattern)
|
||||
public RelaxngException (string message, RdpPattern invalidatedPattern)
|
||||
: base (message)
|
||||
{
|
||||
debugXml = RdpUtil.DebugRdpPattern (invalidatedPattern, new Hashtable ());
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace Commons.Xml.Relaxng
|
||||
"http://relaxng.org/ns/structure/1.0";
|
||||
|
||||
// object model fields
|
||||
RelaxngGrammarContentList starts = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList defs = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList includes = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList divs = new RelaxngGrammarContentList ();
|
||||
ArrayList starts = new ArrayList ();
|
||||
ArrayList defs = new ArrayList ();
|
||||
ArrayList includes = new ArrayList ();
|
||||
ArrayList divs = new ArrayList ();
|
||||
|
||||
RelaxngDatatypeProvider provider;
|
||||
|
||||
@@ -75,19 +75,19 @@ namespace Commons.Xml.Relaxng
|
||||
get { return RelaxngPatternType.Grammar; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Starts {
|
||||
public IList Starts {
|
||||
get { return starts; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Defines {
|
||||
public IList Defines {
|
||||
get { return defs; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Includes {
|
||||
public IList Includes {
|
||||
get { return includes; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Divs {
|
||||
public IList Divs {
|
||||
get { return divs; }
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,8 @@ namespace Commons.Xml.Relaxng
|
||||
static RelaxngMergedProvider ()
|
||||
{
|
||||
RelaxngMergedProvider p = new RelaxngMergedProvider ();
|
||||
#if !PNET
|
||||
p ["http://www.w3.org/2001/XMLSchema-datatypes"] = XsdDatatypeProvider.Instance;
|
||||
p [XSchema.Namespace] = XsdDatatypeProvider.Instance;
|
||||
#endif
|
||||
p [String.Empty] = RelaxngNamespaceDatatypeProvider.Instance;
|
||||
defaultProvider = p;
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ namespace Commons.Xml.Relaxng
|
||||
|
||||
public RelaxngNameClassList Names {
|
||||
get { return names; }
|
||||
set { names = value; }
|
||||
}
|
||||
|
||||
public override void Write (XmlWriter writer)
|
||||
|
||||
@@ -121,11 +121,7 @@ namespace Commons.Xml.Relaxng
|
||||
#endregion
|
||||
|
||||
#region Grammatical elements
|
||||
public interface IGrammarContent
|
||||
{
|
||||
}
|
||||
|
||||
public class RelaxngStart : RelaxngElementBase, IGrammarContent
|
||||
public class RelaxngStart : RelaxngElementBase
|
||||
{
|
||||
RelaxngPattern p;
|
||||
string combine;
|
||||
@@ -159,7 +155,7 @@ namespace Commons.Xml.Relaxng
|
||||
}
|
||||
}
|
||||
|
||||
public class RelaxngDefine : RelaxngElementBase, IGrammarContent
|
||||
public class RelaxngDefine : RelaxngElementBase
|
||||
{
|
||||
string name;
|
||||
private RelaxngPatternList patterns = new RelaxngPatternList ();
|
||||
@@ -215,12 +211,12 @@ namespace Commons.Xml.Relaxng
|
||||
}
|
||||
}
|
||||
|
||||
public class RelaxngInclude : RelaxngElementBase, IGrammarContent
|
||||
public class RelaxngInclude : RelaxngElementBase
|
||||
{
|
||||
string href;
|
||||
RelaxngGrammarContentList starts = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList defines = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList divs = new RelaxngGrammarContentList ();
|
||||
IList starts = new ArrayList ();
|
||||
IList defines = new ArrayList ();
|
||||
IList divs = new ArrayList ();
|
||||
string ns;
|
||||
|
||||
public RelaxngInclude ()
|
||||
@@ -232,15 +228,15 @@ namespace Commons.Xml.Relaxng
|
||||
set { href = value; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Starts {
|
||||
public IList Starts {
|
||||
get { return starts; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Defines {
|
||||
public IList Defines {
|
||||
get { return defines; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Divs {
|
||||
public IList Divs {
|
||||
get { return divs; }
|
||||
}
|
||||
|
||||
@@ -296,7 +292,7 @@ namespace Commons.Xml.Relaxng
|
||||
// starts.
|
||||
if (this.Starts.Count > 0 && g.Starts.Count == 0)
|
||||
throw new RelaxngException ("When the included grammar does not contain start components, this include component must not contain start components.");
|
||||
RelaxngGrammarContentList appliedStarts = (this.starts.Count > 0) ?
|
||||
IList appliedStarts = (this.starts.Count > 0) ?
|
||||
this.starts : g.Starts;
|
||||
|
||||
RelaxngDiv div = new RelaxngDiv ();
|
||||
@@ -329,30 +325,30 @@ namespace Commons.Xml.Relaxng
|
||||
}
|
||||
}
|
||||
|
||||
public class RelaxngDiv : RelaxngElementBase, IGrammarContent
|
||||
public class RelaxngDiv : RelaxngElementBase
|
||||
{
|
||||
RelaxngGrammarContentList starts = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList defines = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList includes = new RelaxngGrammarContentList ();
|
||||
RelaxngGrammarContentList divs = new RelaxngGrammarContentList ();
|
||||
IList starts = new ArrayList ();
|
||||
IList defines = new ArrayList ();
|
||||
IList includes = new ArrayList ();
|
||||
IList divs = new ArrayList ();
|
||||
|
||||
public RelaxngDiv ()
|
||||
{
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Starts {
|
||||
public IList Starts {
|
||||
get { return starts; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Defines {
|
||||
public IList Defines {
|
||||
get { return defines; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Includes {
|
||||
public IList Includes {
|
||||
get { return includes; }
|
||||
}
|
||||
|
||||
public RelaxngGrammarContentList Divs {
|
||||
public IList Divs {
|
||||
get { return divs; }
|
||||
}
|
||||
|
||||
@@ -484,33 +480,6 @@ namespace Commons.Xml.Relaxng
|
||||
}
|
||||
}
|
||||
|
||||
public class RelaxngGrammarContentList : CollectionBase
|
||||
{
|
||||
public RelaxngGrammarContentList ()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add (IGrammarContent p)
|
||||
{
|
||||
List.Add (p);
|
||||
}
|
||||
|
||||
public IGrammarContent this [int i] {
|
||||
get { return this.List [i] as IGrammarContent; }
|
||||
set { this.List [i] = value; }
|
||||
}
|
||||
|
||||
public void Insert (int pos, IGrammarContent p)
|
||||
{
|
||||
List.Insert (pos, p);
|
||||
}
|
||||
|
||||
public void Remove (IGrammarContent p)
|
||||
{
|
||||
List.Remove (p);
|
||||
}
|
||||
}
|
||||
|
||||
// strict to say, it's not a pattern ;)
|
||||
public class RelaxngNotAllowed : RelaxngPattern
|
||||
{
|
||||
@@ -1348,7 +1317,7 @@ namespace Commons.Xml.Relaxng
|
||||
}
|
||||
}
|
||||
|
||||
internal class RelaxngRefPattern
|
||||
public class RelaxngRefPattern
|
||||
{
|
||||
RelaxngPattern patternRef;
|
||||
string name;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Commons.Xml.Relaxng
|
||||
ZeroOrMore = 17, // no use in derivative
|
||||
Mixed = 18, // no use in derivative
|
||||
Optional = 19, // no use in derivative
|
||||
// Include = 20, // no use in derivative
|
||||
Include = 20, // no use in derivative
|
||||
ExternalRef = 21, // no use in derivative
|
||||
ParentRef = 22, // no use in derivative
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
2004-05-30 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* RncTests.cs : fixed test that got impossible to build anymore.
|
||||
|
||||
2004-05-08 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* RelaxngValidatingReaderTests.cs: this compiled with mcs but fails with
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace MonoTests.Commons.Xml.Relaxng
|
||||
{
|
||||
RncParser parser = new RncParser (new NameTable ());
|
||||
using (StreamReader sr = new StreamReader ("Test/XmlFiles/relaxng.rnc")) {
|
||||
RelaxngPattern g = parser.Parse (sr);
|
||||
RelaxngGrammar g = parser.Parse (sr);
|
||||
g.Compile ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
2004-05-31 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* anglia-test-runner.cs : Added support for RELAX NG compact syntax
|
||||
parser tests.
|
||||
* Makefile : added anglia-test support.
|
||||
* README : ditto.
|
||||
|
||||
2004-02-25 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Added README, Makefile, relaxngtest.cs, prep.xsl, copying.html
|
||||
|
||||
@@ -1,44 +1,26 @@
|
||||
RUNTIME = mono
|
||||
MCS_RUNTIME =
|
||||
MCS = mcs
|
||||
|
||||
TESTS = relax-ng/001/i.rng
|
||||
TEST_ARCHIVE = testSuite.zip
|
||||
|
||||
RNCTESTS = test/RNCTest.xml
|
||||
RNCTEST_ARCHIVE = anglia-test-suite.zip
|
||||
|
||||
all : relaxngtest.exe anglia-test-runner.exe
|
||||
|
||||
relaxngtest.exe : relaxngtest.cs $(TESTS)
|
||||
$(MCS_RUNTIME) $(MCS) -debug+ relaxngtest.cs -r:Commons.Xml.Relaxng.dll
|
||||
|
||||
anglia-test-runner.exe : anglia-test-runner.cs $(RNCTESTS)
|
||||
$(MCS_RUNTIME) $(MCS) -debug+ anglia-test-runner.cs -r:Commons.Xml.Relaxng.dll
|
||||
$(MCS_RUNTIME) $(MCS) relaxngtest.cs -r:Commons.Xml.Relaxng.dll
|
||||
|
||||
$(TESTS) : $(TEST_ARCHIVE) relax-ng
|
||||
cd relax-ng; unzip -n ../$(TEST_ARCHIVE); \
|
||||
xsltproc split.xsl spectest.xml; cd ..; \
|
||||
cp prep.xsl relax-ng
|
||||
|
||||
$(RNCTESTS) : $(RNCTEST_ARCHIVE)
|
||||
unzip -n anglia-test-suite.zip
|
||||
|
||||
$(TEST_ARCHIVE) :
|
||||
wget http://www.thaiopensource.com/relaxng/testSuite.zip
|
||||
|
||||
$(RNCTEST_ARCHIVE) :
|
||||
wget http://www.jeffrafter.com/anglia/anglia-test-suite.zip
|
||||
|
||||
relax-ng:
|
||||
mkdir relax-ng
|
||||
|
||||
test : relaxngtest.exe
|
||||
test :
|
||||
$(RUNTIME) relaxngtest.exe
|
||||
|
||||
anglia-test : anglia-test-runner.exe
|
||||
$(RUNTIME) anglia-test-runner.exe
|
||||
|
||||
# be careful to use it. This removes ALL files in xml-test-suite!
|
||||
# clean:
|
||||
# rm -rf xml-test-suite
|
||||
@@ -1,41 +1,17 @@
|
||||
* standalone RELAX NG test program for the Test Suite
|
||||
|
||||
* Standalone test collection for Commons.Xml.Relaxng.dll
|
||||
|
||||
** standalone RELAX NG test program for the Test Suite
|
||||
** Introduction
|
||||
|
||||
It is a test runner for James Clark's test collection.
|
||||
|
||||
prep.xsl is originally included in Jing (a Java implementation of RELAX NG
|
||||
validator). copying.html is license information for prep.xsl and relaxng.rng.
|
||||
prep.xsl is included in Jing (a Java implementation of RELAX NG validator).
|
||||
copying.html is license information for prep.xsl and relaxng.rng.
|
||||
|
||||
** Usage
|
||||
|
||||
** standalone RELAX NG Compact Syntax test program for the "anglia" test suite
|
||||
|
||||
It is a test runner for Jeff Rafter's "anglia" RNC test collection.
|
||||
|
||||
|
||||
** How to build
|
||||
|
||||
NOTE: To set up test runner, you need xsltproc, which is included in libxslt.
|
||||
To set up test runner, you need xsltproc, which is included in libxslt.
|
||||
(Since the stylesheet uses extensions, we cannot use our xslt engine.)
|
||||
|
||||
"make" will do the same as "make relaxngtest.exe" and
|
||||
"make anglia-test-runner.exe".
|
||||
|
||||
"make relaxngtest.exe" will download the test collection from
|
||||
http://www.thaiopensource.com/relaxng/testSuite.zip and then run
|
||||
xsltproc to split tests and create test directories and files, and finally
|
||||
will compile relaxngtest.cs.
|
||||
|
||||
"make anglia-test-runner.exe" will download the test collection from
|
||||
http://www.jeffrafter.com/anglia/anglia-test-suite.zip , and then will expand
|
||||
that archive, and finally will compile anglia-test-runner.cs.
|
||||
|
||||
|
||||
*** How to run
|
||||
|
||||
"make test" will run relaxngtest.exe and will output the error cases.
|
||||
|
||||
"make anglia-test" will run anglia-test-runner.exe and will output the
|
||||
error cases.
|
||||
"make" will download the test collection from http://www.thaiopensource.com/relaxng/testSuite.zip , run xsltproc and create test directories and files.
|
||||
|
||||
"make test" will run the test program and will output the error cases.
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using Commons.Xml.Relaxng;
|
||||
using Commons.Xml.Relaxng.Rnc;
|
||||
|
||||
public class Driver
|
||||
{
|
||||
public static void Main ()
|
||||
{
|
||||
try {
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
doc.Load ("test/RNCTest.xml");
|
||||
int success = 0;
|
||||
int failure = 0;
|
||||
foreach (XmlElement el in doc.SelectNodes ("/RNCTestCases/TestCase")) {
|
||||
string id = el.GetAttribute ("id");
|
||||
bool isValid = el.GetAttribute ("legal") == "true";
|
||||
RncParser p = new RncParser (new NameTable ());
|
||||
try {
|
||||
string s = new StreamReader ("test" + Path.DirectorySeparatorChar + el.GetAttribute ("path")).ReadToEnd ();
|
||||
p.Parse (new StringReader (s));
|
||||
if (isValid) {
|
||||
success++;
|
||||
// Console.Error.WriteLine ("valid " + id);
|
||||
} else {
|
||||
failure++;
|
||||
Console.Error.WriteLine ("INCORRECTLY VALID " + id);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (isValid) {
|
||||
failure++;
|
||||
Console.Error.WriteLine ("INCORRECTLY INVALID " + id + " --> " + ex.Message);
|
||||
} else {
|
||||
success++;
|
||||
// Console.Error.WriteLine ("invalid " + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.Error.WriteLine ("Total success: " + success);
|
||||
Console.Error.WriteLine ("Total failure: " + failure);
|
||||
} catch (Exception ex) {
|
||||
Console.Error.WriteLine ("Unexpected Exception: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,5 @@ namespace Microsoft.CSharp {
|
||||
{
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public string Comment {
|
||||
get { return comment; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class CP51932 : Encoding
|
||||
value -= 0x0100;
|
||||
bytes [posn++] = (byte) (value / 0x5E + 0xA1);
|
||||
bytes [posn++] = (byte) (value % 0x5E + 0xA1);
|
||||
//Console.WriteLine ("{0:X04}", ch);
|
||||
Console.WriteLine ("{0:X04}", ch);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
./Assembly/AssemblyInfo.cs
|
||||
./IBM.Data.DB2/DB2CLIWrapper.cs
|
||||
./IBM.Data.DB2/DB2ClientUtils.cs
|
||||
./IBM.Data.DB2/DB2OpenConnection.cs
|
||||
./IBM.Data.DB2/DB2CLIWrapper.cs
|
||||
./IBM.Data.DB2/DB2Command.cs
|
||||
./IBM.Data.DB2/DB2Connection.cs
|
||||
./IBM.Data.DB2/DB2ConnectionPool.cs
|
||||
./IBM.Data.DB2/DB2ConnectionSettings.cs
|
||||
./IBM.Data.DB2/DB2Constants.cs
|
||||
./IBM.Data.DB2/DB2DataAdapter.cs
|
||||
./IBM.Data.DB2/DB2DataReader.cs
|
||||
./IBM.Data.DB2/DB2Environment.cs
|
||||
./IBM.Data.DB2/DB2Error.cs
|
||||
./IBM.Data.DB2/DB2ErrorCollection.cs
|
||||
./IBM.Data.DB2/DB2Error.cs
|
||||
./IBM.Data.DB2/DB2Exception.cs
|
||||
./IBM.Data.DB2/DB2InfoMessageEventArgs.cs
|
||||
./IBM.Data.DB2/DB2Parameter.cs
|
||||
./IBM.Data.DB2/DB2OpenConnection.cs
|
||||
./IBM.Data.DB2/DB2ParameterCollection.cs
|
||||
./IBM.Data.DB2/DB2Parameter.cs
|
||||
./IBM.Data.DB2/DB2RowUpdatedEventArgs.cs
|
||||
./IBM.Data.DB2/DB2RowUpdatedEventHandler.cs
|
||||
./IBM.Data.DB2/DB2RowUpdatingEventArgs.cs
|
||||
./IBM.Data.DB2/DB2RowUpdatingEventHandler.cs
|
||||
./IBM.Data.DB2/DB2Transaction.cs
|
||||
./IBM.Data.DB2/DB2Type.cs
|
||||
./IBM.Data.DB2/DB2Type.cs
|
||||
@@ -1,8 +0,0 @@
|
||||
2004-06-09 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* Makefile: Don't sign this assembly as it is fully signed during
|
||||
compilation (we have the original private key). Thanks to Jackson.
|
||||
|
||||
2004-05-28 Duncan Mak <[email protected]>
|
||||
|
||||
* SharpZipLib.pub: Added public key.
|
||||
@@ -1,53 +1,53 @@
|
||||
// AssemblyInfo.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; 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. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
[assembly: AssemblyTitle("ICSharpCode.SharpZipLibrary")]
|
||||
[assembly: AssemblyDescription("free C# zlib implementation")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("#ZipLibrary")]
|
||||
[assembly: AssemblyCopyright("(c) Mike Krueger 2001-2004")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: AssemblyVersion("0.6.0.0")]
|
||||
|
||||
[assembly: AssemblyDelaySign(true)]
|
||||
[assembly: AssemblyKeyFile ("SharpZipLib.pub")]
|
||||
// AssemblyInfo.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; 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. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// 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.
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("SharpZipLibrary")]
|
||||
[assembly: AssemblyDescription("free C# zlib implementation")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("#ZipLibrary")]
|
||||
[assembly: AssemblyCopyright("(c) Mike Krueger 2001-2002")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
#if NET_2_0
|
||||
[assembly: AssemblyVersion("0.31.2.0")]
|
||||
#else
|
||||
[assembly: AssemblyVersion("0.31.0.0")]
|
||||
#endif
|
||||
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("SharpZipLib.key")]
|
||||
@@ -35,8 +35,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// Does all the compress and decompress pre-operation stuff.
|
||||
@@ -47,8 +46,16 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
{
|
||||
public static void Decompress(Stream instream, Stream outstream)
|
||||
{
|
||||
System.IO.Stream bos = outstream;
|
||||
System.IO.Stream bis = instream;
|
||||
BufferedStream bos = new BufferedStream(outstream);
|
||||
BufferedStream bis = new BufferedStream(instream);
|
||||
int b = bis.ReadByte();
|
||||
if (b != 'B') {
|
||||
return;
|
||||
}
|
||||
b = bis.ReadByte();
|
||||
if (b != 'Z') {
|
||||
return;
|
||||
}
|
||||
BZip2InputStream bzis = new BZip2InputStream(bis);
|
||||
int ch = bzis.ReadByte();
|
||||
while (ch != -1) {
|
||||
@@ -59,11 +66,13 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
}
|
||||
|
||||
public static void Compress(Stream instream, Stream outstream, int blockSize)
|
||||
{
|
||||
System.IO.Stream bos = outstream;
|
||||
System.IO.Stream bis = instream;
|
||||
{
|
||||
BufferedStream bos = new BufferedStream(outstream);
|
||||
bos.WriteByte((byte)'B');
|
||||
bos.WriteByte((byte)'Z');
|
||||
BufferedStream bis = new BufferedStream(instream);
|
||||
int ch = bis.ReadByte();
|
||||
BZip2OutputStream bzos = new BZip2OutputStream(bos, blockSize);
|
||||
BZip2OutputStream bzos = new BZip2OutputStream(bos);
|
||||
while(ch != -1) {
|
||||
bzos.WriteByte((byte)ch);
|
||||
ch = bis.ReadByte();
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// Base class for both the compress and decompress classes.
|
||||
@@ -42,59 +41,59 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
public sealed class BZip2Constants
|
||||
{
|
||||
public readonly static int[] rNums = {
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
|
||||
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
|
||||
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
|
||||
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
|
||||
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
|
||||
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
|
||||
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
|
||||
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
|
||||
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
|
||||
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
|
||||
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
|
||||
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
|
||||
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
|
||||
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
|
||||
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
|
||||
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
|
||||
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
|
||||
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
|
||||
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
|
||||
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
|
||||
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
|
||||
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
|
||||
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
|
||||
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
|
||||
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
|
||||
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
|
||||
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
|
||||
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
|
||||
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
|
||||
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
|
||||
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
|
||||
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
|
||||
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
|
||||
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
|
||||
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
|
||||
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
|
||||
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
|
||||
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
|
||||
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
|
||||
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
|
||||
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
|
||||
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
|
||||
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
|
||||
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
|
||||
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
|
||||
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
|
||||
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
|
||||
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
|
||||
936, 638
|
||||
};
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
|
||||
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
|
||||
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
|
||||
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
|
||||
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
|
||||
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
|
||||
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
|
||||
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
|
||||
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
|
||||
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
|
||||
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
|
||||
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
|
||||
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
|
||||
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
|
||||
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
|
||||
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
|
||||
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
|
||||
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
|
||||
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
|
||||
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
|
||||
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
|
||||
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
|
||||
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
|
||||
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
|
||||
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
|
||||
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
|
||||
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
|
||||
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
|
||||
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
|
||||
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
|
||||
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
|
||||
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
|
||||
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
|
||||
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
|
||||
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
|
||||
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
|
||||
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
|
||||
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
|
||||
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
|
||||
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
|
||||
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
|
||||
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
|
||||
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
|
||||
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
|
||||
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
|
||||
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
|
||||
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
|
||||
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
|
||||
936, 638
|
||||
};
|
||||
|
||||
public readonly static int baseBlockSize = 100000;
|
||||
|
||||
|
||||
+21
-34
@@ -37,8 +37,7 @@ using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// An input stream that decompresses from the BZip2 format (without the file
|
||||
@@ -160,23 +159,23 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
static void Cadvise()
|
||||
{
|
||||
//Console.WriteLine("CRC Error");
|
||||
Console.WriteLine("CRC Error");
|
||||
//throw new CCoruptionError();
|
||||
}
|
||||
|
||||
static void BadBGLengths()
|
||||
{
|
||||
//Console.WriteLine("bad BG lengths");
|
||||
Console.WriteLine("bad BG lengths");
|
||||
}
|
||||
|
||||
static void BitStreamEOF()
|
||||
static void bitStreamEOF()
|
||||
{
|
||||
//Console.WriteLine("bit stream eof");
|
||||
Console.WriteLine("bit stream eof");
|
||||
}
|
||||
|
||||
static void CompressedStreamEOF()
|
||||
{
|
||||
//Console.WriteLine("compressed stream eof");
|
||||
Console.WriteLine("compressed stream eof");
|
||||
}
|
||||
|
||||
void MakeMaps()
|
||||
@@ -210,8 +209,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
bool blockRandomised;
|
||||
|
||||
// private int bytesIn;
|
||||
// private int bytesOut;
|
||||
// private int bytesIn;
|
||||
// private int bytesOut;
|
||||
int bsBuff;
|
||||
int bsLive;
|
||||
IChecksum mCrc = new StrangeCRC();
|
||||
@@ -285,7 +284,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (streamEnd) {
|
||||
return -1; // ok
|
||||
return -1;
|
||||
}
|
||||
|
||||
int retChar = currentChar;
|
||||
@@ -314,14 +313,10 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
// -jr- 18-Nov-2003 magic1 and 2 added here so stream is fully capable on its own
|
||||
char magic1 = BsGetUChar();
|
||||
char magic2 = BsGetUChar();
|
||||
|
||||
char magic3 = BsGetUChar();
|
||||
char magic4 = BsGetUChar();
|
||||
|
||||
if (magic1 != 'B' || magic2 != 'Z' || magic3 != 'h' || magic4 < '1' || magic4 > '9') {
|
||||
if (magic3 != 'h' || magic4 < '1' || magic4 > '9') {
|
||||
streamEnd = true;
|
||||
return;
|
||||
}
|
||||
@@ -370,7 +365,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
CrcError();
|
||||
}
|
||||
|
||||
// 1528150659
|
||||
// 1528150659
|
||||
computedCombinedCRC = ((computedCombinedCRC << 1) & 0xFFFFFFFF) | (computedCombinedCRC >> 31);
|
||||
computedCombinedCRC = computedCombinedCRC ^ (uint)computedBlockCRC;
|
||||
}
|
||||
@@ -387,17 +382,17 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
static void BlockOverrun()
|
||||
{
|
||||
//Console.WriteLine("Block overrun");
|
||||
Console.WriteLine("Block overrun");
|
||||
}
|
||||
|
||||
static void BadBlockHeader()
|
||||
{
|
||||
//Console.WriteLine("Bad block header");
|
||||
Console.WriteLine("Bad block header");
|
||||
}
|
||||
|
||||
static void CrcError()
|
||||
{
|
||||
//Console.WriteLine("crc error");
|
||||
Console.WriteLine("crc error");
|
||||
}
|
||||
|
||||
|
||||
@@ -523,10 +518,6 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
for (int j = 0; j < 16; j++) {
|
||||
inUse[i * 16 + j] = (BsR(1) == 1);
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
inUse[i * 16 + j] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,9 +622,6 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
int zj;
|
||||
|
||||
while (zvec > limit[zt][zn]) {
|
||||
if (zn > 20) { // the longest code
|
||||
throw new ApplicationException("Bzip data error"); // -jr- 17-Dec-2003 from bzip 1.02 why 20???
|
||||
}
|
||||
zn++;
|
||||
while (bsLive < 1) {
|
||||
FillBuffer();
|
||||
@@ -642,12 +630,10 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
bsLive--;
|
||||
zvec = (zvec << 1) | zj;
|
||||
}
|
||||
if (zvec - baseArray[zt][zn] < 0 || zvec - baseArray[zt][zn] >= BZip2Constants.MAX_ALPHA_SIZE) {
|
||||
throw new ApplicationException("Bzip data error"); // -jr- 17-Dec-2003 from bzip 1.02
|
||||
}
|
||||
nextSym = perm[zt][zvec - baseArray[zt][zn]];
|
||||
|
||||
while (true) {
|
||||
|
||||
if (nextSym == EOB) {
|
||||
break;
|
||||
}
|
||||
@@ -657,9 +643,9 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
int n = 1;
|
||||
do {
|
||||
if (nextSym == BZip2Constants.RUNA) {
|
||||
s += (0 + 1) * n;
|
||||
s += (0+1) * n;
|
||||
} else if (nextSym == BZip2Constants.RUNB) {
|
||||
s += (1 + 1) * n;
|
||||
s += (1+1) * n;
|
||||
}
|
||||
|
||||
n <<= 1;
|
||||
@@ -776,7 +762,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
void SetupRandPartA()
|
||||
{
|
||||
if (i2 <= last) {
|
||||
if(i2 <= last) {
|
||||
chPrev = ch2;
|
||||
ch2 = ll8[tPos];
|
||||
tPos = tt[tPos];
|
||||
@@ -900,10 +886,11 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
void SetDecompressStructureSizes(int newSize100k)
|
||||
{
|
||||
if (!(0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k && blockSize100k <= 9)) {
|
||||
if (!(0 <= newSize100k && newSize100k <= 9 &&
|
||||
0 <= blockSize100k && blockSize100k <= 9)) {
|
||||
throw new ApplicationException("Invalid block size");
|
||||
}
|
||||
|
||||
|
||||
blockSize100k = newSize100k;
|
||||
|
||||
if (newSize100k == 0) {
|
||||
|
||||
+50
-80
@@ -37,8 +37,7 @@ using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// An output stream that compresses into the BZip2 format (without the file
|
||||
@@ -153,7 +152,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
static void Panic()
|
||||
{
|
||||
//Console.WriteLine("panic");
|
||||
Console.WriteLine("panic");
|
||||
}
|
||||
|
||||
void MakeMaps()
|
||||
@@ -223,7 +222,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
break;
|
||||
}
|
||||
if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) {
|
||||
yy++;
|
||||
yy++;
|
||||
}
|
||||
if (weight[tmp] < weight[heap[yy]]) {
|
||||
break;
|
||||
@@ -242,15 +241,13 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
tmp = heap[zz];
|
||||
while (true) {
|
||||
yy = zz << 1;
|
||||
if (yy > nHeap) {
|
||||
if (yy > nHeap)
|
||||
break;
|
||||
}
|
||||
if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) {
|
||||
yy++;
|
||||
}
|
||||
if (weight[tmp] < weight[heap[yy]]) {
|
||||
if (yy < nHeap &&
|
||||
weight[heap[yy+1]] < weight[heap[yy]])
|
||||
yy++;
|
||||
if (weight[tmp] < weight[heap[yy]])
|
||||
break;
|
||||
}
|
||||
heap[zz] = heap[yy];
|
||||
zz = yy;
|
||||
}
|
||||
@@ -258,7 +255,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
nNodes++;
|
||||
parent[n1] = parent[n2] = nNodes;
|
||||
|
||||
weight[nNodes] = (int)((weight[n1] & 0xffffff00) + (weight[n2] & 0xffffff00)) |
|
||||
weight[nNodes] = (int)((weight[n1] & 0xffffff00) + (weight[n2] & 0xffffff00)) |
|
||||
(int)(1 + (((weight[n1] & 0x000000ff) > (weight[n2] & 0x000000ff)) ? (weight[n1] & 0x000000ff) : (weight[n2] & 0x000000ff)));
|
||||
|
||||
parent[nNodes] = -1;
|
||||
@@ -322,7 +319,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
bool blockRandomised;
|
||||
|
||||
// int bytesIn;
|
||||
// int bytesIn;
|
||||
int bytesOut;
|
||||
int bsBuff;
|
||||
int bsLive;
|
||||
@@ -478,14 +475,14 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
EndBlock();
|
||||
EndCompression();
|
||||
closed = true;
|
||||
// super.close();
|
||||
// super.close();
|
||||
Flush();
|
||||
baseStream.Close();
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
// super.flush();
|
||||
// super.flush();
|
||||
baseStream.Flush();
|
||||
}
|
||||
|
||||
@@ -493,16 +490,13 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
// bytesIn = 0;
|
||||
// bytesIn = 0;
|
||||
bytesOut = 0;
|
||||
nBlocksRandomised = 0;
|
||||
|
||||
/*--- Write `magic' bytes h indicating file-format == huffmanised,
|
||||
followed by a digit indicating blockSize100k.
|
||||
---*/
|
||||
BsPutUChar('B'); // -jr- 18-Nov-2003 added to match BZ2 1.02 header already in BZip class but that sux a lot
|
||||
BsPutUChar('Z');
|
||||
|
||||
BsPutUChar('h');
|
||||
BsPutUChar('0' + blockSize100k);
|
||||
|
||||
@@ -528,10 +522,6 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
void EndBlock()
|
||||
{
|
||||
if (last < 0) { //-jr- dont do anything for empty files, (makes empty files compatible with original Bzip)
|
||||
return;
|
||||
}
|
||||
|
||||
blockCRC = (uint)mCrc.Value;
|
||||
combinedCRC = (combinedCRC << 1) | (combinedCRC >> 31);
|
||||
combinedCRC ^= blockCRC;
|
||||
@@ -619,8 +609,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
void BsFinishedWithStream()
|
||||
{
|
||||
while (bsLive > 0)
|
||||
{
|
||||
while (bsLive > 0) {
|
||||
int ch = (bsBuff >> 24);
|
||||
baseStream.WriteByte((byte)ch); // write 8-bit
|
||||
bsBuff <<= 8;
|
||||
@@ -751,6 +740,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
totc = 0;
|
||||
gs = 0;
|
||||
while (true) {
|
||||
|
||||
/*--- Set group start & end marks. --*/
|
||||
if (gs >= nMTF) {
|
||||
break;
|
||||
@@ -841,6 +831,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
Panic();
|
||||
}
|
||||
|
||||
|
||||
/*--- Compute MTF values for the selectors. ---*/
|
||||
char[] pos = new char[BZip2Constants.N_GROUPS];
|
||||
char ll_i, tmp2, tmp;
|
||||
@@ -1020,40 +1011,35 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
i++;
|
||||
|
||||
/*-- copy 2 --*/
|
||||
if (i > hi) {
|
||||
if (i > hi)
|
||||
break;
|
||||
}
|
||||
v = zptr[i];
|
||||
j = i;
|
||||
while (FullGtU ( zptr[j-h]+d, v+d )) {
|
||||
zptr[j] = zptr[j-h];
|
||||
j = j - h;
|
||||
if (j <= (lo + h - 1)) {
|
||||
if (j <= (lo + h - 1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
zptr[j] = v;
|
||||
i++;
|
||||
|
||||
/*-- copy 3 --*/
|
||||
if (i > hi) {
|
||||
if (i > hi)
|
||||
break;
|
||||
}
|
||||
v = zptr[i];
|
||||
j = i;
|
||||
while (FullGtU ( zptr[j-h]+d, v+d)) {
|
||||
zptr[j] = zptr[j-h];
|
||||
j = j - h;
|
||||
if (j <= (lo + h - 1)) {
|
||||
if (j <= (lo + h - 1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
zptr[j] = v;
|
||||
i++;
|
||||
|
||||
if (workDone > workLimit && firstAttempt) {
|
||||
if (workDone > workLimit && firstAttempt)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1102,9 +1088,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
int unLo, unHi, ltLo, gtHi, med, n, m;
|
||||
int sp, lo, hi, d;
|
||||
StackElem[] stack = new StackElem[QSORT_STACK_SIZE];
|
||||
for (int count = 0; count < QSORT_STACK_SIZE; count++) {
|
||||
for(int count = 0; count < QSORT_STACK_SIZE; count++)
|
||||
stack[count] = new StackElem();
|
||||
}
|
||||
|
||||
sp = 0;
|
||||
|
||||
@@ -1125,9 +1110,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
if (hi - lo < SMALL_THRESH || d > DEPTH_THRESH) {
|
||||
SimpleSort(lo, hi, d);
|
||||
if (workDone > workLimit && firstAttempt) {
|
||||
if (workDone > workLimit && firstAttempt)
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1159,9 +1143,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
unLo++;
|
||||
}
|
||||
while (true) {
|
||||
if (unLo > unHi) {
|
||||
if (unLo > unHi)
|
||||
break;
|
||||
}
|
||||
n = ((int)block[zptr[unHi]+d + 1]) - med;
|
||||
if (n == 0) {
|
||||
int temp = 0;
|
||||
@@ -1171,21 +1154,19 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
gtHi--;
|
||||
unHi--;
|
||||
continue;
|
||||
}
|
||||
if (n < 0) {
|
||||
};
|
||||
if (n < 0)
|
||||
break;
|
||||
}
|
||||
unHi--;
|
||||
}
|
||||
if (unLo > unHi) {
|
||||
if (unLo > unHi)
|
||||
break;
|
||||
}
|
||||
{
|
||||
int temp = zptr[unLo];
|
||||
zptr[unLo] = zptr[unHi];
|
||||
zptr[unHi] = temp;
|
||||
unLo++;
|
||||
unHi--;
|
||||
int temp = zptr[unLo];
|
||||
zptr[unLo] = zptr[unHi];
|
||||
zptr[unHi] = temp;
|
||||
unLo++;
|
||||
unHi--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1252,20 +1233,18 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
Use simpleSort(), since the full sorting mechanism
|
||||
has quite a large constant overhead.
|
||||
--*/
|
||||
for (i = 0; i <= last; i++) {
|
||||
for (i = 0; i <= last; i++)
|
||||
zptr[i] = i;
|
||||
}
|
||||
firstAttempt = false;
|
||||
workDone = workLimit = 0;
|
||||
SimpleSort(0, last, 0);
|
||||
} else {
|
||||
numQSorted = 0;
|
||||
for (i = 0; i <= 255; i++) {
|
||||
for (i = 0; i <= 255; i++)
|
||||
bigDone[i] = false;
|
||||
}
|
||||
for (i = 0; i <= 65536; i++) {
|
||||
|
||||
for (i = 0; i <= 65536; i++)
|
||||
ftab[i] = 0;
|
||||
}
|
||||
|
||||
c1 = block[0];
|
||||
for (i = 0; i <= last; i++) {
|
||||
@@ -1274,9 +1253,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
c1 = c2;
|
||||
}
|
||||
|
||||
for (i = 1; i <= 65536; i++) {
|
||||
for (i = 1; i <= 65536; i++)
|
||||
ftab[i] += ftab[i - 1];
|
||||
}
|
||||
|
||||
c1 = block[1];
|
||||
for (i = 0; i < last; i++) {
|
||||
@@ -1314,9 +1292,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
while ((ftab[((runningOrder[j-h])+1) << 8] - ftab[(runningOrder[j-h]) << 8]) > (ftab[((vv)+1) << 8] - ftab[(vv) << 8])) {
|
||||
runningOrder[j] = runningOrder[j-h];
|
||||
j = j - h;
|
||||
if (j <= (h - 1)) {
|
||||
if (j <= (h - 1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
runningOrder[j] = vv;
|
||||
}
|
||||
@@ -1341,7 +1318,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
--*/
|
||||
for (j = 0; j <= 255; j++) {
|
||||
sb = (ss << 8) + j;
|
||||
if(!((ftab[sb] & SETMASK) == SETMASK)) {
|
||||
if(!((ftab[sb] & SETMASK) == SETMASK) ) {
|
||||
int lo = ftab[sb] & CLEARMASK;
|
||||
int hi = (ftab[sb+1] & CLEARMASK) - 1;
|
||||
if (hi > lo) {
|
||||
@@ -1416,17 +1393,15 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
int i;
|
||||
int rNToGo = 0;
|
||||
int rTPos = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (i = 0; i < 256; i++)
|
||||
inUse[i] = false;
|
||||
}
|
||||
|
||||
for (i = 0; i <= last; i++) {
|
||||
if (rNToGo == 0) {
|
||||
rNToGo = (int)BZip2Constants.rNums[rTPos];
|
||||
rTPos++;
|
||||
if (rTPos == 512) {
|
||||
if(rTPos == 512)
|
||||
rTPos = 0;
|
||||
}
|
||||
}
|
||||
rNToGo--;
|
||||
block[i + 1] ^= (byte)((rNToGo == 1) ? 1 : 0);
|
||||
@@ -1507,9 +1482,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
c1 = block[i1 + 1];
|
||||
c2 = block[i2 + 1];
|
||||
if (c1 != c2) {
|
||||
if (c1 != c2)
|
||||
return c1 > c2;
|
||||
}
|
||||
i1++;
|
||||
i2++;
|
||||
|
||||
@@ -1598,11 +1572,9 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
because the number of elems to sort is
|
||||
usually small, typically <= 20.
|
||||
--*/
|
||||
readonly int[] incs = new int[] {
|
||||
1, 4, 13, 40, 121, 364, 1093, 3280,
|
||||
9841, 29524, 88573, 265720,
|
||||
797161, 2391484
|
||||
};
|
||||
readonly int[] incs = new int[] { 1, 4, 13, 40, 121, 364, 1093, 3280,
|
||||
9841, 29524, 88573, 265720,
|
||||
797161, 2391484 };
|
||||
|
||||
void AllocateCompressStructures()
|
||||
{
|
||||
@@ -1664,7 +1636,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
|
||||
j = 0;
|
||||
tmp = yy[j];
|
||||
while (ll_i != tmp) {
|
||||
while ( ll_i != tmp ) {
|
||||
j++;
|
||||
tmp2 = tmp;
|
||||
tmp = yy[j];
|
||||
@@ -1689,12 +1661,11 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
wr++;
|
||||
mtfFreq[BZip2Constants.RUNB]++;
|
||||
break;
|
||||
}
|
||||
if (zPend < 2) {
|
||||
};
|
||||
if (zPend < 2)
|
||||
break;
|
||||
}
|
||||
zPend = (zPend - 2) / 2;
|
||||
}
|
||||
};
|
||||
zPend = 0;
|
||||
}
|
||||
szptr[wr] = (short)(j + 1);
|
||||
@@ -1718,9 +1689,8 @@ namespace ICSharpCode.SharpZipLib.BZip2
|
||||
mtfFreq[BZip2Constants.RUNB]++;
|
||||
break;
|
||||
}
|
||||
if (zPend < 2) {
|
||||
if (zPend < 2)
|
||||
break;
|
||||
}
|
||||
zPend = (zPend - 2) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
2004-05-28 Duncan Mak <[email protected]>
|
||||
|
||||
* AssemblyInfo.cs: Use the new SharpZipLib.pub.
|
||||
* Zip/Compression/DeflaterHuffman.cs (FlushBlock): Add some
|
||||
parenthesis to help the generics compiler read this source.
|
||||
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
/// <summary>
|
||||
/// Computes Adler32 checksum for a stream of data. An Adler32
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
/// <summary>
|
||||
/// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
|
||||
@@ -97,7 +96,7 @@ namespace ICSharpCode.SharpZipLib.Checksums
|
||||
0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6,
|
||||
0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615,
|
||||
0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344,
|
||||
0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
|
||||
0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A,
|
||||
0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
@@ -119,15 +118,10 @@ namespace ICSharpCode.SharpZipLib.Checksums
|
||||
0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605,
|
||||
0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8,
|
||||
0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B,
|
||||
0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B,
|
||||
0x2D02EF8D
|
||||
};
|
||||
|
||||
internal static uint ComputeCrc32(uint oldCrc, byte bval)
|
||||
{
|
||||
return (uint)(Crc32.CrcTable[(oldCrc ^ bval) & 0xFF] ^ (oldCrc >> 8));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The crc data checksum so far.
|
||||
/// </summary>
|
||||
@@ -140,9 +134,6 @@ namespace ICSharpCode.SharpZipLib.Checksums
|
||||
get {
|
||||
return (long)crc;
|
||||
}
|
||||
set {
|
||||
crc = (uint)value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
/// <summary>
|
||||
/// Interface to compute a data checksum used by checked input/output streams.
|
||||
@@ -50,8 +49,7 @@ namespace ICSharpCode.SharpZipLib.Checksums
|
||||
/// <summary>
|
||||
/// Returns the data checksum computed so far.
|
||||
/// </summary>
|
||||
long Value
|
||||
{
|
||||
long Value {
|
||||
get;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,77 +38,76 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
public class StrangeCRC : IChecksum
|
||||
{
|
||||
readonly static uint[] crc32Table = {
|
||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
||||
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
||||
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
||||
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9,
|
||||
0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
||||
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011,
|
||||
0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
||||
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
|
||||
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
||||
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81,
|
||||
0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
||||
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49,
|
||||
0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
||||
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
|
||||
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
||||
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae,
|
||||
0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
||||
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
|
||||
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
||||
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
|
||||
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
||||
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066,
|
||||
0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
||||
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e,
|
||||
0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
||||
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
|
||||
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
||||
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
|
||||
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
||||
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686,
|
||||
0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
||||
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
|
||||
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
||||
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
|
||||
0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
||||
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47,
|
||||
0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
||||
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
|
||||
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
||||
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7,
|
||||
0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
||||
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f,
|
||||
0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
||||
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
|
||||
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
||||
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f,
|
||||
0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
||||
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
|
||||
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
||||
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
|
||||
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
||||
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30,
|
||||
0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
||||
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
|
||||
0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
||||
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
|
||||
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
||||
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
|
||||
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
||||
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0,
|
||||
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
||||
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
|
||||
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
||||
};
|
||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
||||
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
||||
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
||||
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9,
|
||||
0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
||||
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011,
|
||||
0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
||||
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
|
||||
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
||||
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81,
|
||||
0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
||||
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49,
|
||||
0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
||||
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
|
||||
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
||||
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae,
|
||||
0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
||||
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
|
||||
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
||||
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
|
||||
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
||||
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066,
|
||||
0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
||||
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e,
|
||||
0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
||||
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
|
||||
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
||||
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
|
||||
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
||||
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686,
|
||||
0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
||||
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
|
||||
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
||||
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
|
||||
0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
||||
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47,
|
||||
0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
||||
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
|
||||
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
||||
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7,
|
||||
0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
||||
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f,
|
||||
0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
||||
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
|
||||
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
||||
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f,
|
||||
0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
||||
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
|
||||
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
||||
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
|
||||
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
||||
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30,
|
||||
0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
||||
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
|
||||
0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
||||
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
|
||||
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
||||
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
|
||||
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
||||
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0,
|
||||
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
||||
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
|
||||
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
||||
};
|
||||
int globalCrc;
|
||||
|
||||
public StrangeCRC()
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.GZip {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for gzip.
|
||||
|
||||
@@ -42,8 +42,7 @@ using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.GZip {
|
||||
|
||||
/// <summary>
|
||||
/// This filter stream is used to decompress a "GZIP" format stream.
|
||||
@@ -81,6 +80,9 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
/// </example>
|
||||
public class GZipInputStream : InflaterInputStream
|
||||
{
|
||||
|
||||
//Variables
|
||||
|
||||
/// <summary>
|
||||
/// CRC-32 value for uncompressed data
|
||||
/// </summary>
|
||||
@@ -91,9 +93,6 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
/// </summary>
|
||||
protected bool eos;
|
||||
|
||||
// Have we read the GZIP header yet?
|
||||
bool readGZIPHeader;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a GzipInputStream with the default buffer size
|
||||
/// </summary>
|
||||
@@ -166,8 +165,8 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
Crc32 headCRC = new Crc32();
|
||||
int magic = baseInputStream.ReadByte();
|
||||
if (magic < 0) {
|
||||
eos = true;
|
||||
return;
|
||||
eos = true;
|
||||
return;
|
||||
}
|
||||
headCRC.Update(magic);
|
||||
if (magic != (GZipConstants.GZIP_MAGIC >> 8)) {
|
||||
@@ -247,8 +246,7 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
extraLen = (len1 << 8) | len2;
|
||||
for (int i = 0; i < extraLen;i++) {
|
||||
int readByte = baseInputStream.ReadByte();
|
||||
if (readByte < 0)
|
||||
{
|
||||
if (readByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
headCRC.Update(readByte);
|
||||
@@ -332,5 +330,8 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
*/
|
||||
eos = true;
|
||||
}
|
||||
|
||||
/* Have we read the GZIP header yet? */
|
||||
private bool readGZIPHeader;
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,7 @@ using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.GZip {
|
||||
|
||||
/// <summary>
|
||||
/// This filter stream is used to compress a stream into a "GZIP" stream.
|
||||
@@ -56,7 +55,7 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
/// using System;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using ICSharpCode.SharpZipLib.GZip; // -jr- corrected
|
||||
/// using NZlib.GZip;
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
@@ -104,12 +103,7 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
/// </param>
|
||||
public GZipOutputStream(Stream baseOutputStream, int size) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size)
|
||||
{
|
||||
WriteHeader();
|
||||
// System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )");
|
||||
}
|
||||
|
||||
void WriteHeader()
|
||||
{
|
||||
// TODO : find out correctness, orgininally this was : (int) (System.currentTimeMillis() / 1000L);
|
||||
int mod_time = (int)(DateTime.Now.Ticks / 10000L); // Ticks give back 100ns intervals
|
||||
byte[] gzipHeader = {
|
||||
/* The two magic bytes */
|
||||
@@ -131,7 +125,9 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
/* The OS type (unknown) */
|
||||
(byte) 255
|
||||
};
|
||||
|
||||
baseOutputStream.Write(gzipHeader, 0, gzipHeader.Length);
|
||||
// System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )");
|
||||
}
|
||||
|
||||
public override void Write(byte[] buf, int off, int len)
|
||||
@@ -166,7 +162,7 @@ namespace ICSharpCode.SharpZipLib.GZip
|
||||
(byte) totalin, (byte) (totalin >> 8),
|
||||
(byte) (totalin >> 16), (byte) (totalin >> 24)
|
||||
};
|
||||
|
||||
|
||||
baseOutputStream.Write(gzipFooter, 0, gzipFooter.Length);
|
||||
// System.err.println("wrote GZIP trailer (" + gzipFooter.length + " bytes )");
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// InvalidHeaderException.cs
|
||||
// BZip2OutputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -38,18 +38,18 @@ using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
public delegate void ProgressMessageHandler(TarArchive archive, TarEntry entry, string message);
|
||||
public delegate void ProgressMessageHandler(TarArchive archive, string message);
|
||||
|
||||
/// <summary>
|
||||
/// The TarArchive class implements the concept of a
|
||||
/// tar archive. A tar archive is a series of entries, each of
|
||||
/// which represents a file system object. Each entry in
|
||||
/// the archive consists of a header block. Directory entries
|
||||
/// consist only of the header block, and are followed by entries
|
||||
/// the archive consists of a header record. Directory entries
|
||||
/// consist only of the header record, and are followed by entries
|
||||
/// for the directory's contents. File entries consist of a
|
||||
/// header followed by the number of blocks needed to
|
||||
/// header record followed by the number of records needed to
|
||||
/// contain the file's contents. All entries are written on
|
||||
/// block boundaries. Blocks are 512 bytes long.
|
||||
/// record boundaries. Records are 512 bytes long.
|
||||
///
|
||||
/// TarArchives are instantiated in either read or write mode,
|
||||
/// based upon whether they are instantiated with an InputStream
|
||||
@@ -63,31 +63,31 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public class TarArchive
|
||||
{
|
||||
bool verbose;
|
||||
bool debug;
|
||||
bool keepOldFiles;
|
||||
bool asciiTranslate;
|
||||
protected bool verbose;
|
||||
protected bool debug;
|
||||
protected bool keepOldFiles;
|
||||
protected bool asciiTranslate;
|
||||
|
||||
int userId;
|
||||
string userName;
|
||||
int groupId;
|
||||
string groupName;
|
||||
protected int userId;
|
||||
protected string userName;
|
||||
protected int groupId;
|
||||
protected string groupName;
|
||||
|
||||
string rootPath;
|
||||
string pathPrefix;
|
||||
protected string rootPath;
|
||||
protected string pathPrefix;
|
||||
|
||||
int recordSize;
|
||||
byte[] recordBuf;
|
||||
protected int recordSize;
|
||||
protected byte[] recordBuf;
|
||||
|
||||
TarInputStream tarIn;
|
||||
TarOutputStream tarOut;
|
||||
protected TarInputStream tarIn;
|
||||
protected TarOutputStream tarOut;
|
||||
|
||||
public event ProgressMessageHandler ProgressMessageEvent;
|
||||
|
||||
protected virtual void OnProgressMessageEvent(TarEntry entry, string message)
|
||||
protected virtual void OnProgressMessageEvent(string message)
|
||||
{
|
||||
if (ProgressMessageEvent != null) {
|
||||
ProgressMessageEvent(this, entry, message);
|
||||
ProgressMessageEvent(this, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,14 +103,19 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream)
|
||||
{
|
||||
return CreateInputTarArchive(inputStream, TarBuffer.DefaultBlockFactor);
|
||||
return CreateInputTarArchive(inputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream, int blockFactor)
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream, int blockSize)
|
||||
{
|
||||
return CreateInputTarArchive(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarArchive archive = new TarArchive();
|
||||
archive.tarIn = new TarInputStream(inputStream, blockFactor);
|
||||
archive.Initialize(blockFactor * TarBuffer.BlockSize);
|
||||
archive.tarIn = new TarInputStream(inputStream, blockSize, recordSize);
|
||||
archive.Initialize(recordSize);
|
||||
return archive;
|
||||
}
|
||||
|
||||
@@ -121,23 +126,28 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream)
|
||||
{
|
||||
return CreateOutputTarArchive(outputStream, TarBuffer.DefaultBlockFactor);
|
||||
return CreateOutputTarArchive(outputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockFactor)
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockSize)
|
||||
{
|
||||
return CreateOutputTarArchive(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarArchive archive = new TarArchive();
|
||||
archive.tarOut = new TarOutputStream(outputStream, blockFactor);
|
||||
archive.Initialize(blockFactor * TarBuffer.BlockSize);
|
||||
archive.tarOut = new TarOutputStream(outputStream, blockSize, recordSize);
|
||||
archive.Initialize(recordSize);
|
||||
return archive;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Common constructor initialization code.
|
||||
/// </summary>
|
||||
void Initialize(int recordSize)
|
||||
{
|
||||
this.recordSize = recordSize;
|
||||
this.rootPath = null;
|
||||
this.pathPrefix = null;
|
||||
|
||||
@@ -155,11 +165,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
this.recordBuf = new byte[RecordSize];
|
||||
}
|
||||
|
||||
///
|
||||
/// <summary> Set the debugging flag. </summary>
|
||||
///
|
||||
/// <param name=debugF> The new debug setting. </param>
|
||||
|
||||
/**
|
||||
* Set the debugging flag.
|
||||
*
|
||||
* @param debugF The new debug setting.
|
||||
*/
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugF;
|
||||
@@ -196,7 +206,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the ascii file translation flag. If ascii file translation
|
||||
/// Set the ascii file translation flag. If ascii file translatio
|
||||
/// is true, then the MIME file type will be consulted to determine
|
||||
/// if the file is of type 'text/*'. If the MIME type is not found,
|
||||
/// then the TransFileTyper is consulted if it is not null. If
|
||||
@@ -204,7 +214,8 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// file, it will be translated. The translation converts the local
|
||||
/// operating system's concept of line ends into the UNIX line end,
|
||||
/// '\n', which is the defacto standard for a TAR archive. This makes
|
||||
/// text files compatible with UNIX.
|
||||
/// text files compatible with UNIX, and since most tar implementations
|
||||
/// text files compatible with UNIX, and since most tar implementations
|
||||
/// </summary>
|
||||
/// <param name= "asciiTranslate">
|
||||
/// If true, translate ascii text files.
|
||||
@@ -214,7 +225,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
this.asciiTranslate = asciiTranslate;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
/// <summary>
|
||||
/// Set the object that will determine if a file is of type
|
||||
/// ascii text for translation purposes.
|
||||
@@ -225,8 +236,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
public void SetTransFileTyper(TarTransFileTyper transTyper)
|
||||
{
|
||||
this.transTyper = transTyper;
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Set user and group information that will be used to fill in the
|
||||
@@ -305,11 +315,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// Get the archive's record size. Because of its history, tar
|
||||
/// supports the concept of buffered IO consisting of RECORDS of
|
||||
/// BLOCKS. This allowed tar to match the IO characteristics of
|
||||
/// supports the concept of buffered IO consisting of BLOCKS of
|
||||
/// RECORDS. This allowed tar to match the IO characteristics of
|
||||
/// the physical device being used. Of course, in the Java world,
|
||||
/// this makes no sense, WITH ONE EXCEPTION - archives are expected
|
||||
/// to be properly "blocked". Thus, all of the horrible TarBuffer
|
||||
/// to be propertly "blocked". Thus, all of the horrible TarBuffer
|
||||
/// support boils down to simply getting the "boundaries" correct.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
@@ -319,11 +329,10 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
get {
|
||||
if (this.tarIn != null) {
|
||||
return this.tarIn.GetRecordSize();
|
||||
}
|
||||
else if (this.tarOut != null) {
|
||||
} else if (this.tarOut != null) {
|
||||
return this.tarOut.GetRecordSize();
|
||||
}
|
||||
return TarBuffer.DefaultRecordSize;
|
||||
return TarBuffer.DEFAULT_RCDSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,8 +344,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
{
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.Close();
|
||||
}
|
||||
else if (this.tarOut != null) {
|
||||
} else if (this.tarOut != null) {
|
||||
this.tarOut.Flush();
|
||||
this.tarOut.Close();
|
||||
}
|
||||
@@ -356,11 +364,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
if (entry == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ EOF BLOCK");
|
||||
Console.Error.WriteLine("READ EOF RECORD");
|
||||
}
|
||||
break;
|
||||
}
|
||||
OnProgressMessageEvent(entry, null);
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,7 +385,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
if (entry == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ EOF BLOCK");
|
||||
Console.Error.WriteLine("READ EOF RECORD");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -391,22 +399,20 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
if (!Directory.Exists(directoryName)) {
|
||||
try {
|
||||
Directory.CreateDirectory(directoryName);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
throw new IOException("error making directory path '" + directoryName + "', " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO -jr- No longer reads entire file into memory but is still a weak test!
|
||||
|
||||
bool IsBinary(string filename)
|
||||
{
|
||||
FileStream fs = File.OpenRead(filename);
|
||||
|
||||
int sampleSize = System.Math.Min(4096, (int)fs.Length);
|
||||
byte[] content = new byte[sampleSize];
|
||||
byte[] content = new byte[fs.Length];
|
||||
|
||||
fs.Read(content, 0, sampleSize);
|
||||
fs.Read(content, 0, (int)fs.Length);
|
||||
fs.Close();
|
||||
|
||||
// assume that ascii 0 or
|
||||
@@ -434,7 +440,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
void ExtractEntry(string destDir, TarEntry entry)
|
||||
{
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry, null);
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
}
|
||||
|
||||
string name = entry.Name;
|
||||
@@ -448,17 +454,15 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
if (entry.IsDirectory) {
|
||||
EnsureDirectoryExists(destFile);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
string parentDirectory = Path.GetDirectoryName(destFile);
|
||||
EnsureDirectoryExists(parentDirectory);
|
||||
|
||||
if (this.keepOldFiles && File.Exists(destFile)) {
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry, "Destination file already exists");
|
||||
OnProgressMessageEvent("not overwriting " + entry.Name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
bool asciiTrans = false;
|
||||
Stream outputStream = File.Create(destFile);
|
||||
if (this.asciiTranslate) {
|
||||
@@ -508,16 +512,14 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
off = b + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
outputStream.Write(rdbuf, 0, numRead);
|
||||
}
|
||||
}
|
||||
|
||||
if (asciiTrans) {
|
||||
outw.Close();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
outputStream.Close();
|
||||
}
|
||||
}
|
||||
@@ -549,8 +551,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
//
|
||||
if (eFile == null || eFile.Length == 0) {
|
||||
entry = TarEntry.CreateTarEntry(entry.Name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//
|
||||
// The user may have explicitly set the entry's name to
|
||||
// something other than the file's path, so we must save
|
||||
@@ -563,12 +564,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry, null);
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
}
|
||||
|
||||
if (this.asciiTranslate && !entry.IsDirectory) {
|
||||
asciiTrans = !IsBinary(eFile);
|
||||
|
||||
// original java source :
|
||||
// MimeType mime = null;
|
||||
// string contentType = null;
|
||||
@@ -616,7 +616,6 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
inStream.Close();
|
||||
|
||||
outStream.Flush();
|
||||
outStream.Close();
|
||||
|
||||
@@ -651,8 +650,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
this.WriteEntry(list[i], recurse);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Stream inputStream = File.OpenRead(eFile);
|
||||
int numWritten = 0;
|
||||
byte[] eBuf = new byte[32 * 1024];
|
||||
@@ -666,8 +664,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
this.tarOut.Write(eBuf, 0, numRead);
|
||||
numWritten += numRead;
|
||||
}
|
||||
|
||||
// Console.WriteLine("written " + numWritten + " bytes");
|
||||
Console.WriteLine("written " + numWritten + " bytes");
|
||||
|
||||
inputStream.Close();
|
||||
|
||||
|
||||
@@ -36,15 +36,14 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// The TarBuffer class implements the tar archive concept
|
||||
/// of a buffered input stream. This concept goes back to the
|
||||
/// days of blocked tape drives and special io devices. In the
|
||||
/// C# universe, the only real function that this class
|
||||
/// performs is to ensure that files have the correct "record"
|
||||
/// performs is to ensure that files have the correct "block"
|
||||
/// size, or other tars will complain.
|
||||
/// <p>
|
||||
/// You should never have a need to access this class directly.
|
||||
@@ -53,68 +52,20 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </summary>
|
||||
public class TarBuffer
|
||||
{
|
||||
|
||||
/* A quote from GNU tar man file on blocking and records
|
||||
A `tar' archive file contains a series of blocks. Each block
|
||||
contains `BLOCKSIZE' bytes. Although this format may be thought of as
|
||||
being on magnetic tape, other media are often used.
|
||||
|
||||
Each file archived is represented by a header block which describes
|
||||
the file, followed by zero or more blocks which give the contents of
|
||||
the file. At the end of the archive file there may be a block filled
|
||||
with binary zeros as an end-of-file marker. A reasonable system should
|
||||
write a block of zeros at the end, but must not assume that such a
|
||||
block exists when reading an archive.
|
||||
|
||||
The blocks may be "blocked" for physical I/O operations. Each
|
||||
record of N blocks (where N is set by the `--blocking-factor=512-SIZE'
|
||||
(`-b 512-SIZE') option to `tar') is written with a single `write ()'
|
||||
operation. On magnetic tapes, the result of such a write is a single
|
||||
record. When writing an archive, the last record of blocks should be
|
||||
written at the full size, with blocks after the zero block containing
|
||||
all zeros. When reading an archive, a reasonable system should
|
||||
properly handle an archive whose last record is shorter than the rest,
|
||||
or which contains garbage records after a zero block.
|
||||
*/
|
||||
|
||||
// public static readonly int DEFAULT_RCDSIZE = 512;
|
||||
// public const int DEFAULT_BLOCKFACTOR = 20;
|
||||
// public static readonly int DEFAULT_BLKSIZE = DEFAULT_RCDSIZE * DEFAULT_BLOCKFACTOR;
|
||||
|
||||
public static readonly int BlockSize = 512;
|
||||
public static readonly int DefaultBlockFactor = 20;
|
||||
public static readonly int DefaultRecordSize = BlockSize * DefaultBlockFactor;
|
||||
public static readonly int DEFAULT_RCDSIZE = 512;
|
||||
public static readonly int DEFAULT_BLKSIZE = DEFAULT_RCDSIZE * 20;
|
||||
|
||||
Stream inputStream;
|
||||
Stream outputStream;
|
||||
|
||||
byte[] recordBuffer;
|
||||
int currentBlockIndex;
|
||||
int currentRecordIndex;
|
||||
|
||||
int recordSize = DefaultRecordSize;
|
||||
public int RecordSize
|
||||
{
|
||||
get { return recordSize; }
|
||||
}
|
||||
|
||||
int blockFactor = DefaultBlockFactor;
|
||||
|
||||
public int BlockFactor
|
||||
{
|
||||
get { return blockFactor; }
|
||||
}
|
||||
|
||||
bool debug = false;
|
||||
|
||||
/// <summary>
|
||||
/// Set the debugging flag for the buffer.
|
||||
/// </summary>
|
||||
public void SetDebug(bool debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
byte[] blockBuffer;
|
||||
int currBlkIdx;
|
||||
int currRecIdx;
|
||||
int blockSize;
|
||||
int recordSize;
|
||||
int recsPerBlock;
|
||||
|
||||
bool debug;
|
||||
|
||||
protected TarBuffer()
|
||||
{
|
||||
@@ -122,30 +73,36 @@ or which contains garbage records after a zero block.
|
||||
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream)
|
||||
{
|
||||
return CreateInputTarBuffer(inputStream, TarBuffer.DefaultBlockFactor);
|
||||
return CreateInputTarBuffer(inputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockFactor)
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockSize )
|
||||
{
|
||||
return CreateInputTarBuffer(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarBuffer tarBuffer = new TarBuffer();
|
||||
tarBuffer.inputStream = inputStream;
|
||||
tarBuffer.outputStream = null;
|
||||
tarBuffer.Initialize(blockFactor);
|
||||
tarBuffer.Initialize(blockSize, recordSize);
|
||||
|
||||
return tarBuffer;
|
||||
}
|
||||
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream)
|
||||
{
|
||||
return CreateOutputTarBuffer(outputStream, TarBuffer.DefaultBlockFactor);
|
||||
return CreateOutputTarBuffer(outputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockFactor)
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockSize )
|
||||
{
|
||||
return CreateOutputTarBuffer(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarBuffer tarBuffer = new TarBuffer();
|
||||
tarBuffer.inputStream = null;
|
||||
tarBuffer.outputStream = outputStream;
|
||||
tarBuffer.Initialize(blockFactor);
|
||||
tarBuffer.Initialize(blockSize, recordSize);
|
||||
|
||||
return tarBuffer;
|
||||
}
|
||||
@@ -153,32 +110,29 @@ or which contains garbage records after a zero block.
|
||||
/// <summary>
|
||||
/// Initialization common to all constructors.
|
||||
/// </summary>
|
||||
void Initialize(int blockFactor)
|
||||
void Initialize(int blockSize, int recordSize)
|
||||
{
|
||||
this.debug = false;
|
||||
this.blockFactor = blockFactor;
|
||||
this.recordSize = blockFactor * BlockSize;
|
||||
|
||||
this.recordBuffer = new byte[RecordSize];
|
||||
this.blockSize = blockSize;
|
||||
this.recordSize = recordSize;
|
||||
this.recsPerBlock = this.blockSize / this.recordSize;
|
||||
this.blockBuffer = new byte[this.blockSize];
|
||||
|
||||
if (inputStream != null)
|
||||
{
|
||||
this.currentRecordIndex = -1;
|
||||
this.currentBlockIndex = BlockFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentRecordIndex = 0;
|
||||
this.currentBlockIndex = 0;
|
||||
if (inputStream != null) {
|
||||
this.currBlkIdx = -1;
|
||||
this.currRecIdx = this.recsPerBlock;
|
||||
} else {
|
||||
this.currBlkIdx = 0;
|
||||
this.currRecIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the TAR Buffer's block factor
|
||||
/// Get the TAR Buffer's block size. Blocks consist of multiple records.
|
||||
/// </summary>
|
||||
public int GetBlockFactor()
|
||||
public int GetBlockSize()
|
||||
{
|
||||
return this.blockFactor;
|
||||
return this.blockSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -190,21 +144,24 @@ or which contains garbage records after a zero block.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if an archive block indicates End of Archive. End of
|
||||
/// archive is indicated by a block that consists entirely of null bytes.
|
||||
/// All remaining blocks for the record should also be null's
|
||||
/// However some older tars only do a couple of null blocks (Old GNU tar for one)
|
||||
/// and also partial records
|
||||
/// Set the debugging flag for the buffer.
|
||||
/// </summary>
|
||||
/// <param name = "block">
|
||||
/// The block data to check.
|
||||
/// </param>
|
||||
public bool IsEOFBlock(byte[] block)
|
||||
public void SetDebug(bool debug)
|
||||
{
|
||||
for (int i = 0, sz = BlockSize; i < sz; ++i)
|
||||
{
|
||||
if (block[i] != 0)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if an archive record indicate End of Archive. End of
|
||||
/// archive is indicated by a record that consists entirely of null bytes.
|
||||
/// </summary>
|
||||
/// <param name = "record">
|
||||
/// The record data to check.
|
||||
/// </param>
|
||||
public bool IsEOFRecord(byte[] record)
|
||||
{
|
||||
for (int i = 0, sz = this.GetRecordSize(); i < sz; ++i) {
|
||||
if (record[i] != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -213,175 +170,156 @@ or which contains garbage records after a zero block.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skip over a block on the input stream.
|
||||
/// Skip over a record on the input stream.
|
||||
/// </summary>
|
||||
public void SkipBlock()
|
||||
public void SkipRecord()
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("SkipBlock: recIdx = " + this.currentRecordIndex + " blkIdx = " + this.currentBlockIndex);
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("SkipRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
|
||||
if (this.inputStream == null)
|
||||
{
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream defined");
|
||||
}
|
||||
|
||||
if (this.currentBlockIndex >= this.BlockFactor)
|
||||
{
|
||||
if (!this.ReadRecord())
|
||||
{
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
if (!this.ReadBlock()) {
|
||||
return; // UNDONE
|
||||
}
|
||||
}
|
||||
|
||||
this.currentBlockIndex++;
|
||||
this.currRecIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a block from the input stream and return the data.
|
||||
/// Read a record from the input stream and return the data.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The block data.
|
||||
/// The record data.
|
||||
/// </returns>
|
||||
public byte[] ReadBlock()
|
||||
public byte[] ReadRecord()
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine( "ReadBlock: blockIndex = " + this.currentBlockIndex + " recordIndex = " + this.currentRecordIndex );
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine( "ReadRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
}
|
||||
|
||||
if (this.inputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.ReadBlock - no input stream defined");
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream defined");
|
||||
}
|
||||
|
||||
if (this.currentBlockIndex >= this.BlockFactor)
|
||||
{
|
||||
if (!this.ReadRecord())
|
||||
{
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
if (!this.ReadBlock()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] result = new byte[BlockSize];
|
||||
byte[] result = new byte[this.recordSize];
|
||||
|
||||
Array.Copy(this.recordBuffer, (this.currentBlockIndex * BlockSize), result, 0, BlockSize );
|
||||
this.currentBlockIndex++;
|
||||
Array.Copy(this.blockBuffer, (this.currRecIdx * this.recordSize), result, 0, this.recordSize );
|
||||
this.currRecIdx++;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <returns>
|
||||
/// false if End-Of-File, else true
|
||||
/// </returns>
|
||||
bool ReadRecord()
|
||||
bool ReadBlock()
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("ReadRecord: recordIndex = " + this.currentRecordIndex);
|
||||
Console.WriteLine(this.debug);
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("ReadBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
|
||||
if (this.inputStream == null)
|
||||
{
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream stream defined");
|
||||
}
|
||||
|
||||
this.currentBlockIndex = 0;
|
||||
this.currRecIdx = 0;
|
||||
|
||||
int offset = 0;
|
||||
int bytesNeeded = RecordSize;
|
||||
|
||||
while (bytesNeeded > 0)
|
||||
{
|
||||
long numBytes = this.inputStream.Read(this.recordBuffer, offset, bytesNeeded);
|
||||
int bytesNeeded = this.blockSize;
|
||||
for (; bytesNeeded > 0 ;) {
|
||||
long numBytes = this.inputStream.Read(this.blockBuffer, offset, bytesNeeded);
|
||||
|
||||
//
|
||||
// NOTE
|
||||
// We have found EOF, and the record is not full!
|
||||
// We have fit EOF, and the block is not full!
|
||||
//
|
||||
// This is a broken archive. It does not follow the standard
|
||||
// blocking algorithm. However, because we are generous, and
|
||||
// it requires little effort, we will simply ignore the error
|
||||
// and continue as if the entire record were read. This does
|
||||
// and continue as if the entire block were read. This does
|
||||
// not appear to break anything upstream. We used to return
|
||||
// false in this case.
|
||||
//
|
||||
// Thanks to '[email protected]' for this fix.
|
||||
//
|
||||
if (numBytes <= 0)
|
||||
{
|
||||
if (numBytes <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
offset += (int)numBytes;
|
||||
bytesNeeded -= (int)numBytes;
|
||||
if (numBytes != RecordSize)
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("ReadRecord: INCOMPLETE READ " + numBytes + " of " + this.blockSize + " bytes read.");
|
||||
if (numBytes != this.blockSize) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("ReadBlock: INCOMPLETE READ " + numBytes + " of " + this.blockSize + " bytes read.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.currentRecordIndex++;
|
||||
this.currBlkIdx++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current block number, within the current record, zero based.
|
||||
/// Get the current block number, zero based.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current zero based block number.
|
||||
/// </returns>
|
||||
public int GetCurrentBlockNum()
|
||||
{
|
||||
return this.currentBlockIndex;
|
||||
return this.currBlkIdx;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current record number
|
||||
/// Absolute block number in file = (currentRecordNum * block factor) + currentBlockNum.
|
||||
/// Get the current record number, within the current block, zero based.
|
||||
/// Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current zero based record number.
|
||||
/// </returns>
|
||||
public int GetCurrentRecordNum()
|
||||
{
|
||||
return this.currentRecordIndex;
|
||||
return this.currRecIdx - 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an archive block to the archive.
|
||||
/// Write an archive record to the archive.
|
||||
/// </summary>
|
||||
/// <param name="block">
|
||||
/// The data to write to the archive.
|
||||
/// <param name="record">
|
||||
/// The record data to write to the archive.
|
||||
/// </param>
|
||||
///
|
||||
public void WriteBlock(byte[] block)
|
||||
public void WriteRecord(byte[] record)
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("WriteRecord: recIdx = " + this.currentRecordIndex + " blkIdx = " + this.currentBlockIndex );
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
}
|
||||
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - no output stream defined");
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream defined");
|
||||
}
|
||||
|
||||
if (block.Length != BlockSize)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - block to write has length '" + block.Length + "' which is not the block size of '" + BlockSize + "'" );
|
||||
if (record.Length != this.recordSize) {
|
||||
throw new IOException("record to write has length '" + record.Length + "' which is not the record size of '" + this.recordSize + "'" );
|
||||
}
|
||||
|
||||
if (this.currentBlockIndex >= BlockFactor)
|
||||
{
|
||||
this.WriteRecord();
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.WriteBlock();
|
||||
}
|
||||
|
||||
Array.Copy(block, 0, this.recordBuffer, (this.currentBlockIndex * BlockSize), BlockSize);
|
||||
this.currentBlockIndex++;
|
||||
Array.Copy(record, 0, this.blockBuffer, (this.currRecIdx * this.recordSize), this.recordSize );
|
||||
this.currRecIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -395,53 +333,47 @@ or which contains garbage records after a zero block.
|
||||
/// <param name="offset">
|
||||
/// The offset of the record data within buf.
|
||||
/// </param>
|
||||
public void WriteBlock(byte[] buf, int offset)
|
||||
public void WriteRecord(byte[] buf, int offset)
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("WriteBlock: recIdx = " + this.currentRecordIndex + " blkIdx = " + this.currentBlockIndex );
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
}
|
||||
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - no output stream stream defined");
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream stream defined");
|
||||
}
|
||||
|
||||
if ((offset + BlockSize) > buf.Length)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - record has length '" + buf.Length + "' with offset '" + offset + "' which is less than the record size of '" + this.recordSize + "'" );
|
||||
if ((offset + this.recordSize) > buf.Length) {
|
||||
throw new IOException("record has length '" + buf.Length + "' with offset '" + offset + "' which is less than the record size of '" + this.recordSize + "'" );
|
||||
}
|
||||
|
||||
if (this.currentBlockIndex >= this.BlockFactor)
|
||||
{
|
||||
this.WriteRecord();
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.WriteBlock();
|
||||
}
|
||||
|
||||
Array.Copy(buf, offset, this.recordBuffer, (this.currentBlockIndex * BlockSize), BlockSize);
|
||||
Array.Copy(buf, offset, this.blockBuffer, (this.currRecIdx * this.recordSize), this.recordSize );
|
||||
|
||||
this.currentBlockIndex++;
|
||||
this.currRecIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a TarBuffer record to the archive.
|
||||
/// Write a TarBuffer block to the archive.
|
||||
/// </summary>
|
||||
void WriteRecord()
|
||||
void WriteBlock()
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("Writerecord: record index = " + this.currentRecordIndex);
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteRecord no output stream defined");
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream defined");
|
||||
}
|
||||
|
||||
this.outputStream.Write(this.recordBuffer, 0, RecordSize);
|
||||
this.outputStream.Write(this.blockBuffer, 0, this.blockSize);
|
||||
this.outputStream.Flush();
|
||||
|
||||
this.currentBlockIndex = 0;
|
||||
this.currentRecordIndex++;
|
||||
this.currRecIdx = 0;
|
||||
this.currBlkIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -449,19 +381,16 @@ or which contains garbage records after a zero block.
|
||||
/// </summary>
|
||||
void Flush()
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("TarBuffer.FlushBlock() called.");
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarBuffer.FlushBlock() called.");
|
||||
}
|
||||
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.Flush no output stream defined");
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output base stream defined");
|
||||
}
|
||||
|
||||
if (this.currentBlockIndex > 0)
|
||||
{
|
||||
this.WriteRecord();
|
||||
if (this.currRecIdx > 0) {
|
||||
this.WriteBlock();
|
||||
}
|
||||
outputStream.Flush();
|
||||
}
|
||||
@@ -472,27 +401,25 @@ or which contains garbage records after a zero block.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("TarBuffer.Close().");
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarBuffer.Close().");
|
||||
}
|
||||
|
||||
if (outputStream != null)
|
||||
{
|
||||
if (outputStream != null ) {
|
||||
Flush();
|
||||
|
||||
// if ( this.outStream != System.out
|
||||
// && this.outStream != System.err ) {
|
||||
outputStream.Close();
|
||||
outputStream = null;
|
||||
}
|
||||
else if (inputStream != null)
|
||||
{
|
||||
} else if (inputStream != null) {
|
||||
// if (this.inStream != System.in ) {
|
||||
inputStream.Close();
|
||||
inputStream = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
|
||||
@@ -36,8 +36,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// This class represents an entry in a Tar archive. It consists
|
||||
@@ -65,6 +64,27 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// other information. In this case the header fields are set to
|
||||
/// defaults and the File is set to null.</p>
|
||||
///
|
||||
/// <p>
|
||||
/// The C structure for a Tar Entry's header is:
|
||||
/// <pre>
|
||||
/// struct header {
|
||||
/// char name[NAMSIZ];
|
||||
/// char mode[8];
|
||||
/// char uid[8];
|
||||
/// char gid[8];
|
||||
/// char size[12];
|
||||
/// char mtime[12];
|
||||
/// char chksum[8];
|
||||
/// char linkflag;
|
||||
/// char linkname[NAMSIZ];
|
||||
/// char magic[8];
|
||||
/// char uname[TUNMLEN];
|
||||
/// char gname[TGNMLEN];
|
||||
/// char devmajor[8];
|
||||
/// char devminor[8];
|
||||
/// } header;
|
||||
/// </pre>
|
||||
/// </p>
|
||||
/// <see cref="TarHeader"/>
|
||||
/// </summary>
|
||||
public class TarEntry
|
||||
@@ -72,12 +92,12 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// If this entry represents a File, this references it.
|
||||
/// </summary>
|
||||
string file;
|
||||
protected string file;
|
||||
|
||||
/// <summary>
|
||||
/// This is the entry's header information.
|
||||
/// </summary>
|
||||
TarHeader header;
|
||||
protected TarHeader header;
|
||||
|
||||
/// <summary>
|
||||
/// Only Create Entries with the static CreateXYZ methods or a headerBuffer.
|
||||
@@ -96,15 +116,10 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
public TarEntry(byte[] headerBuf)
|
||||
{
|
||||
this.Initialize();
|
||||
this.header.ParseBuffer(headerBuf);
|
||||
this.ParseTarHeader(this.header, headerBuf);
|
||||
}
|
||||
|
||||
|
||||
public TarEntry(TarHeader header)
|
||||
{
|
||||
file = null;
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Construct an entry with only a name. This allows the programmer
|
||||
@@ -134,7 +149,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialization code common to all pseudo constructors.
|
||||
/// Initialization code common to all constructors.
|
||||
/// </summary>
|
||||
void Initialize()
|
||||
{
|
||||
@@ -151,8 +166,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public override bool Equals(object it)
|
||||
{
|
||||
if (!(it is TarEntry))
|
||||
{
|
||||
if (!(it is TarEntry)) {
|
||||
return false;
|
||||
}
|
||||
return this.header.name.ToString().Equals(((TarEntry)it).header.name.ToString());
|
||||
@@ -189,10 +203,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <returns>
|
||||
/// This entry's TarHeader.
|
||||
/// </returns>
|
||||
public TarHeader TarHeader
|
||||
{
|
||||
get
|
||||
{
|
||||
public TarHeader TarHeader {
|
||||
get {
|
||||
return this.header;
|
||||
}
|
||||
}
|
||||
@@ -200,14 +212,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Get/Set this entry's name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
public string Name {
|
||||
get {
|
||||
return this.header.name.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.name = new StringBuilder(value);
|
||||
}
|
||||
}
|
||||
@@ -215,14 +224,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Get/set this entry's user id.
|
||||
/// </summary>
|
||||
public int UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
public int UserId {
|
||||
get {
|
||||
return this.header.userId;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.userId = value;
|
||||
}
|
||||
}
|
||||
@@ -230,14 +236,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Get/set this entry's group id.
|
||||
/// </summary>
|
||||
public int GroupId
|
||||
{
|
||||
get
|
||||
{
|
||||
public int GroupId {
|
||||
get {
|
||||
return this.header.groupId;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.groupId = value;
|
||||
}
|
||||
}
|
||||
@@ -245,14 +248,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Get/set this entry's user name.
|
||||
/// </summary>
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
public string UserName {
|
||||
get {
|
||||
return this.header.userName.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.userName = new StringBuilder(value);
|
||||
}
|
||||
}
|
||||
@@ -260,14 +260,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Get/set this entry's group name.
|
||||
/// </summary>
|
||||
public string GroupName
|
||||
{
|
||||
get
|
||||
{
|
||||
public string GroupName {
|
||||
get {
|
||||
return this.header.groupName.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.groupName = new StringBuilder(value);
|
||||
}
|
||||
}
|
||||
@@ -302,17 +299,17 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
GroupName = groupName;
|
||||
}
|
||||
|
||||
// TODO :
|
||||
// /**
|
||||
// * Set this entry's modification time. The parameter passed
|
||||
// * to this method is in "Java time".
|
||||
// *
|
||||
// * @param time This entry's new modification time.
|
||||
// */
|
||||
// public void setModTime( long time )
|
||||
// {
|
||||
// this.header.modTime = time / 1000;
|
||||
// }
|
||||
// TODO :
|
||||
// /**
|
||||
// * Set this entry's modification time. The parameter passed
|
||||
// * to this method is in "Java time".
|
||||
// *
|
||||
// * @param time This entry's new modification time.
|
||||
// */
|
||||
// public void setModTime( long time )
|
||||
// {
|
||||
// this.header.modTime = time / 1000;
|
||||
// }
|
||||
|
||||
/// Convert time to DateTimes
|
||||
/**
|
||||
@@ -320,14 +317,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
*
|
||||
* @param time This entry's new modification time.
|
||||
*/
|
||||
public DateTime ModTime
|
||||
{
|
||||
get
|
||||
{
|
||||
public DateTime ModTime {
|
||||
get {
|
||||
return this.header.modTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.modTime = value;
|
||||
}
|
||||
}
|
||||
@@ -338,10 +332,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <returns>
|
||||
/// This entry's file.
|
||||
/// </returns>
|
||||
public string File
|
||||
{
|
||||
get
|
||||
{
|
||||
public string File {
|
||||
get {
|
||||
return this.file;
|
||||
}
|
||||
}
|
||||
@@ -349,14 +341,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Get/set this entry's file size.
|
||||
/// </summary>
|
||||
public long Size
|
||||
{
|
||||
get
|
||||
{
|
||||
public long Size {
|
||||
get {
|
||||
return this.header.size;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
this.header.size = value;
|
||||
}
|
||||
}
|
||||
@@ -385,17 +374,13 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public bool IsDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.file != null)
|
||||
{
|
||||
get {
|
||||
if (this.file != null) {
|
||||
return Directory.Exists(file);
|
||||
}
|
||||
|
||||
if (this.header != null)
|
||||
{
|
||||
if (this.header.typeFlag == TarHeader.LF_DIR || this.header.name.ToString().EndsWith( "/" ))
|
||||
{
|
||||
if (this.header != null) {
|
||||
if (this.header.linkFlag == TarHeader.LF_DIR || this.header.name.ToString().EndsWith( "/" )) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -415,61 +400,50 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
public void GetFileTarHeader(TarHeader hdr, string file)
|
||||
{
|
||||
this.file = file;
|
||||
|
||||
// bugfix from torhovl from #D forum:
|
||||
string name = file;
|
||||
|
||||
// -jr- 23-Jan-2004 HAK HAK HAK, GnuTar allows device names in path where the name is not local to the current directory
|
||||
if (Environment.CurrentDirectory == Path.GetDirectoryName(name))
|
||||
{
|
||||
name = Path.GetFileName(name);
|
||||
}
|
||||
/*
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
{ // check if the OS is Windows
|
||||
|
||||
string name = Path.GetDirectoryName(file);
|
||||
|
||||
if (Path.DirectorySeparatorChar == '\\') { // check if the OS is a windows
|
||||
// Strip off drive letters!
|
||||
if (name.Length > 2)
|
||||
{
|
||||
if (name.Length > 2) {
|
||||
char ch1 = name[0];
|
||||
char ch2 = name[1];
|
||||
|
||||
if (ch2 == ':' && Char.IsLetter(ch1))
|
||||
{
|
||||
if (ch2 == ':' && Char.IsLetter(ch1)) {
|
||||
name = name.Substring(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
name = name.Replace(Path.DirectorySeparatorChar, '/').ToLower();
|
||||
|
||||
name = name.Replace(Path.DirectorySeparatorChar, '/');
|
||||
|
||||
// No absolute pathnames
|
||||
// Windows (and Posix?) paths can start with UNC style "\\NetworkDrive\",
|
||||
// Windows (and Posix?) paths can start with "\\NetworkDrive\",
|
||||
// so we loop on starting /'s.
|
||||
while (name.StartsWith("/")) {
|
||||
name = name.Substring(1);
|
||||
}
|
||||
|
||||
|
||||
hdr.linkName = new StringBuilder(String.Empty);
|
||||
hdr.name = new StringBuilder(name);
|
||||
|
||||
if (Directory.Exists(file)) {
|
||||
hdr.mode = 1003; // 01753 -jr- no octal constants!! 040755; // Magic number for security access for a UNIX filesystem
|
||||
hdr.typeFlag = TarHeader.LF_DIR;
|
||||
if (hdr.name.Length == 0 || hdr.name[hdr.name.Length - 1] != '/') {
|
||||
hdr.mode = 040755; // TODO : what does this magic number ?? Mike
|
||||
hdr.linkFlag = TarHeader.LF_DIR;
|
||||
if (hdr.name[hdr.name.Length - 1] != '/') {
|
||||
hdr.name.Append("/");
|
||||
}
|
||||
|
||||
hdr.size = 0;
|
||||
} else {
|
||||
hdr.mode = 33216; // 0100700 -jr- // 0100644; // Magic number for security access for a UNIX filesystem
|
||||
hdr.typeFlag = TarHeader.LF_NORMAL;
|
||||
hdr.mode = 0100644; // TODO : again a magic number
|
||||
hdr.linkFlag = TarHeader.LF_NORMAL;
|
||||
Console.WriteLine(file.Replace('/', Path.DirectorySeparatorChar));
|
||||
hdr.size = new FileInfo(file.Replace('/', Path.DirectorySeparatorChar)).Length;
|
||||
}
|
||||
|
||||
// UNDONE When File lets us get the userName, use it!
|
||||
hdr.modTime = System.IO.File.GetLastWriteTimeUtc(file.Replace('/', Path.DirectorySeparatorChar)); // -jr- Unix times are in UTC
|
||||
hdr.checkSum = 0;
|
||||
hdr.modTime = System.IO.File.GetLastAccessTime(file.Replace('/', Path.DirectorySeparatorChar));
|
||||
hdr.checkSum = 0;
|
||||
hdr.devMajor = 0;
|
||||
hdr.devMinor = 0;
|
||||
}
|
||||
@@ -483,23 +457,44 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public TarEntry[] GetDirectoryEntries()
|
||||
{
|
||||
if (this.file == null || !Directory.Exists(this.file))
|
||||
{
|
||||
if (this.file == null || !Directory.Exists(this.file)) {
|
||||
return new TarEntry[0];
|
||||
}
|
||||
|
||||
string[] list = Directory.GetFileSystemEntries(this.file);
|
||||
TarEntry[] result = new TarEntry[list.Length];
|
||||
|
||||
for (int i = 0; i < list.Length; ++i)
|
||||
{
|
||||
|
||||
string dirName = file;
|
||||
if (!dirName.EndsWith(Path.DirectorySeparatorChar.ToString())) {
|
||||
dirName += Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.Length; ++i) {
|
||||
result[i] = TarEntry.CreateEntryFromFile(list[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Compute the checksum of a tar entry header.
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// The tar entry's header buffer.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The computed checksum.
|
||||
/// </returns>
|
||||
public long ComputeCheckSum(byte[] buf)
|
||||
{
|
||||
long sum = 0;
|
||||
for (int i = 0; i < buf.Length; ++i) {
|
||||
sum += 255 & buf[i]; // TODO : I think the 255 & x isn't neccessary += buf[i] should be enough. CHECK IT!
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an entry's header information to a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "outbuf">
|
||||
@@ -507,7 +502,120 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </param>
|
||||
public void WriteEntryHeader(byte[] outbuf)
|
||||
{
|
||||
this.header.WriteHeader(outbuf);
|
||||
int offset = 0;
|
||||
|
||||
offset = TarHeader.GetNameBytes(this.header.name, outbuf, offset, TarHeader.NAMELEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.mode, outbuf, offset, TarHeader.MODELEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.userId, outbuf, offset, TarHeader.UIDLEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.groupId, outbuf, offset, TarHeader.GIDLEN);
|
||||
|
||||
long size = this.header.size;
|
||||
|
||||
offset = TarHeader.GetLongOctalBytes(size, outbuf, offset, TarHeader.SIZELEN);
|
||||
offset = TarHeader.GetLongOctalBytes(GetCTime(this.header.modTime), outbuf, offset, TarHeader.MODTIMELEN);
|
||||
|
||||
int csOffset = offset;
|
||||
for (int c = 0; c < TarHeader.CHKSUMLEN; ++c) {
|
||||
outbuf[offset++] = (byte)' ';
|
||||
}
|
||||
|
||||
outbuf[offset++] = this.header.linkFlag;
|
||||
|
||||
offset = TarHeader.GetNameBytes(this.header.linkName, outbuf, offset, TarHeader.NAMELEN);
|
||||
offset = TarHeader.GetNameBytes(this.header.magic, outbuf, offset, TarHeader.MAGICLEN);
|
||||
offset = TarHeader.GetNameBytes(this.header.userName, outbuf, offset, TarHeader.UNAMELEN);
|
||||
offset = TarHeader.GetNameBytes(this.header.groupName, outbuf, offset, TarHeader.GNAMELEN);
|
||||
|
||||
offset = TarHeader.GetOctalBytes(this.header.devMajor, outbuf, offset, TarHeader.DEVLEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.devMinor, outbuf, offset, TarHeader.DEVLEN);
|
||||
|
||||
for (; offset < outbuf.Length;) {
|
||||
outbuf[offset++] = 0;
|
||||
}
|
||||
|
||||
long checkSum = this.ComputeCheckSum(outbuf);
|
||||
|
||||
TarHeader.GetCheckSumOctalBytes(checkSum, outbuf, csOffset, TarHeader.CHKSUMLEN);
|
||||
}
|
||||
|
||||
// time conversion functions
|
||||
readonly static long timeConversionFactor = 10000000L;
|
||||
readonly static DateTime datetTime1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
|
||||
static int GetCTime(System.DateTime dateTime)
|
||||
{
|
||||
return (int)((dateTime.Ticks - datetTime1970.Ticks) / timeConversionFactor);
|
||||
}
|
||||
|
||||
static DateTime GetDateTimeFromCTime(long ticks)
|
||||
{
|
||||
return new DateTime(datetTime1970.Ticks + ticks * timeConversionFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an entry's TarHeader information from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name ="hdr">
|
||||
/// Parse an entry's TarHeader information from a header buffer.
|
||||
/// </param>
|
||||
/// <param name = "header">
|
||||
/// The tar entry header buffer to get information from.
|
||||
/// </param>
|
||||
public void ParseTarHeader(TarHeader hdr, byte[] header)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
hdr.name = TarHeader.ParseName(header, offset, TarHeader.NAMELEN);
|
||||
|
||||
offset += TarHeader.NAMELEN;
|
||||
|
||||
hdr.mode = (int)TarHeader.ParseOctal(header, offset, TarHeader.MODELEN);
|
||||
|
||||
offset += TarHeader.MODELEN;
|
||||
|
||||
hdr.userId = (int)TarHeader.ParseOctal(header, offset, TarHeader.UIDLEN);
|
||||
|
||||
offset += TarHeader.UIDLEN;
|
||||
|
||||
hdr.groupId = (int)TarHeader.ParseOctal(header, offset, TarHeader.GIDLEN);
|
||||
|
||||
offset += TarHeader.GIDLEN;
|
||||
|
||||
hdr.size = TarHeader.ParseOctal(header, offset, TarHeader.SIZELEN);
|
||||
|
||||
offset += TarHeader.SIZELEN;
|
||||
|
||||
hdr.modTime = GetDateTimeFromCTime(TarHeader.ParseOctal(header, offset, TarHeader.MODTIMELEN));
|
||||
|
||||
offset += TarHeader.MODTIMELEN;
|
||||
|
||||
hdr.checkSum = (int)TarHeader.ParseOctal(header, offset, TarHeader.CHKSUMLEN);
|
||||
|
||||
offset += TarHeader.CHKSUMLEN;
|
||||
|
||||
hdr.linkFlag = header[ offset++ ];
|
||||
|
||||
hdr.linkName = TarHeader.ParseName(header, offset, TarHeader.NAMELEN);
|
||||
|
||||
offset += TarHeader.NAMELEN;
|
||||
|
||||
hdr.magic = TarHeader.ParseName(header, offset, TarHeader.MAGICLEN);
|
||||
|
||||
offset += TarHeader.MAGICLEN;
|
||||
|
||||
hdr.userName = TarHeader.ParseName(header, offset, TarHeader.UNAMELEN);
|
||||
|
||||
offset += TarHeader.UNAMELEN;
|
||||
|
||||
hdr.groupName = TarHeader.ParseName(header, offset, TarHeader.GNAMELEN);
|
||||
|
||||
offset += TarHeader.GNAMELEN;
|
||||
|
||||
hdr.devMajor = (int)TarHeader.ParseOctal(header, offset, TarHeader.DEVLEN);
|
||||
|
||||
offset += TarHeader.DEVLEN;
|
||||
|
||||
hdr.devMinor = (int)TarHeader.ParseOctal(header, offset, TarHeader.DEVLEN);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -521,22 +629,22 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </param>
|
||||
public void NameTarHeader(TarHeader hdr, string name)
|
||||
{
|
||||
bool isDir = name.EndsWith("/"); // -jr- this is true for BSD tar but not all others I think?
|
||||
bool isDir = name.EndsWith("/");
|
||||
|
||||
hdr.checkSum = 0;
|
||||
hdr.devMajor = 0;
|
||||
hdr.devMinor = 0;
|
||||
|
||||
hdr.name = new StringBuilder(name);
|
||||
// hdr.mode = isDir ? 040755 : 0100644; // TODO : I think I've seen these magics before ...
|
||||
hdr.mode = isDir ? 1003 : 33216;
|
||||
hdr.userId = 0;
|
||||
hdr.mode = isDir ? 040755 : 0100644; // TODO : I think I've seen these magics before ...
|
||||
hdr.userId = 0;
|
||||
hdr.groupId = 0;
|
||||
hdr.size = 0;
|
||||
hdr.checkSum = 0;
|
||||
|
||||
hdr.modTime = DateTime.UtcNow; // -jr- 24-Jan-2004 Unix times are in utc!
|
||||
// hdr.modTime = DateTime.Now; // (new java.util.Date()).getTime() / 1000;
|
||||
hdr.modTime = DateTime.Now;//(new java.util.Date()).getTime() / 1000;
|
||||
|
||||
hdr.typeFlag = isDir ? TarHeader.LF_DIR : TarHeader.LF_NORMAL;
|
||||
hdr.linkFlag = isDir ? TarHeader.LF_DIR : TarHeader.LF_NORMAL;
|
||||
|
||||
hdr.linkName = new StringBuilder(String.Empty);
|
||||
hdr.userName = new StringBuilder(String.Empty);
|
||||
@@ -547,9 +655,6 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// TarHeader.cs
|
||||
//
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
@@ -33,41 +32,10 @@
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
|
||||
/* The tar format and its POSIX successor PAX have a long history which makes for compatability
|
||||
issues when creating and reading files...
|
||||
|
||||
This is the ustar (Posix 1003.1) header.
|
||||
|
||||
struct header
|
||||
{
|
||||
char t_name[100]; // 0 Filename
|
||||
char t_mode[8]; // 100 Permissions
|
||||
char t_uid[8]; // 108 Numerical User ID
|
||||
char t_gid[8]; // 116 Numerical Group ID
|
||||
char t_size[12]; // 124 Filesize
|
||||
char t_mtime[12]; // 136 st_mtime
|
||||
char t_chksum[8]; // 148 Checksum
|
||||
char t_typeflag; // 156 Type of File
|
||||
char t_linkname[100]; // 157 Target of Links
|
||||
char t_magic[6]; // 257 "ustar"
|
||||
char t_version[2]; // 263 Version fixed to 00
|
||||
char t_uname[32]; // 265 User Name
|
||||
char t_gname[32]; // 297 Group Name
|
||||
char t_devmajor[8]; // 329 Major for devices
|
||||
char t_devminor[8]; // 337 Minor for devices
|
||||
char t_prefix[155]; // 345 Prefix for t_name
|
||||
// 500 End
|
||||
char t_mfill[12]; // 500 Filler up to 512
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -109,13 +77,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// The length of the magic field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int MAGICLEN = 6;
|
||||
public readonly static int MAGICLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the version field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int VERSIONLEN = 2;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the modification time field in a header buffer.
|
||||
/// </summary>
|
||||
@@ -137,109 +100,58 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
public readonly static int DEVLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// LF_ constants represents the "type" of an entry
|
||||
/// LF_ constants represent the "link flag" of an entry, or more commonly,
|
||||
/// the "entry type". This is the "old way" of indicating a normal file.
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// This is the "old way" of indicating a normal file.
|
||||
/// </summary>
|
||||
public const byte LF_OLDNORM = 0;
|
||||
public readonly static byte LF_OLDNORM = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Normal file type.
|
||||
/// </summary>
|
||||
public const byte LF_NORMAL = (byte) '0';
|
||||
public readonly static byte LF_NORMAL = (byte) '0';
|
||||
|
||||
/// <summary>
|
||||
/// Link file type.
|
||||
/// </summary>
|
||||
public const byte LF_LINK = (byte) '1';
|
||||
public readonly static byte LF_LINK = (byte) '1';
|
||||
|
||||
/// <summary>
|
||||
/// Symbolic link file type.
|
||||
/// </summary>
|
||||
public const byte LF_SYMLINK = (byte) '2';
|
||||
public readonly static byte LF_SYMLINK = (byte) '2';
|
||||
|
||||
/// <summary>
|
||||
/// Character device file type.
|
||||
/// </summary>
|
||||
public const byte LF_CHR = (byte) '3';
|
||||
public readonly static byte LF_CHR = (byte) '3';
|
||||
|
||||
/// <summary>
|
||||
/// Block device file type.
|
||||
/// </summary>
|
||||
public const byte LF_BLK = (byte) '4';
|
||||
public readonly static byte LF_BLK = (byte) '4';
|
||||
|
||||
/// <summary>
|
||||
/// Directory file type.
|
||||
/// </summary>
|
||||
public const byte LF_DIR = (byte) '5';
|
||||
public readonly static byte LF_DIR = (byte) '5';
|
||||
|
||||
/// <summary>
|
||||
/// FIFO (pipe) file type.
|
||||
/// </summary>
|
||||
public const byte LF_FIFO = (byte) '6';
|
||||
public readonly static byte LF_FIFO = (byte) '6';
|
||||
|
||||
/// <summary>
|
||||
/// Contiguous file type.
|
||||
/// </summary>
|
||||
public const byte LF_CONTIG = (byte) '7';
|
||||
public readonly static byte LF_CONTIG = (byte) '7';
|
||||
|
||||
/// <summary>
|
||||
/// Posix.1 2001 global extended header
|
||||
/// The magic tag representing a POSIX tar archive.
|
||||
/// </summary>
|
||||
///
|
||||
public const byte LF_GHDR = (byte) 'g';
|
||||
public readonly static string TMAGIC = "ustar";
|
||||
|
||||
/// <summary>
|
||||
/// Posix.1 2001 extended header
|
||||
/// </summary>
|
||||
public readonly static byte LF_XHDR = (byte) 'x';
|
||||
|
||||
|
||||
|
||||
|
||||
// POSIX allows for upper case ascii type as extensions
|
||||
|
||||
// Solaris access control list
|
||||
public const byte LF_ACL = (byte) 'A';
|
||||
|
||||
// This is a dir entry that contains the names of files that were in the
|
||||
// dir at the time the dump was made
|
||||
public const byte LF_GNU_DUMPDIR = (byte) 'D';
|
||||
|
||||
// Solaris Extended Attribute File
|
||||
public const byte LF_EXTATTR = (byte) 'E' ;
|
||||
|
||||
// Inode (metadata only) no file content
|
||||
public const byte LF_META = (byte) 'I';
|
||||
|
||||
// Identifies the next file on the tape as having a long link name
|
||||
public const byte LF_GNU_LONGLINK = (byte) 'K';
|
||||
|
||||
// Identifies the next file on the tape as having a long name
|
||||
public const byte LF_GNU_LONGNAME = (byte) 'L';
|
||||
|
||||
// Continuation of a file that began on another volume
|
||||
public const byte LF_GNU_MULTIVOL = (byte) 'M';
|
||||
|
||||
// For storing filenames that dont fit in the main header (old GNU)
|
||||
public const byte LF_GNU_NAMES = (byte) 'N';
|
||||
|
||||
// Sparse file
|
||||
public const byte LF_GNU_SPARSE = (byte) 'S';
|
||||
|
||||
// Tape/volume header ignore on extraction
|
||||
public const byte LF_GNU_VOLHDR = (byte) 'V';
|
||||
|
||||
/// <summary>
|
||||
/// The magic tag representing a POSIX tar archive. (includes trailing NULL)
|
||||
/// </summary>
|
||||
public readonly static string TMAGIC = "ustar ";
|
||||
|
||||
/// <summary>
|
||||
/// The magic tag representing an old GNU tar archive where version is included in magic and overwrites it
|
||||
/// The magic tag representing a GNU tar archive.
|
||||
/// </summary>
|
||||
public readonly static string GNU_TMAGIC = "ustar ";
|
||||
|
||||
@@ -279,9 +191,9 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
public int checkSum;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's type flag.
|
||||
/// The entry's link flag.
|
||||
/// </summary>
|
||||
public byte typeFlag;
|
||||
public byte linkFlag;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's link name.
|
||||
@@ -293,11 +205,6 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </summary>
|
||||
public StringBuilder magic;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's version.
|
||||
/// </summary>
|
||||
public StringBuilder version;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's user name.
|
||||
/// </summary>
|
||||
@@ -321,27 +228,20 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
public TarHeader()
|
||||
{
|
||||
this.magic = new StringBuilder(TarHeader.TMAGIC);
|
||||
this.version = new StringBuilder(" ");
|
||||
|
||||
this.name = new StringBuilder();
|
||||
this.linkName = new StringBuilder();
|
||||
|
||||
string user = Environment.UserName;
|
||||
// string user = "PocketPC";
|
||||
// string user = "Everyone";
|
||||
|
||||
if (user.Length > 31) {
|
||||
user = user.Substring(0, 31);
|
||||
}
|
||||
|
||||
this.userId = 1003; // -jr- was 0
|
||||
this.groupId = 513; // -jr- was 0
|
||||
this.userId = 0;
|
||||
this.groupId = 0;
|
||||
this.userName = new StringBuilder(user);
|
||||
// -jr-
|
||||
// this.groupName = new StringBuilder(String.Empty);
|
||||
// this.groupName = new StringBuilder("Everyone"); Attempt2
|
||||
this.groupName = new StringBuilder("None"); // Gnu compatible
|
||||
this.size = 0;
|
||||
this.groupName = new StringBuilder(String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -358,10 +258,9 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
hdr.size = this.size;
|
||||
hdr.modTime = this.modTime;
|
||||
hdr.checkSum = this.checkSum;
|
||||
hdr.typeFlag = this.typeFlag;
|
||||
hdr.linkFlag = this.linkFlag;
|
||||
hdr.linkName = (this.linkName == null) ? null : new StringBuilder(this.linkName.ToString());
|
||||
hdr.magic = (this.magic == null) ? null : new StringBuilder(this.magic.ToString());
|
||||
hdr.version = (this.version == null) ? null : new StringBuilder(this.version.ToString());
|
||||
hdr.userName = (this.userName == null) ? null : new StringBuilder(this.userName.ToString());
|
||||
hdr.groupName = (this.groupName == null) ? null : new StringBuilder(this.groupName.ToString());
|
||||
hdr.devMajor = this.devMajor;
|
||||
@@ -403,22 +302,17 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
bool stillPadding = true;
|
||||
|
||||
int end = offset + length;
|
||||
for (int i = offset; i < end ; ++i)
|
||||
{
|
||||
if (header[i] == 0)
|
||||
{
|
||||
for (int i = offset; i < end ; ++i) {
|
||||
if (header[i] == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (header[i] == (byte)' ' || header[i] == '0')
|
||||
{
|
||||
if (stillPadding)
|
||||
{
|
||||
if (header[i] == (byte)' ' || header[i] == '0') {
|
||||
if (stillPadding) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header[i] == (byte)' ')
|
||||
{
|
||||
if (header[i] == (byte)' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -450,10 +344,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
StringBuilder result = new StringBuilder(length);
|
||||
|
||||
for (int i = offset; i < offset + length; ++i)
|
||||
{
|
||||
if (header[i] == 0)
|
||||
{
|
||||
for (int i = offset; i < offset + length; ++i) {
|
||||
if (header[i] == 0) {
|
||||
break;
|
||||
}
|
||||
result.Append((char)header[i]);
|
||||
@@ -462,24 +354,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int GetNameBytes(StringBuilder name, int nameOffset, byte[] buf, int bufferOffset, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < length && nameOffset + i < name.Length; ++i)
|
||||
{
|
||||
buf[bufferOffset + i] = (byte)name[nameOffset + i];
|
||||
}
|
||||
|
||||
for (; i < length ; ++i)
|
||||
{
|
||||
buf[bufferOffset + i] = 0;
|
||||
}
|
||||
|
||||
return bufferOffset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Determine the number of bytes in an entry name.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
@@ -498,7 +373,17 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public static int GetNameBytes(StringBuilder name, byte[] buf, int offset, int length)
|
||||
{
|
||||
return GetNameBytes(name, 0, buf, offset, length);
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < length && i < name.Length; ++i) {
|
||||
buf[offset + i] = (byte)name[i];
|
||||
}
|
||||
|
||||
for (; i < length ; ++i) {
|
||||
buf[offset + i] = 0;
|
||||
}
|
||||
|
||||
return offset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -520,26 +405,27 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public static int GetOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
// TODO check for values too large...
|
||||
|
||||
byte[] result = new byte[length];
|
||||
|
||||
int idx = length - 1;
|
||||
|
||||
// Either a space or null is valid here. We use NULL as per GNUTar
|
||||
|
||||
buf[offset + idx] = 0;
|
||||
--idx;
|
||||
|
||||
if (val > 0)
|
||||
{
|
||||
for (long v = val; idx >= 0 && v > 0; --idx)
|
||||
{
|
||||
buf[offset + idx] = (byte)' ';
|
||||
--idx;
|
||||
|
||||
if (val == 0) {
|
||||
buf[offset + idx] = (byte)'0';
|
||||
--idx;
|
||||
} else {
|
||||
for (long v = val; idx >= 0 && v > 0; --idx) {
|
||||
buf[offset + idx] = (byte)((byte)'0' + (byte)(v & 7));
|
||||
v >>= 3;
|
||||
}
|
||||
}
|
||||
|
||||
for (; idx >= 0; --idx)
|
||||
{
|
||||
buf[offset + idx] = (byte)'0';
|
||||
for (; idx >= 0; --idx) {
|
||||
buf[offset + idx] = (byte)' ';
|
||||
}
|
||||
|
||||
return offset + length;
|
||||
@@ -564,176 +450,37 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public static int GetLongOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
return GetOctalBytes(val, buf, offset, length);
|
||||
byte[] temp = new byte[length + 1];
|
||||
TarHeader.GetOctalBytes(val, temp, 0, length + 1);
|
||||
Array.Copy(temp, 0, buf, offset, length);
|
||||
return offset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the checksum octal integer to header buffer.
|
||||
/// Parse the checksum octal integer from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "val">
|
||||
/// </param>
|
||||
/// <param name = "buf">
|
||||
/// The header buffer to set the checksum for
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "offset">
|
||||
/// The offset into the buffer for the checksum
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "length">
|
||||
/// The number of header bytes to update.
|
||||
/// It's formatted differently from the other fields: it has 6 digits, a
|
||||
/// null, then a space -- rather than digits, a space, then a null.
|
||||
/// The final space is already there, from checksumming
|
||||
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The modified buffer offset
|
||||
/// The integer value of the entry's checksum.
|
||||
/// </returns>
|
||||
private static int GetCheckSumOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
public static int GetCheckSumOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
TarHeader.GetOctalBytes(val, buf, offset, length - 1);
|
||||
// buf[offset + length - 1] = (byte)' '; -jr- 23-Jan-2004 this causes failure!!!
|
||||
// buf[offset + length - 2] = 0;
|
||||
TarHeader.GetOctalBytes(val, buf, offset, length);
|
||||
buf[offset + length - 1] = (byte)' ';
|
||||
buf[offset + length - 2] = 0;
|
||||
return offset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute the checksum for a tar entry header.
|
||||
/// The checksum field must be all spaces prior to this happening
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// The tar entry's header buffer.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The computed checksum.
|
||||
/// </returns>
|
||||
private static long ComputeCheckSum(byte[] buf)
|
||||
{
|
||||
long sum = 0;
|
||||
for (int i = 0; i < buf.Length; ++i)
|
||||
{
|
||||
sum += buf[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
readonly static long timeConversionFactor = 10000000L; // -jr- 1 tick == 100 nanoseconds
|
||||
readonly static DateTime datetTime1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
// readonly static DateTime datetTime1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToUniversalTime(); // -jr- Should be UTC? doesnt match Gnutar if this is so though, why?
|
||||
|
||||
static int GetCTime(System.DateTime dateTime)
|
||||
{
|
||||
return (int)((dateTime.Ticks - datetTime1970.Ticks) / timeConversionFactor);
|
||||
}
|
||||
|
||||
static DateTime GetDateTimeFromCTime(long ticks)
|
||||
{
|
||||
return new DateTime(datetTime1970.Ticks + ticks * timeConversionFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse TarHeader information from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "header">
|
||||
/// The tar entry header buffer to get information from.
|
||||
/// </param>
|
||||
public void ParseBuffer(byte[] header)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
name = TarHeader.ParseName(header, offset, TarHeader.NAMELEN);
|
||||
offset += TarHeader.NAMELEN;
|
||||
|
||||
mode = (int)TarHeader.ParseOctal(header, offset, TarHeader.MODELEN);
|
||||
offset += TarHeader.MODELEN;
|
||||
|
||||
userId = (int)TarHeader.ParseOctal(header, offset, TarHeader.UIDLEN);
|
||||
offset += TarHeader.UIDLEN;
|
||||
|
||||
groupId = (int)TarHeader.ParseOctal(header, offset, TarHeader.GIDLEN);
|
||||
offset += TarHeader.GIDLEN;
|
||||
|
||||
size = TarHeader.ParseOctal(header, offset, TarHeader.SIZELEN);
|
||||
offset += TarHeader.SIZELEN;
|
||||
|
||||
modTime = GetDateTimeFromCTime(TarHeader.ParseOctal(header, offset, TarHeader.MODTIMELEN));
|
||||
offset += TarHeader.MODTIMELEN;
|
||||
|
||||
checkSum = (int)TarHeader.ParseOctal(header, offset, TarHeader.CHKSUMLEN);
|
||||
offset += TarHeader.CHKSUMLEN;
|
||||
|
||||
typeFlag = header[ offset++ ];
|
||||
|
||||
linkName = TarHeader.ParseName(header, offset, TarHeader.NAMELEN);
|
||||
offset += TarHeader.NAMELEN;
|
||||
|
||||
magic = TarHeader.ParseName(header, offset, TarHeader.MAGICLEN);
|
||||
offset += TarHeader.MAGICLEN;
|
||||
|
||||
version = TarHeader.ParseName(header, offset, TarHeader.VERSIONLEN);
|
||||
offset += TarHeader.VERSIONLEN;
|
||||
|
||||
userName = TarHeader.ParseName(header, offset, TarHeader.UNAMELEN);
|
||||
offset += TarHeader.UNAMELEN;
|
||||
|
||||
groupName = TarHeader.ParseName(header, offset, TarHeader.GNAMELEN);
|
||||
offset += TarHeader.GNAMELEN;
|
||||
|
||||
devMajor = (int)TarHeader.ParseOctal(header, offset, TarHeader.DEVLEN);
|
||||
offset += TarHeader.DEVLEN;
|
||||
|
||||
devMinor = (int)TarHeader.ParseOctal(header, offset, TarHeader.DEVLEN);
|
||||
|
||||
// Fields past this point not currently parsed or used...
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 'Write' header information to buffer provided
|
||||
/// </summary>
|
||||
/// <param name="outbuf">output buffer for header information</param>
|
||||
public void WriteHeader(byte[] outbuf)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
offset = GetNameBytes(this.name, outbuf, offset, TarHeader.NAMELEN);
|
||||
offset = GetOctalBytes(this.mode, outbuf, offset, TarHeader.MODELEN);
|
||||
offset = GetOctalBytes(this.userId, outbuf, offset, TarHeader.UIDLEN);
|
||||
offset = GetOctalBytes(this.groupId, outbuf, offset, TarHeader.GIDLEN);
|
||||
|
||||
long size = this.size;
|
||||
|
||||
offset = GetLongOctalBytes(size, outbuf, offset, TarHeader.SIZELEN);
|
||||
offset = GetLongOctalBytes(GetCTime(this.modTime), outbuf, offset, TarHeader.MODTIMELEN);
|
||||
|
||||
int csOffset = offset;
|
||||
for (int c = 0; c < TarHeader.CHKSUMLEN; ++c)
|
||||
{
|
||||
outbuf[offset++] = (byte)' ';
|
||||
}
|
||||
|
||||
outbuf[offset++] = this.typeFlag;
|
||||
|
||||
offset = GetNameBytes(this.linkName, outbuf, offset, NAMELEN);
|
||||
offset = GetNameBytes(this.magic, outbuf, offset, MAGICLEN);
|
||||
offset = GetNameBytes(this.version, outbuf, offset, VERSIONLEN);
|
||||
offset = GetNameBytes(this.userName, outbuf, offset, UNAMELEN);
|
||||
offset = GetNameBytes(this.groupName, outbuf, offset, GNAMELEN);
|
||||
|
||||
if (this.typeFlag == LF_CHR || this.typeFlag == LF_BLK)
|
||||
{
|
||||
offset = GetOctalBytes(this.devMajor, outbuf, offset, DEVLEN);
|
||||
offset = GetOctalBytes(this.devMinor, outbuf, offset, DEVLEN);
|
||||
}
|
||||
|
||||
for ( ; offset < outbuf.Length; )
|
||||
{
|
||||
outbuf[offset++] = 0;
|
||||
}
|
||||
|
||||
long checkSum = ComputeCheckSum(outbuf);
|
||||
|
||||
GetCheckSumOctalBytes(checkSum, outbuf, csOffset, CHKSUMLEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
|
||||
@@ -36,8 +36,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// The TarInputStream reads a UNIX tar archive as an InputStream.
|
||||
@@ -60,14 +59,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
protected IEntryFactory eFactory;
|
||||
|
||||
Stream inputStream;
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return inputStream.CanRead;
|
||||
}
|
||||
}
|
||||
@@ -75,11 +71,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek
|
||||
{
|
||||
// TODO is this valid? should it return false?
|
||||
get
|
||||
{
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return inputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
@@ -87,10 +80,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return inputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
@@ -98,10 +89,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
public override long Length {
|
||||
get {
|
||||
return inputStream.Length;
|
||||
}
|
||||
}
|
||||
@@ -109,14 +98,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
public override long Position {
|
||||
get {
|
||||
return inputStream.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
inputStream.Position = value;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +120,6 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
// TODO allow this?
|
||||
return inputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
@@ -163,27 +148,30 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
}
|
||||
|
||||
|
||||
public TarInputStream(Stream inputStream) : this(inputStream, TarBuffer.DefaultBlockFactor)
|
||||
public TarInputStream(Stream inputStream) : this(inputStream, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarInputStream(Stream inputStream, int blockFactor)
|
||||
public TarInputStream(Stream inputStream, int blockSize) : this(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarInputStream(Stream inputStream, int blockSize, int recordSize)
|
||||
{
|
||||
this.inputStream = inputStream;
|
||||
this.buffer = TarBuffer.CreateInputTarBuffer(inputStream, blockFactor);
|
||||
this.buffer = TarBuffer.CreateInputTarBuffer(inputStream, blockSize, recordSize);
|
||||
|
||||
this.readBuf = null;
|
||||
this.readBuf = null;
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.eFactory = null;
|
||||
}
|
||||
|
||||
public void SetDebug(bool debugFlag)
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugFlag;
|
||||
SetBufferDebug(debugFlag);
|
||||
this.debug = debugF;
|
||||
SetBufferDebug(debugF);
|
||||
}
|
||||
|
||||
public void SetBufferDebug(bool debug)
|
||||
{
|
||||
this.buffer.SetDebug(debug);
|
||||
@@ -226,10 +214,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <returns>
|
||||
/// The number of available bytes for the current entry.
|
||||
/// </returns>
|
||||
public int Available
|
||||
{
|
||||
get
|
||||
{
|
||||
public int Available {
|
||||
get {
|
||||
return this.entrySize - this.entryOffset;
|
||||
}
|
||||
}
|
||||
@@ -245,18 +231,16 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </param>
|
||||
public void Skip(int numToSkip)
|
||||
{
|
||||
// TODO REVIEW
|
||||
// REVIEW
|
||||
// This is horribly inefficient, but it ensures that we
|
||||
// properly skip over bytes via the TarBuffer...
|
||||
//
|
||||
byte[] skipBuf = new byte[8 * 1024];
|
||||
|
||||
for (int num = numToSkip; num > 0;)
|
||||
{
|
||||
for (int num = numToSkip; num > 0;){
|
||||
int numRead = this.Read(skipBuf, 0, (num > skipBuf.Length ? skipBuf.Length : num));
|
||||
|
||||
if (numRead == -1)
|
||||
{
|
||||
if (numRead == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -267,10 +251,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// Since we do not support marking just yet, we return false.
|
||||
/// </summary>
|
||||
public bool IsMarkSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
public bool IsMarkSupported {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -291,24 +273,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
void SkipToNextEntry()
|
||||
{
|
||||
int numToSkip = this.entrySize - this.entryOffset;
|
||||
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("TarInputStream: SKIP currENTRY '" + this.currEntry.Name + "' SZ " + this.entrySize + " OFF " + this.entryOffset + " skipping " + numToSkip + " bytes");
|
||||
}
|
||||
|
||||
if (numToSkip > 0)
|
||||
{
|
||||
this.Skip(numToSkip);
|
||||
}
|
||||
|
||||
this.readBuf = null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the next entry in this tar archive. This will skip
|
||||
/// over any remaining data in the current entry, if there
|
||||
@@ -324,144 +289,68 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </returns>
|
||||
public TarEntry GetNextEntry()
|
||||
{
|
||||
if (this.hasHitEOF)
|
||||
{
|
||||
if (this.hasHitEOF) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.currEntry != null)
|
||||
{
|
||||
SkipToNextEntry();
|
||||
if (this.currEntry != null) {
|
||||
int numToSkip = this.entrySize - this.entryOffset;
|
||||
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarInputStream: SKIP currENTRY '" + this.currEntry.Name + "' SZ " + this.entrySize + " OFF " + this.entryOffset + " skipping " + numToSkip + " bytes");
|
||||
}
|
||||
|
||||
if (numToSkip > 0) {
|
||||
this.Skip(numToSkip);
|
||||
}
|
||||
|
||||
this.readBuf = null;
|
||||
}
|
||||
|
||||
byte[] headerBuf = this.buffer.ReadBlock();
|
||||
byte[] headerBuf = this.buffer.ReadRecord();
|
||||
|
||||
if (headerBuf == null)
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("READ NULL BLOCK");
|
||||
if (headerBuf == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ NULL RECORD");
|
||||
}
|
||||
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
else if (this.buffer.IsEOFBlock(headerBuf))
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine( "READ EOF BLOCK" );
|
||||
} else if (this.buffer.IsEOFRecord(headerBuf)) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine( "READ EOF RECORD" );
|
||||
}
|
||||
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
|
||||
if (this.hasHitEOF)
|
||||
{
|
||||
if (this.hasHitEOF) {
|
||||
this.currEntry = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
TarHeader header = new TarHeader();
|
||||
header.ParseBuffer(headerBuf);
|
||||
this.entryOffset = 0;
|
||||
this.entrySize = (int)header.size;
|
||||
|
||||
StringBuilder longName = null;
|
||||
|
||||
if (header.typeFlag == TarHeader.LF_GNU_LONGNAME)
|
||||
{
|
||||
Console.WriteLine("TarInputStream: Long name found '" + header.name + "' size = " + header.size); // DEBUG
|
||||
|
||||
byte[] nameBuffer = new byte[TarBuffer.BlockSize];
|
||||
|
||||
int numToRead = this.entrySize;
|
||||
|
||||
longName = new StringBuilder();
|
||||
|
||||
while (numToRead > 0)
|
||||
{
|
||||
int numRead = this.Read(nameBuffer, 0, (numToRead > nameBuffer.Length ? nameBuffer.Length : numToRead));
|
||||
|
||||
if (numRead == -1)
|
||||
{
|
||||
throw new InvalidHeaderException("Failed to read long name entry");
|
||||
}
|
||||
|
||||
longName.Append(TarHeader.ParseName(nameBuffer, 0, numRead).ToString());
|
||||
numToRead -= numRead;
|
||||
}
|
||||
|
||||
Console.WriteLine("TarInputStream: Long name is '" + longName.ToString()); // DEBUG
|
||||
|
||||
SkipToNextEntry();
|
||||
headerBuf = this.buffer.ReadBlock();
|
||||
}
|
||||
else if (header.typeFlag == TarHeader.LF_GHDR) // POSIX global extended header
|
||||
{
|
||||
// Ignore things we dont understand completely for now
|
||||
SkipToNextEntry();
|
||||
headerBuf = this.buffer.ReadBlock();
|
||||
}
|
||||
else if (header.typeFlag == TarHeader.LF_XHDR) // POSIX extended header
|
||||
{
|
||||
// Ignore things we dont understand completely for now
|
||||
SkipToNextEntry();
|
||||
headerBuf = this.buffer.ReadBlock();
|
||||
}
|
||||
else if (header.typeFlag == TarHeader.LF_GNU_VOLHDR)
|
||||
{
|
||||
// TODO could show volume name when verbose?
|
||||
SkipToNextEntry();
|
||||
headerBuf = this.buffer.ReadBlock();
|
||||
}
|
||||
else if (header.typeFlag != TarHeader.LF_NORMAL
|
||||
&& header.typeFlag != TarHeader.LF_OLDNORM)
|
||||
{
|
||||
// Ignore things we dont understand completely for now
|
||||
SkipToNextEntry();
|
||||
headerBuf = this.buffer.ReadBlock();
|
||||
}
|
||||
|
||||
if (this.eFactory == null)
|
||||
{
|
||||
this.currEntry = new TarEntry(headerBuf);
|
||||
if (longName != null)
|
||||
{
|
||||
this.currEntry.TarHeader.name.Length = 0;
|
||||
this.currEntry.TarHeader.name.Append(longName.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currEntry = this.eFactory.CreateEntry(headerBuf);
|
||||
} else {
|
||||
try {
|
||||
if (this.eFactory == null) {
|
||||
this.currEntry = new TarEntry(headerBuf);
|
||||
} else {
|
||||
this.currEntry = this.eFactory.CreateEntry(headerBuf);
|
||||
}
|
||||
|
||||
// TODO -jr- ustar is not the only magic possible by any means
|
||||
// tar, xtar, ...
|
||||
if (!(headerBuf[257] == 'u' && headerBuf[258] == 's' && headerBuf[259] == 't' && headerBuf[260] == 'a' && headerBuf[261] == 'r'))
|
||||
{
|
||||
|
||||
if (!(headerBuf[257] == 'u' && headerBuf[258] == 's' && headerBuf[259] == 't' && headerBuf[260] == 'a' && headerBuf[261] == 'r')) {
|
||||
throw new InvalidHeaderException("header magic is not 'ustar', but '" + headerBuf[257] + headerBuf[258] + headerBuf[259] + headerBuf[260] + headerBuf[261] +
|
||||
"', or (dec) " + ((int)headerBuf[257]) + ", " + ((int)headerBuf[258]) + ", " + ((int)headerBuf[259]) + ", " + ((int)headerBuf[260]) + ", " + ((int)headerBuf[261]));
|
||||
"', or (dec) " + ((int)headerBuf[257]) + ", " + ((int)headerBuf[258]) + ", " + ((int)headerBuf[259]) + ", " + ((int)headerBuf[260]) + ", " + ((int)headerBuf[261]));
|
||||
}
|
||||
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("TarInputStream: SET CURRENTRY '" + this.currEntry.Name + "' size = " + this.currEntry.Size);
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarInputStream: SET CURRENTRY '" + this.currEntry.Name + "' size = " + this.currEntry.Size);
|
||||
}
|
||||
|
||||
this.entryOffset = 0;
|
||||
|
||||
// TODO REVIEW How do we resolve this discrepancy?!
|
||||
// REVIEW How do we resolve this discrepancy?!
|
||||
this.entrySize = (int) this.currEntry.Size;
|
||||
}
|
||||
catch (InvalidHeaderException ex)
|
||||
{
|
||||
} catch (InvalidHeaderException ex) {
|
||||
this.entrySize = 0;
|
||||
this.entryOffset = 0;
|
||||
this.currEntry = null;
|
||||
throw new InvalidHeaderException("bad header in record " + this.buffer.GetCurrentBlockNum() + " block " + this.buffer.GetCurrentBlockNum() + ", " + ex.Message);
|
||||
throw new InvalidHeaderException("bad header in block " + this.buffer.GetCurrentBlockNum() + " record " + this.buffer.GetCurrentRecordNum() + ", " + ex.Message);
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
@@ -475,8 +364,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
byte[] oneByteBuffer = new byte[1];
|
||||
int num = this.Read(oneByteBuffer, 0, 1);
|
||||
if (num <= 0) // return -1 to indicate that no byte was read.
|
||||
{
|
||||
if (num <= 0) { // return -1 to indicate that no byte was read.
|
||||
return -1;
|
||||
}
|
||||
return (int)oneByteBuffer[0];
|
||||
@@ -486,9 +374,10 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// Reads bytes from the current tar archive entry.
|
||||
///
|
||||
/// This method is aware of the boundaries of the current
|
||||
/// entry in the archive and will deal with them appropriately
|
||||
/// entry in the archive and will deal with them as if they
|
||||
/// entry in the archive and will deal with them as if they
|
||||
/// </summary>
|
||||
/// <param name="outputBuffer">
|
||||
/// <param name="buf">
|
||||
/// The buffer into which to place bytes read.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
@@ -498,36 +387,30 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// The number of bytes to read.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The number of bytes read, or 0 at end of stream/EOF.
|
||||
/// The number of bytes read, or -1 at EOF.
|
||||
/// </returns>
|
||||
public override int Read(byte[] outputBuffer, int offset, int numToRead)
|
||||
public override int Read(byte[] buf, int offset, int numToRead)
|
||||
{
|
||||
int totalRead = 0;
|
||||
|
||||
if (this.entryOffset >= this.entrySize)
|
||||
{
|
||||
return 0;
|
||||
if (this.entryOffset >= this.entrySize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((numToRead + this.entryOffset) > this.entrySize)
|
||||
{
|
||||
if ((numToRead + this.entryOffset) > this.entrySize) {
|
||||
numToRead = this.entrySize - this.entryOffset;
|
||||
}
|
||||
|
||||
if (this.readBuf != null)
|
||||
{
|
||||
if (this.readBuf != null) {
|
||||
int sz = (numToRead > this.readBuf.Length) ? this.readBuf.Length : numToRead;
|
||||
|
||||
Array.Copy(this.readBuf, 0, outputBuffer, offset, sz);
|
||||
Array.Copy(this.readBuf, 0, buf, offset, sz);
|
||||
|
||||
if (sz >= this.readBuf.Length)
|
||||
{
|
||||
if (sz >= this.readBuf.Length) {
|
||||
this.readBuf = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int newLen = this.readBuf.Length - sz;
|
||||
byte[] newBuf = new byte[newLen];
|
||||
byte[] newBuf = new byte[ newLen ];
|
||||
Array.Copy(this.readBuf, sz, newBuf, 0, newLen);
|
||||
this.readBuf = newBuf;
|
||||
}
|
||||
@@ -537,11 +420,9 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
offset += sz;
|
||||
}
|
||||
|
||||
while (numToRead > 0)
|
||||
{
|
||||
byte[] rec = this.buffer.ReadBlock();
|
||||
if (rec == null)
|
||||
{
|
||||
while (numToRead > 0) {
|
||||
byte[] rec = this.buffer.ReadRecord();
|
||||
if (rec == null) {
|
||||
// Unexpected EOF!
|
||||
throw new IOException("unexpected EOF with " + numToRead + " bytes unread");
|
||||
}
|
||||
@@ -549,16 +430,13 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
int sz = numToRead;
|
||||
int recLen = rec.Length;
|
||||
|
||||
if (recLen > sz)
|
||||
{
|
||||
Array.Copy(rec, 0, outputBuffer, offset, sz);
|
||||
if (recLen > sz) {
|
||||
Array.Copy(rec, 0, buf, offset, sz);
|
||||
this.readBuf = new byte[recLen - sz];
|
||||
Array.Copy(rec, sz, this.readBuf, 0, recLen - sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sz = recLen;
|
||||
Array.Copy(rec, 0, outputBuffer, offset, recLen);
|
||||
Array.Copy(rec, 0, buf, offset, recLen);
|
||||
}
|
||||
|
||||
totalRead += sz;
|
||||
@@ -582,11 +460,9 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
byte[] buf = new byte[32 * 1024];
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
int numRead = this.Read(buf, 0, buf.Length);
|
||||
if (numRead <= 0)
|
||||
{
|
||||
if (numRead <= 0) {
|
||||
break;
|
||||
}
|
||||
outputStream.Write(buf, 0, numRead);
|
||||
|
||||
@@ -36,8 +36,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// The TarOutputStream writes a UNIX tar archive as an OutputStream.
|
||||
@@ -50,7 +49,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
protected bool debug;
|
||||
protected int currSize;
|
||||
protected int currBytes;
|
||||
protected byte[] blockBuf;
|
||||
protected byte[] recordBuf;
|
||||
protected int assemLen;
|
||||
protected byte[] assemBuf;
|
||||
|
||||
@@ -60,10 +59,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return outputStream.CanRead;
|
||||
}
|
||||
}
|
||||
@@ -71,21 +68,17 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return outputStream.CanSeek; // -jr- Should be false?
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return outputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return outputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
@@ -93,10 +86,8 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
public override long Length {
|
||||
get {
|
||||
return outputStream.Length;
|
||||
}
|
||||
}
|
||||
@@ -104,14 +95,11 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
public override long Position {
|
||||
get {
|
||||
return outputStream.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
outputStream.Position = value;
|
||||
}
|
||||
}
|
||||
@@ -153,31 +141,35 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
outputStream.Flush();
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream) : this(outputStream, TarBuffer.DefaultBlockFactor)
|
||||
public TarOutputStream(Stream outputStream) : this(outputStream, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream, int blockFactor)
|
||||
public TarOutputStream(Stream outputStream, int blockSize) : this(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream, int blockSize, int recordSize)
|
||||
{
|
||||
this.outputStream = outputStream;
|
||||
this.buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockFactor);
|
||||
this.buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockSize, recordSize);
|
||||
|
||||
this.debug = false;
|
||||
this.assemLen = 0;
|
||||
this.assemBuf = new byte[TarBuffer.BlockSize];
|
||||
this.blockBuf = new byte[TarBuffer.BlockSize];
|
||||
this.assemBuf = new byte[recordSize];
|
||||
this.recordBuf = new byte[recordSize];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the debugging flag.
|
||||
/// </summary>
|
||||
/// <param name = "debugFlag">
|
||||
/// <param name = "debugF">
|
||||
/// True to turn on debugging.
|
||||
/// </param>
|
||||
public void SetDebug(bool debugFlag)
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugFlag;
|
||||
SetBufferDebug(debugFlag);
|
||||
this.debug = debugF;
|
||||
SetBufferDebug(debugF);
|
||||
}
|
||||
|
||||
public void SetBufferDebug(bool debug)
|
||||
@@ -218,7 +210,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
|
||||
/// <summary>
|
||||
/// Put an entry on the output stream. This writes the entry's
|
||||
/// header and positions the output stream for writing
|
||||
/// header record and positions the output stream for writing
|
||||
/// the contents of the entry. Once this method is called, the
|
||||
/// stream is ready for calls to write() to write the entry's
|
||||
/// contents. Once the contents are written, closeEntry()
|
||||
@@ -230,36 +222,12 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </param>
|
||||
public void PutNextEntry(TarEntry entry)
|
||||
{
|
||||
if (entry.TarHeader.name.Length > TarHeader.NAMELEN)
|
||||
{
|
||||
TarHeader longHeader = new TarHeader();
|
||||
longHeader.typeFlag = TarHeader.LF_GNU_LONGNAME;
|
||||
longHeader.name.Append("././@LongLink");
|
||||
longHeader.userId = 0;
|
||||
longHeader.groupId = 0;
|
||||
longHeader.groupName.Length = 0;
|
||||
longHeader.userName.Length = 0;
|
||||
longHeader.linkName.Length = 0;
|
||||
|
||||
longHeader.size = entry.TarHeader.name.Length;
|
||||
|
||||
Console.WriteLine("TarOutputStream: PutNext entry Long name found size = " + longHeader.size); // DEBUG
|
||||
|
||||
longHeader.WriteHeader(this.blockBuf);
|
||||
this.buffer.WriteBlock(this.blockBuf); // Add special long filename header block
|
||||
|
||||
int nameCharIndex = 0;
|
||||
|
||||
while (nameCharIndex < entry.TarHeader.name.Length)
|
||||
{
|
||||
TarHeader.GetNameBytes(entry.TarHeader.name, nameCharIndex, this.blockBuf, 0, TarBuffer.BlockSize);
|
||||
nameCharIndex += TarBuffer.BlockSize;
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
}
|
||||
if (entry.TarHeader.name.Length > TarHeader.NAMELEN) {
|
||||
throw new InvalidHeaderException("file name '" + entry.TarHeader.name + "' is too long ( > " + TarHeader.NAMELEN + " bytes )");
|
||||
}
|
||||
|
||||
entry.WriteEntryHeader(this.blockBuf);
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
entry.WriteEntryHeader(this.recordBuf);
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
|
||||
this.currBytes = 0;
|
||||
|
||||
@@ -270,28 +238,25 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// Close an entry. This method MUST be called for all file
|
||||
/// entries that contain data. The reason is that we must
|
||||
/// buffer data written to the stream in order to satisfy
|
||||
/// the buffer's block based writes. Thus, there may be
|
||||
/// the buffer's record based writes. Thus, there may be
|
||||
/// data fragments still being assembled that must be written
|
||||
/// to the output stream before this entry is closed and the
|
||||
/// next entry written.
|
||||
/// </summary>
|
||||
public void CloseEntry()
|
||||
{
|
||||
if (this.assemLen > 0)
|
||||
{
|
||||
for (int i = this.assemLen; i < this.assemBuf.Length; ++i)
|
||||
{
|
||||
if (this.assemLen > 0) {
|
||||
for (int i = this.assemLen; i < this.assemBuf.Length; ++i) {
|
||||
this.assemBuf[i] = 0;
|
||||
}
|
||||
|
||||
this.buffer.WriteBlock(this.assemBuf);
|
||||
this.buffer.WriteRecord(this.assemBuf);
|
||||
|
||||
this.currBytes += this.assemLen;
|
||||
this.assemLen = 0;
|
||||
}
|
||||
|
||||
if (this.currBytes < this.currSize)
|
||||
{
|
||||
if (this.currBytes < this.currSize) {
|
||||
throw new IOException("entry closed at '" + this.currBytes + "' before the '" + this.currSize + "' bytes specified in the header were written");
|
||||
}
|
||||
}
|
||||
@@ -328,8 +293,7 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </param>
|
||||
public override void Write(byte[] wBuf, int wOffset, int numToWrite)
|
||||
{
|
||||
if ((this.currBytes + numToWrite) > this.currSize)
|
||||
{
|
||||
if ((this.currBytes + numToWrite) > this.currSize) {
|
||||
throw new IOException("request to write '" + numToWrite + "' bytes exceeds size in header of '" + this.currSize + "' bytes");
|
||||
}
|
||||
|
||||
@@ -340,27 +304,23 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
// REVIEW Maybe this should be in TarBuffer? Could that help to
|
||||
// eliminate some of the buffer copying.
|
||||
//
|
||||
if (this.assemLen > 0)
|
||||
{
|
||||
if ((this.assemLen + numToWrite ) >= this.blockBuf.Length)
|
||||
{
|
||||
int aLen = this.blockBuf.Length - this.assemLen;
|
||||
if (this.assemLen > 0) {
|
||||
if ((this.assemLen + numToWrite ) >= this.recordBuf.Length) {
|
||||
int aLen = this.recordBuf.Length - this.assemLen;
|
||||
|
||||
Array.Copy(this.assemBuf, 0, this.blockBuf, 0, this.assemLen);
|
||||
Array.Copy(this.assemBuf, 0, this.recordBuf, 0, this.assemLen);
|
||||
|
||||
Array.Copy(wBuf, wOffset, this.blockBuf, this.assemLen, aLen);
|
||||
Array.Copy(wBuf, wOffset, this.recordBuf, this.assemLen, aLen);
|
||||
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
|
||||
this.currBytes += this.blockBuf.Length;
|
||||
this.currBytes += this.recordBuf.Length;
|
||||
|
||||
wOffset += aLen;
|
||||
numToWrite -= aLen;
|
||||
|
||||
this.assemLen = 0;
|
||||
}
|
||||
else
|
||||
{// ( (this.assemLen + numToWrite ) < this.blockBuf.length )
|
||||
} else {// ( (this.assemLen + numToWrite ) < this.recordBuf.length )
|
||||
Array.Copy(wBuf, wOffset, this.assemBuf, this.assemLen, numToWrite);
|
||||
wOffset += numToWrite;
|
||||
this.assemLen += numToWrite;
|
||||
@@ -373,18 +333,16 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
// o An empty "assemble" buffer.
|
||||
// o No bytes to write (numToWrite == 0)
|
||||
//
|
||||
while (numToWrite > 0)
|
||||
{
|
||||
if (numToWrite < this.blockBuf.Length)
|
||||
{
|
||||
while (numToWrite > 0) {
|
||||
if (numToWrite < this.recordBuf.Length) {
|
||||
Array.Copy(wBuf, wOffset, this.assemBuf, this.assemLen, numToWrite);
|
||||
this.assemLen += numToWrite;
|
||||
break;
|
||||
}
|
||||
|
||||
this.buffer.WriteBlock(wBuf, wOffset);
|
||||
this.buffer.WriteRecord(wBuf, wOffset);
|
||||
|
||||
int num = this.blockBuf.Length;
|
||||
int num = this.recordBuf.Length;
|
||||
this.currBytes += num;
|
||||
numToWrite -= num;
|
||||
wOffset += num;
|
||||
@@ -397,11 +355,10 @@ namespace ICSharpCode.SharpZipLib.Tar
|
||||
/// </summary>
|
||||
void WriteEOFRecord()
|
||||
{
|
||||
for (int i = 0; i < this.blockBuf.Length; ++i)
|
||||
{
|
||||
this.blockBuf[i] = 0;
|
||||
for (int i = 0; i < this.recordBuf.Length; ++i) {
|
||||
this.recordBuf[i] = 0;
|
||||
}
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This is the Deflater class. The deflater class compresses input
|
||||
@@ -120,8 +119,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
private static int INIT_STATE = 0x00;
|
||||
private static int SETDICT_STATE = 0x01;
|
||||
// private static int INIT_FINISHING_STATE = 0x08;
|
||||
// private static int SETDICT_FINISHING_STATE = 0x09;
|
||||
// private static int INIT_FINISHING_STATE = 0x08;
|
||||
// private static int SETDICT_FINISHING_STATE = 0x09;
|
||||
private static int BUSY_STATE = 0x10;
|
||||
private static int FLUSHING_STATE = 0x14;
|
||||
private static int FINISHING_STATE = 0x1c;
|
||||
@@ -138,10 +137,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
/// </summary>
|
||||
private bool noHeader;
|
||||
|
||||
// /// <summary>
|
||||
// /// Compression strategy.
|
||||
// /// </summary>
|
||||
// private int strategy;
|
||||
// /// <summary>
|
||||
// /// Compression strategy.
|
||||
// /// </summary>
|
||||
// private int strategy;
|
||||
|
||||
/// <summary>
|
||||
/// The current state.
|
||||
@@ -361,6 +360,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
throw new ArgumentOutOfRangeException("lvl");
|
||||
}
|
||||
|
||||
|
||||
if (level != lvl) {
|
||||
level = lvl;
|
||||
engine.SetLevel(lvl);
|
||||
@@ -425,7 +425,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
if (state < BUSY_STATE) {
|
||||
/* output header */
|
||||
int header = (DEFLATED +
|
||||
((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8;
|
||||
((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8;
|
||||
int level_flags = (level - 1) >> 1;
|
||||
if (level_flags < 0 || level_flags > 3) {
|
||||
level_flags = 3;
|
||||
|
||||
+1
-2
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for the deflater.
|
||||
|
||||
+82
-85
@@ -39,11 +39,9 @@ using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
public enum DeflateStrategy
|
||||
{
|
||||
public enum DeflateStrategy {
|
||||
// The default strategy.
|
||||
Default = 0,
|
||||
|
||||
@@ -62,7 +60,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
static int TOO_FAR = 4096;
|
||||
|
||||
int ins_h;
|
||||
// private byte[] buffer;
|
||||
// private byte[] buffer;
|
||||
short[] head;
|
||||
short[] prev;
|
||||
|
||||
@@ -177,15 +175,15 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
max_chain = DeflaterConstants.MAX_CHAIN[lvl];
|
||||
|
||||
if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("Change from "+comprFunc +" to "
|
||||
// + DeflaterConstants.COMPR_FUNC[lvl]);
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Change from "+comprFunc +" to "
|
||||
// + DeflaterConstants.COMPR_FUNC[lvl]);
|
||||
// }
|
||||
switch (comprFunc) {
|
||||
case DEFLATE_STORED:
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushStoredBlock(window, blockStart,
|
||||
strstart - blockStart, false);
|
||||
strstart - blockStart, false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
UpdateHash();
|
||||
@@ -193,7 +191,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
case DEFLATE_FAST:
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
false);
|
||||
false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
break;
|
||||
@@ -202,7 +200,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
huffman.TallyLit(window[strstart-1] & 0xff);
|
||||
}
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart, false);
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
prevAvailable = false;
|
||||
@@ -213,29 +212,29 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateHash()
|
||||
private void UpdateHash()
|
||||
{
|
||||
// if (DEBUGGING) {
|
||||
// //Console.WriteLine("updateHash: "+strstart);
|
||||
// }
|
||||
// if (DEBUGGING) {
|
||||
// Console.WriteLine("updateHash: "+strstart);
|
||||
// }
|
||||
ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1];
|
||||
}
|
||||
|
||||
int InsertString()
|
||||
private int InsertString()
|
||||
{
|
||||
short match;
|
||||
int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)]) & HASH_MASK;
|
||||
|
||||
// if (DEBUGGING) {
|
||||
// if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^
|
||||
// (window[strstart + 1] << HASH_SHIFT) ^
|
||||
// (window[strstart + 2])) & HASH_MASK)) {
|
||||
// throw new Exception("hash inconsistent: "+hash+"/"
|
||||
// +window[strstart]+","
|
||||
// +window[strstart+1]+","
|
||||
// +window[strstart+2]+","+HASH_SHIFT);
|
||||
// }
|
||||
// }
|
||||
// if (DEBUGGING) {
|
||||
// if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^
|
||||
// (window[strstart + 1] << HASH_SHIFT) ^
|
||||
// (window[strstart + 2])) & HASH_MASK)) {
|
||||
// throw new Exception("hash inconsistent: "+hash+"/"
|
||||
// +window[strstart]+","
|
||||
// +window[strstart+1]+","
|
||||
// +window[strstart+2]+","+HASH_SHIFT);
|
||||
// }
|
||||
// }
|
||||
|
||||
prev[strstart & WMASK] = match = head[hash];
|
||||
head[hash] = (short)strstart;
|
||||
@@ -297,7 +296,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
}
|
||||
|
||||
bool FindLongestMatch(int curMatch)
|
||||
private bool FindLongestMatch(int curMatch)
|
||||
{
|
||||
int chainLength = this.max_chain;
|
||||
int niceLength = this.niceLength;
|
||||
@@ -326,7 +325,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
|
||||
if (DeflaterConstants.DEBUGGING && strstart > 2 * WSIZE - MIN_LOOKAHEAD) {
|
||||
throw new InvalidOperationException("need lookahead");
|
||||
throw new InvalidOperationException("need lookahead");
|
||||
}
|
||||
|
||||
do {
|
||||
@@ -334,10 +333,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
throw new InvalidOperationException("future match");
|
||||
}
|
||||
if (window[curMatch + best_len] != scan_end ||
|
||||
window[curMatch + best_len - 1] != scan_end1 ||
|
||||
window[curMatch] != window[scan] ||
|
||||
window[curMatch + 1] != window[scan + 1]) {
|
||||
continue;
|
||||
window[curMatch + best_len - 1] != scan_end1 ||
|
||||
window[curMatch] != window[scan] ||
|
||||
window[curMatch + 1] != window[scan + 1]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match = curMatch + 2;
|
||||
@@ -346,14 +345,14 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
/* We check for insufficient lookahead only every 8th comparison;
|
||||
* the 256th check will be made at strstart+258.
|
||||
*/
|
||||
while (window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] && scan < strend) ;
|
||||
while (window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] && scan < strend) ;
|
||||
|
||||
if (scan > best_end) {
|
||||
// if (DeflaterConstants.DEBUGGING && ins_h == 0)
|
||||
@@ -361,7 +360,6 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
matchStart = curMatch;
|
||||
best_end = scan;
|
||||
best_len = scan - strstart;
|
||||
|
||||
if (best_len >= niceLength) {
|
||||
break;
|
||||
}
|
||||
@@ -402,7 +400,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
blockStart = strstart;
|
||||
}
|
||||
|
||||
bool DeflateStored(bool flush, bool finish)
|
||||
private bool DeflateStored(bool flush, bool finish)
|
||||
{
|
||||
if (!flush && lookahead == 0) {
|
||||
return false;
|
||||
@@ -422,9 +420,9 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
lastBlock = false;
|
||||
}
|
||||
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("storedBlock["+storedLen+","+lastBlock+"]");
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("storedBlock["+storedLen+","+lastBlock+"]");
|
||||
// }
|
||||
|
||||
huffman.FlushStoredBlock(window, blockStart, storedLen, lastBlock);
|
||||
blockStart += storedLen;
|
||||
@@ -447,7 +445,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strstart > 2 * WSIZE - MIN_LOOKAHEAD) {
|
||||
if (strstart > 2 * WSIZE - MIN_LOOKAHEAD)
|
||||
{
|
||||
/* slide window, as findLongestMatch need this.
|
||||
* This should only happen when flushing and the window
|
||||
* is almost full.
|
||||
@@ -457,25 +456,20 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
int hashHead;
|
||||
if (lookahead >= MIN_MATCH &&
|
||||
(hashHead = InsertString()) != 0 &&
|
||||
strategy != DeflateStrategy.HuffmanOnly &&
|
||||
strstart - hashHead <= MAX_DIST &&
|
||||
FindLongestMatch(hashHead)) {
|
||||
(hashHead = InsertString()) != 0 &&
|
||||
strategy != DeflateStrategy.HuffmanOnly &&
|
||||
strstart - hashHead <= MAX_DIST &&
|
||||
FindLongestMatch(hashHead)) {
|
||||
/* longestMatch sets matchStart and matchLen */
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// for (int i = 0 ; i < matchLen; i++) {
|
||||
// if (window[strstart+i] != window[matchStart + i]) {
|
||||
// throw new Exception();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// for (int i = 0 ; i < matchLen; i++) {
|
||||
// if (window[strstart+i] != window[matchStart + i]) {
|
||||
// throw new Exception();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// -jr- Hak hak hak this stops problems with fast/low compression and index out of range
|
||||
if (huffman.TallyDist(strstart - matchStart, matchLen)) {
|
||||
bool lastBlock = finish && lookahead == 0;
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock);
|
||||
blockStart = strstart;
|
||||
}
|
||||
huffman.TallyDist(strstart - matchStart, matchLen);
|
||||
|
||||
lookahead -= matchLen;
|
||||
if (matchLen <= max_lazy && lookahead >= MIN_MATCH) {
|
||||
@@ -501,7 +495,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
if (huffman.IsFull()) {
|
||||
bool lastBlock = finish && lookahead == 0;
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock);
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
lastBlock);
|
||||
blockStart = strstart;
|
||||
return !lastBlock;
|
||||
}
|
||||
@@ -509,7 +504,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeflateSlow(bool flush, bool finish)
|
||||
private bool DeflateSlow(bool flush, bool finish)
|
||||
{
|
||||
if (lookahead < MIN_LOOKAHEAD && !flush) {
|
||||
return false;
|
||||
@@ -527,41 +522,43 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
throw new Exception("Not flushing, but no lookahead");
|
||||
}
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
finish);
|
||||
finish);
|
||||
blockStart = strstart;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD) {
|
||||
if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD)
|
||||
{
|
||||
/* slide window, as findLongestMatch need this.
|
||||
* This should only happen when flushing and the window
|
||||
* is almost full.
|
||||
*/
|
||||
SlideWindow();
|
||||
SlideWindow();
|
||||
}
|
||||
|
||||
int prevMatch = matchStart;
|
||||
int prevLen = matchLen;
|
||||
if (lookahead >= MIN_MATCH) {
|
||||
int hashHead = InsertString();
|
||||
if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead)) {
|
||||
/* longestMatch sets matchStart and matchLen */
|
||||
if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead))
|
||||
{
|
||||
/* longestMatch sets matchStart and matchLen */
|
||||
|
||||
/* Discard match if too small and too far away */
|
||||
if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TOO_FAR))) {
|
||||
matchLen = MIN_MATCH - 1;
|
||||
/* Discard match if too small and too far away */
|
||||
if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TOO_FAR))) {
|
||||
matchLen = MIN_MATCH - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* previous match was better */
|
||||
if (prevLen >= MIN_MATCH && matchLen <= prevLen) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// for (int i = 0 ; i < matchLen; i++) {
|
||||
// if (window[strstart-1+i] != window[prevMatch + i])
|
||||
// throw new Exception();
|
||||
// }
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// for (int i = 0 ; i < matchLen; i++) {
|
||||
// if (window[strstart-1+i] != window[prevMatch + i])
|
||||
// throw new Exception();
|
||||
// }
|
||||
// }
|
||||
huffman.TallyDist(strstart - 1 - prevMatch, prevLen);
|
||||
prevLen -= 2;
|
||||
do {
|
||||
@@ -604,10 +601,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
do {
|
||||
FillWindow();
|
||||
bool canFlush = flush && inputOff == inputEnd;
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("window: ["+blockStart+","+strstart+","
|
||||
// +lookahead+"], "+comprFunc+","+canFlush);
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("window: ["+blockStart+","+strstart+","
|
||||
// +lookahead+"], "+comprFunc+","+canFlush);
|
||||
// }
|
||||
switch (comprFunc) {
|
||||
case DEFLATE_STORED:
|
||||
progress = DeflateStored(canFlush, finish);
|
||||
|
||||
+102
-104
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This is the DeflaterHuffman class.
|
||||
@@ -79,15 +78,15 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
15
|
||||
};
|
||||
|
||||
|
||||
public class Tree
|
||||
{
|
||||
public short[] freqs;
|
||||
public short[] codes;
|
||||
public byte[] length;
|
||||
public int[] bl_counts;
|
||||
public int minNumCodes, numCodes;
|
||||
|
||||
short[] codes;
|
||||
int[] bl_counts;
|
||||
int maxLength;
|
||||
public int maxLength;
|
||||
DeflaterHuffman dh;
|
||||
|
||||
public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength)
|
||||
@@ -110,10 +109,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
public void WriteSymbol(int code)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// freqs[code]--;
|
||||
// // Console.Write("writeSymbol("+freqs.length+","+code+"): ");
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// freqs[code]--;
|
||||
// // Console.Write("writeSymbol("+freqs.length+","+code+"): ");
|
||||
// }
|
||||
dh.pending.WriteBits(codes[code] & 0xffff, length[code]);
|
||||
}
|
||||
|
||||
@@ -122,14 +121,14 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
bool empty = true;
|
||||
for (int i = 0; i < freqs.Length; i++) {
|
||||
if (freqs[i] != 0) {
|
||||
//Console.WriteLine("freqs["+i+"] == "+freqs[i]);
|
||||
Console.WriteLine("freqs["+i+"] == "+freqs[i]);
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
if (!empty) {
|
||||
throw new Exception();
|
||||
}
|
||||
//Console.WriteLine("checkEmpty suceeded!");
|
||||
Console.WriteLine("checkEmpty suceeded!");
|
||||
}
|
||||
|
||||
public void SetStaticCodes(short[] stCodes, byte[] stLength)
|
||||
@@ -145,17 +144,17 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
int code = 0;
|
||||
codes = new short[freqs.Length];
|
||||
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("buildCodes: "+freqs.Length);
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("buildCodes: "+freqs.Length);
|
||||
// }
|
||||
|
||||
for (int bits = 0; bits < maxLength; bits++) {
|
||||
nextCode[bits] = code;
|
||||
code += bl_counts[bits] << (15 - bits);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("bits: "+(bits+1)+" count: "+bl_counts[bits]
|
||||
// +" nextCode: "+code); // HACK : Integer.toHexString(
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("bits: "+(bits+1)+" count: "+bl_counts[bits]
|
||||
// +" nextCode: "+code); // HACK : Integer.toHexString(
|
||||
// }
|
||||
}
|
||||
if (DeflaterConstants.DEBUGGING && code != 65536) {
|
||||
throw new Exception("Inconsistent bl_counts!");
|
||||
@@ -164,17 +163,17 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
for (int i=0; i < numCodes; i++) {
|
||||
int bits = length[i];
|
||||
if (bits > 0) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+")," // HACK : Integer.toHexString(
|
||||
// +bits);
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+")," // HACK : Integer.toHexString(
|
||||
// +bits);
|
||||
// }
|
||||
codes[i] = BitReverse(nextCode[bits-1]);
|
||||
nextCode[bits-1] += 1 << (16 - bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BuildLength(int[] childs)
|
||||
private void BuildLength(int[] childs)
|
||||
{
|
||||
this.length = new byte [freqs.Length];
|
||||
int numNodes = childs.Length / 2;
|
||||
@@ -205,13 +204,13 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
}
|
||||
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("Tree "+freqs.Length+" lengths:");
|
||||
// for (int i=0; i < numLeafs; i++) {
|
||||
// //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
|
||||
// + " len: "+length[childs[2*i]]);
|
||||
// }
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Tree "+freqs.Length+" lengths:");
|
||||
// for (int i=0; i < numLeafs; i++) {
|
||||
// Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
|
||||
// + " len: "+length[childs[2*i]]);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (overflow == 0) {
|
||||
return;
|
||||
@@ -259,13 +258,13 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("*** After overflow elimination. ***");
|
||||
// for (int i=0; i < numLeafs; i++) {
|
||||
// //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
|
||||
// + " len: "+length[childs[2*i]]);
|
||||
// }
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("*** After overflow elimination. ***");
|
||||
// for (int i=0; i < numLeafs; i++) {
|
||||
// Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
|
||||
// + " len: "+length[childs[2*i]]);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public void BuildTree()
|
||||
@@ -333,17 +332,16 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
/* Propagate the hole to the leafs of the heap */
|
||||
int ppos = 0;
|
||||
int path = 1;
|
||||
|
||||
while (path < heapLen) {
|
||||
if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) {
|
||||
path++;
|
||||
}
|
||||
|
||||
|
||||
heap[ppos] = heap[path];
|
||||
ppos = path;
|
||||
path = path * 2 + 1;
|
||||
}
|
||||
|
||||
|
||||
/* Now propagate the last element down along path. Normally
|
||||
* it shouldn't go too deep.
|
||||
*/
|
||||
@@ -366,17 +364,16 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
/* Again, propagate the hole to the leafs */
|
||||
ppos = 0;
|
||||
path = 1;
|
||||
|
||||
while (path < heapLen) {
|
||||
if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) {
|
||||
path++;
|
||||
}
|
||||
|
||||
|
||||
heap[ppos] = heap[path];
|
||||
ppos = path;
|
||||
path = ppos * 2 + 1;
|
||||
}
|
||||
|
||||
|
||||
/* Now propagate the new element down along path */
|
||||
while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) {
|
||||
heap[path] = heap[ppos];
|
||||
@@ -479,7 +476,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
while (count-- > 0) {
|
||||
blTree.WriteSymbol(curlen);
|
||||
}
|
||||
} else if (curlen != 0) {
|
||||
}
|
||||
else if (curlen != 0) {
|
||||
blTree.WriteSymbol(REP_3_6);
|
||||
dh.pending.WriteBits(count - 3, 2);
|
||||
} else if (count <= 10) {
|
||||
@@ -511,10 +509,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
/// </summary>
|
||||
public static short BitReverse(int value)
|
||||
{
|
||||
return (short) (bit4Reverse[value & 0xF] << 12 |
|
||||
bit4Reverse[(value >> 4) & 0xF] << 8 |
|
||||
bit4Reverse[(value >> 8) & 0xF] << 4 |
|
||||
bit4Reverse[value >> 12]);
|
||||
return (short) (bit4Reverse[value & 0xF] << 12
|
||||
| bit4Reverse[(value >> 4) & 0xF] << 8
|
||||
| bit4Reverse[(value >> 8) & 0xF] << 4
|
||||
| bit4Reverse[value >> 12]);
|
||||
}
|
||||
|
||||
|
||||
@@ -572,7 +570,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
blTree.Reset();
|
||||
}
|
||||
|
||||
int Lcode(int len)
|
||||
private int L_code(int len)
|
||||
{
|
||||
if (len == 255) {
|
||||
return 285;
|
||||
@@ -586,7 +584,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
return code + len;
|
||||
}
|
||||
|
||||
int Dcode(int distance)
|
||||
private int D_code(int distance)
|
||||
{
|
||||
int code = 0;
|
||||
while (distance >= 4) {
|
||||
@@ -609,9 +607,9 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
literalTree.WriteTree(blTree);
|
||||
distTree.WriteTree(blTree);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// blTree.CheckEmpty();
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// blTree.CheckEmpty();
|
||||
// }
|
||||
}
|
||||
|
||||
public void CompressBlock()
|
||||
@@ -620,11 +618,11 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
int litlen = l_buf[i] & 0xff;
|
||||
int dist = d_buf[i];
|
||||
if (dist-- != 0) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.Write("["+(dist+1)+","+(litlen+3)+"]: ");
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.Write("["+(dist+1)+","+(litlen+3)+"]: ");
|
||||
// }
|
||||
|
||||
int lc = Lcode(litlen);
|
||||
int lc = L_code(litlen);
|
||||
literalTree.WriteSymbol(lc);
|
||||
|
||||
int bits = (lc - 261) / 4;
|
||||
@@ -632,7 +630,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
pending.WriteBits(litlen & ((1 << bits) - 1), bits);
|
||||
}
|
||||
|
||||
int dc = Dcode(dist);
|
||||
int dc = D_code(dist);
|
||||
distTree.WriteSymbol(dc);
|
||||
|
||||
bits = dc / 2 - 1;
|
||||
@@ -640,40 +638,41 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
pending.WriteBits(dist & ((1 << bits) - 1), bits);
|
||||
}
|
||||
} else {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// if (litlen > 32 && litlen < 127) {
|
||||
// Console.Write("("+(char)litlen+"): ");
|
||||
// } else {
|
||||
// Console.Write("{"+litlen+"}: ");
|
||||
// }
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// if (litlen > 32 && litlen < 127) {
|
||||
// Console.Write("("+(char)litlen+"): ");
|
||||
// } else {
|
||||
// Console.Write("{"+litlen+"}: ");
|
||||
// }
|
||||
// }
|
||||
literalTree.WriteSymbol(litlen);
|
||||
}
|
||||
}
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.Write("EOF: ");
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.Write("EOF: ");
|
||||
// }
|
||||
literalTree.WriteSymbol(EOF_SYMBOL);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// literalTree.CheckEmpty();
|
||||
// distTree.CheckEmpty();
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// literalTree.CheckEmpty();
|
||||
// distTree.CheckEmpty();
|
||||
// }
|
||||
}
|
||||
|
||||
public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
|
||||
public void FlushStoredBlock(byte[] stored, int stored_offset, int stored_len, bool lastBlock)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("Flushing stored block "+ storedLength);
|
||||
// }
|
||||
pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Flushing stored block "+ stored_len);
|
||||
// }
|
||||
pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1)
|
||||
+ (lastBlock ? 1 : 0), 3);
|
||||
pending.AlignToByte();
|
||||
pending.WriteShort(storedLength);
|
||||
pending.WriteShort(~storedLength);
|
||||
pending.WriteBlock(stored, storedOffset, storedLength);
|
||||
pending.WriteShort(stored_len);
|
||||
pending.WriteShort(~stored_len);
|
||||
pending.WriteBlock(stored, stored_offset, stored_len);
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
|
||||
public void FlushBlock(byte[] stored, int stored_offset, int stored_len, bool lastBlock)
|
||||
{
|
||||
literalTree.freqs[EOF_SYMBOL]++;
|
||||
|
||||
@@ -695,8 +694,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
}
|
||||
int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() +
|
||||
literalTree.GetEncodedLength() + distTree.GetEncodedLength() +
|
||||
extra_bits;
|
||||
literalTree.GetEncodedLength() + distTree.GetEncodedLength() +
|
||||
extra_bits;
|
||||
|
||||
int static_len = extra_bits;
|
||||
for (int i = 0; i < LITERAL_NUM; i++) {
|
||||
@@ -710,13 +709,13 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
opt_len = static_len;
|
||||
}
|
||||
|
||||
if ((storedOffset >= 0) && (storedLength + 4 < (opt_len >> 3))) {
|
||||
if (stored_offset >= 0 && stored_len+4 < (opt_len >> 3)) {
|
||||
/* Store Block */
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len
|
||||
// + " <= " + static_len);
|
||||
// }
|
||||
FlushStoredBlock(stored, storedOffset, storedLength, lastBlock);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Storing, since " + stored_len + " < " + opt_len
|
||||
// + " <= " + static_len);
|
||||
// }
|
||||
FlushStoredBlock(stored, stored_offset, stored_len, lastBlock);
|
||||
} else if (opt_len == static_len) {
|
||||
/* Encode with static tree */
|
||||
pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3);
|
||||
@@ -735,19 +734,18 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
public bool IsFull()
|
||||
{
|
||||
// return last_lit + 16 >= BUFSIZE; // HACK: This was == 'last_lit == BUFSIZE', but errors occured with DeflateFast
|
||||
return last_lit >= BUFSIZE; // -jr- This is the correct form!
|
||||
return last_lit + 16 >= BUFSIZE; // HACK: This was == 'last_lit == BUFSIZE', but errors occured with DeflateFast
|
||||
}
|
||||
|
||||
public bool TallyLit(int lit)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// if (lit > 32 && lit < 127) {
|
||||
// //Console.WriteLine("("+(char)lit+")");
|
||||
// } else {
|
||||
// //Console.WriteLine("{"+lit+"}");
|
||||
// }
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// if (lit > 32 && lit < 127) {
|
||||
// Console.WriteLine("("+(char)lit+")");
|
||||
// } else {
|
||||
// Console.WriteLine("{"+lit+"}");
|
||||
// }
|
||||
// }
|
||||
d_buf[last_lit] = 0;
|
||||
l_buf[last_lit++] = (byte)lit;
|
||||
literalTree.freqs[lit]++;
|
||||
@@ -756,20 +754,20 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
public bool TallyDist(int dist, int len)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("["+dist+","+len+"]");
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("["+dist+","+len+"]");
|
||||
// }
|
||||
|
||||
d_buf[last_lit] = (short)dist;
|
||||
l_buf[last_lit++] = (byte)(len - 3);
|
||||
|
||||
int lc = Lcode(len - 3);
|
||||
int lc = L_code(len - 3);
|
||||
literalTree.freqs[lc]++;
|
||||
if (lc >= 265 && lc < 285) {
|
||||
extra_bits += (lc - 261) / 4;
|
||||
}
|
||||
|
||||
int dc = Dcode(dist - 1);
|
||||
int dc = D_code(dist - 1);
|
||||
distTree.freqs[dc]++;
|
||||
if (dc >= 4) {
|
||||
extra_bits += dc / 2 - 1;
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This class stores the pending output of the Deflater.
|
||||
|
||||
+31
-35
@@ -40,8 +40,7 @@ using System;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// Inflater is used to decompress data that has been compressed according
|
||||
@@ -70,35 +69,35 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
/// Copy lengths for literal codes 257..285
|
||||
/// </summary>
|
||||
private static int[] CPLENS = {
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
|
||||
};
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Extra bits for literal codes 257..285
|
||||
/// </summary>
|
||||
private static int[] CPLEXT = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Copy offsets for distance codes 0..29
|
||||
/// </summary>
|
||||
private static int[] CPDIST = {
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577
|
||||
};
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Extra bits for distance codes
|
||||
/// </summary>
|
||||
private static int[] CPDEXT = {
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13
|
||||
};
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// This are the state in which the inflater can be.
|
||||
@@ -385,7 +384,9 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
neededBits -= 8;
|
||||
}
|
||||
if ((int) adler.Value != readAdler) {
|
||||
throw new FormatException("Adler chksum doesn't match: " + (int)adler.Value + " vs. " + readAdler);
|
||||
throw new FormatException("Adler chksum doesn't match: "
|
||||
+ (int)adler.Value
|
||||
+ " vs. " + readAdler);
|
||||
}
|
||||
mode = FINISHED;
|
||||
return false;
|
||||
@@ -432,7 +433,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
if ((type & 1) != 0) {
|
||||
isLastBlock = true;
|
||||
}
|
||||
switch (type >> 1){
|
||||
switch (type >> 1) {
|
||||
case DeflaterConstants.STORED_BLOCK:
|
||||
input.SkipToByteBoundary();
|
||||
mode = DECODE_STORED_LEN1;
|
||||
@@ -451,17 +452,15 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
return true;
|
||||
|
||||
case DECODE_STORED_LEN1:
|
||||
{
|
||||
case DECODE_STORED_LEN1: {
|
||||
if ((uncomprLen = input.PeekBits(16)) < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(16);
|
||||
mode = DECODE_STORED_LEN2;
|
||||
}
|
||||
goto case DECODE_STORED_LEN2; /* fall through */
|
||||
case DECODE_STORED_LEN2:
|
||||
{
|
||||
goto case DECODE_STORED_LEN2; /* fall through */
|
||||
case DECODE_STORED_LEN2: {
|
||||
int nlen = input.PeekBits(16);
|
||||
if (nlen < 0) {
|
||||
return false;
|
||||
@@ -472,9 +471,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
mode = DECODE_STORED;
|
||||
}
|
||||
goto case DECODE_STORED;/* fall through */
|
||||
case DECODE_STORED:
|
||||
{
|
||||
goto case DECODE_STORED;/* fall through */
|
||||
case DECODE_STORED: {
|
||||
int more = outputWindow.CopyStored(input, uncomprLen);
|
||||
uncomprLen -= more;
|
||||
if (uncomprLen == 0) {
|
||||
@@ -556,7 +554,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
|
||||
adler.Update(buffer, off, len);
|
||||
if ((int)adler.Value != readAdler) {
|
||||
if ((int) adler.Value != readAdler) {
|
||||
throw new ArgumentException("Wrong adler checksum");
|
||||
}
|
||||
adler.Reset();
|
||||
@@ -662,15 +660,12 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
}
|
||||
// Special case: len may be zero
|
||||
if (len == 0) {
|
||||
if (IsFinished == false) {// -jr- 08-Nov-2003 INFLATE_BUG fix..
|
||||
Decode();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* // Check for correct buff, off, len triple
|
||||
if (off < 0 || off + len >= buf.Length) {
|
||||
throw new ArgumentException("off/len outside buf bounds");
|
||||
}*/
|
||||
/* // Check for correct buff, off, len triple
|
||||
if (off < 0 || off + len >= buf.Length) {
|
||||
throw new ArgumentException("off/len outside buf bounds");
|
||||
}*/
|
||||
int count = 0;
|
||||
int more;
|
||||
do {
|
||||
@@ -692,7 +687,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
return count;
|
||||
}
|
||||
}
|
||||
} while (Decode() || (outputWindow.GetAvailable() > 0 && mode != DECODE_CHKSUM));
|
||||
} while (Decode() || (outputWindow.GetAvailable() > 0 &&
|
||||
mode != DECODE_CHKSUM));
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
+89
-93
@@ -39,8 +39,7 @@ using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
class InflaterDynHeader
|
||||
{
|
||||
@@ -65,8 +64,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
byte lastLen;
|
||||
int ptr;
|
||||
|
||||
static readonly int[] BL_ORDER =
|
||||
{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
||||
static readonly int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
||||
|
||||
public InflaterDynHeader()
|
||||
{
|
||||
@@ -75,93 +73,91 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
public bool Decode(StreamManipulator input)
|
||||
{
|
||||
decode_loop:
|
||||
for (;;) {
|
||||
switch (mode) {
|
||||
case LNUM:
|
||||
lnum = input.PeekBits(5);
|
||||
if (lnum < 0) {
|
||||
return false;
|
||||
}
|
||||
lnum += 257;
|
||||
input.DropBits(5);
|
||||
// System.err.println("LNUM: "+lnum);
|
||||
mode = DNUM;
|
||||
goto case DNUM; // fall through
|
||||
case DNUM:
|
||||
dnum = input.PeekBits(5);
|
||||
if (dnum < 0) {
|
||||
return false;
|
||||
}
|
||||
dnum++;
|
||||
input.DropBits(5);
|
||||
// System.err.println("DNUM: "+dnum);
|
||||
num = lnum+dnum;
|
||||
litdistLens = new byte[num];
|
||||
mode = BLNUM;
|
||||
goto case BLNUM; // fall through
|
||||
case BLNUM:
|
||||
blnum = input.PeekBits(4);
|
||||
if (blnum < 0) {
|
||||
return false;
|
||||
}
|
||||
blnum += 4;
|
||||
input.DropBits(4);
|
||||
blLens = new byte[19];
|
||||
ptr = 0;
|
||||
// System.err.println("BLNUM: "+blnum);
|
||||
mode = BLLENS;
|
||||
goto case BLLENS; // fall through
|
||||
case BLLENS:
|
||||
while (ptr < blnum) {
|
||||
int len = input.PeekBits(3);
|
||||
if (len < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(3);
|
||||
// System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len);
|
||||
blLens[BL_ORDER[ptr]] = (byte) len;
|
||||
ptr++;
|
||||
}
|
||||
blTree = new InflaterHuffmanTree(blLens);
|
||||
blLens = null;
|
||||
ptr = 0;
|
||||
mode = LENS;
|
||||
goto case LENS; // fall through
|
||||
case LENS:
|
||||
{
|
||||
int symbol;
|
||||
while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) {
|
||||
/* Normal case: symbol in [0..15] */
|
||||
|
||||
// System.err.println("litdistLens["+ptr+"]: "+symbol);
|
||||
litdistLens[ptr++] = lastLen = (byte)symbol;
|
||||
|
||||
if (ptr == num) {
|
||||
/* Finished */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* need more input ? */
|
||||
if (symbol < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* otherwise repeat code */
|
||||
if (symbol >= 17) {
|
||||
/* repeat zero */
|
||||
// System.err.println("repeating zero");
|
||||
lastLen = 0;
|
||||
} else {
|
||||
if (ptr == 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
repSymbol = symbol-16;
|
||||
for (;;) {
|
||||
switch (mode) {
|
||||
case LNUM:
|
||||
lnum = input.PeekBits(5);
|
||||
if (lnum < 0) {
|
||||
return false;
|
||||
}
|
||||
mode = REPS;
|
||||
goto case REPS; // fall through
|
||||
case REPS:
|
||||
lnum += 257;
|
||||
input.DropBits(5);
|
||||
// System.err.println("LNUM: "+lnum);
|
||||
mode = DNUM;
|
||||
goto case DNUM; // fall through
|
||||
case DNUM:
|
||||
dnum = input.PeekBits(5);
|
||||
if (dnum < 0) {
|
||||
return false;
|
||||
}
|
||||
dnum++;
|
||||
input.DropBits(5);
|
||||
// System.err.println("DNUM: "+dnum);
|
||||
num = lnum+dnum;
|
||||
litdistLens = new byte[num];
|
||||
mode = BLNUM;
|
||||
goto case BLNUM; // fall through
|
||||
case BLNUM:
|
||||
blnum = input.PeekBits(4);
|
||||
if (blnum < 0) {
|
||||
return false;
|
||||
}
|
||||
blnum += 4;
|
||||
input.DropBits(4);
|
||||
blLens = new byte[19];
|
||||
ptr = 0;
|
||||
// System.err.println("BLNUM: "+blnum);
|
||||
mode = BLLENS;
|
||||
goto case BLLENS; // fall through
|
||||
case BLLENS:
|
||||
while (ptr < blnum) {
|
||||
int len = input.PeekBits(3);
|
||||
if (len < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(3);
|
||||
// System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len);
|
||||
blLens[BL_ORDER[ptr]] = (byte) len;
|
||||
ptr++;
|
||||
}
|
||||
blTree = new InflaterHuffmanTree(blLens);
|
||||
blLens = null;
|
||||
ptr = 0;
|
||||
mode = LENS;
|
||||
goto case LENS; // fall through
|
||||
case LENS: {
|
||||
int symbol;
|
||||
while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) {
|
||||
/* Normal case: symbol in [0..15] */
|
||||
|
||||
// System.err.println("litdistLens["+ptr+"]: "+symbol);
|
||||
litdistLens[ptr++] = lastLen = (byte)symbol;
|
||||
|
||||
if (ptr == num) {
|
||||
/* Finished */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* need more input ? */
|
||||
if (symbol < 0)
|
||||
return false;
|
||||
|
||||
/* otherwise repeat code */
|
||||
if (symbol >= 17) {
|
||||
/* repeat zero */
|
||||
// System.err.println("repeating zero");
|
||||
lastLen = 0;
|
||||
} else {
|
||||
if (ptr == 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
repSymbol = symbol-16;
|
||||
}
|
||||
mode = REPS;
|
||||
goto case REPS; // fall through
|
||||
case REPS:
|
||||
{
|
||||
int bits = repBits[repSymbol];
|
||||
int count = input.PeekBits(bits);
|
||||
@@ -184,10 +180,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
return true;
|
||||
}
|
||||
}
|
||||
mode = LENS;
|
||||
goto decode_loop;
|
||||
}
|
||||
mode = LENS;
|
||||
goto decode_loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InflaterHuffmanTree BuildLitLenTree()
|
||||
|
||||
+3
-8
@@ -39,8 +39,7 @@ using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
public class InflaterHuffmanTree
|
||||
{
|
||||
@@ -97,9 +96,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
for (int i = 0; i < codeLengths.Length; i++) {
|
||||
int bits = codeLengths[i];
|
||||
if (bits > 0) {
|
||||
if (bits > 0)
|
||||
blCount[bits]++;
|
||||
}
|
||||
}
|
||||
|
||||
int code = 0;
|
||||
@@ -114,12 +112,9 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
treeSize += (end - start) >> (16 - bits);
|
||||
}
|
||||
}
|
||||
/* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g
|
||||
if (code != 65536)
|
||||
{
|
||||
if (code != 65536) {
|
||||
throw new Exception("Code lengths don't add up properly.");
|
||||
}
|
||||
*/
|
||||
/* Now create and fill the extra tables from longest to shortest
|
||||
* bit len. This way the sub trees will be aligned.
|
||||
*/
|
||||
|
||||
+6
-8
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This class is general purpose class for writing data to a buffer.
|
||||
@@ -74,9 +73,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
public void WriteByte(int b)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
if (DeflaterConstants.DEBUGGING && start != 0)
|
||||
throw new Exception();
|
||||
}
|
||||
buf[end++] = (byte) b;
|
||||
}
|
||||
|
||||
@@ -135,9 +133,9 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("writeBits("+b+","+count+")");
|
||||
// }
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("writeBits("+b+","+count+")");
|
||||
// }
|
||||
bits |= (uint)(b << bitCount);
|
||||
bitCount += count;
|
||||
if (bitCount >= 16) {
|
||||
@@ -200,7 +198,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
byte[] ret = new byte[end - start];
|
||||
byte[] ret = new byte[ end - start ];
|
||||
System.Array.Copy(buf, start, ret, 0, ret.Length);
|
||||
start = 0;
|
||||
end = 0;
|
||||
|
||||
+9
-92
@@ -37,11 +37,10 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// This is a special FilterOutputStream deflating the bytes that are
|
||||
@@ -81,8 +80,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return false;
|
||||
// return baseOutputStream.CanSeek;
|
||||
return baseOutputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +119,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003
|
||||
// return baseOutputStream.Seek(offset, origin);
|
||||
return baseOutputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,24 +145,14 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
return baseOutputStream.Read(b, off, len);
|
||||
}
|
||||
// -jr- 01-Dec-2003
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new NotSupportedException("Asynch read not currently supported");
|
||||
}
|
||||
|
||||
// -jr- 01-Dec-2003
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new NotSupportedException("Asynch write not currently supported");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deflates everything in the def's input buffers. This will call
|
||||
/// <code>def.deflate()</code> until all bytes from the input buffers
|
||||
/// are processed.
|
||||
/// </summary>
|
||||
protected void Deflate()
|
||||
protected void deflate()
|
||||
{
|
||||
while (!def.IsNeedingInput) {
|
||||
int len = def.Deflate(buf, 0, buf.Length);
|
||||
@@ -190,6 +177,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </param>
|
||||
public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,7 +228,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
public override void Flush()
|
||||
{
|
||||
def.Flush();
|
||||
Deflate();
|
||||
deflate();
|
||||
baseOutputStream.Flush();
|
||||
}
|
||||
|
||||
@@ -250,18 +238,11 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
public virtual void Finish()
|
||||
{
|
||||
def.Finish();
|
||||
while (!def.IsFinished) {
|
||||
while (!def.IsFinished) {
|
||||
int len = def.Deflate(buf, 0, buf.Length);
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// kidnthrain encryption alteration
|
||||
if (this.Password != null) {
|
||||
// plain data has been deflated. Now encrypt result
|
||||
this.EncryptBlock(buf, 0, len);
|
||||
}
|
||||
|
||||
baseOutputStream.Write(buf, 0, len);
|
||||
}
|
||||
if (!def.IsFinished) {
|
||||
@@ -308,72 +289,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
// System.err.println("DOS with off " + off + " and len " + len);
|
||||
def.SetInput(buf, off, len);
|
||||
Deflate();
|
||||
deflate();
|
||||
}
|
||||
|
||||
#region Encryption
|
||||
string password = null;
|
||||
uint[] keys = null;
|
||||
|
||||
public string Password {
|
||||
get {
|
||||
return password;
|
||||
}
|
||||
set {
|
||||
password = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//The beauty of xor-ing bits is that
|
||||
//plain ^ key = enc
|
||||
//and enc ^ key = plain
|
||||
//accordingly, this is the exact same as the decrypt byte
|
||||
//function in InflaterInputStream
|
||||
protected byte EncryptByte()
|
||||
{
|
||||
uint temp = ((keys[2] & 0xFFFF) | 2);
|
||||
return (byte)((temp * (temp ^ 1)) >> 8);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Takes a buffer of data and uses the keys
|
||||
/// that have been previously initialized from a
|
||||
/// password and then updated via a random encryption header
|
||||
/// to encrypt that data
|
||||
/// </summary>
|
||||
protected void EncryptBlock(byte[] buf, int off, int len)
|
||||
{
|
||||
for (int i = off; i < off + len; ++i) {
|
||||
byte oldbyte = buf[i];
|
||||
buf[i] ^= EncryptByte();
|
||||
UpdateKeys(oldbyte);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes our encryption keys using a given password
|
||||
/// </summary>
|
||||
protected void InitializePassword(string password) {
|
||||
keys = new uint[] {
|
||||
0x12345678,
|
||||
0x23456789,
|
||||
0x34567890
|
||||
};
|
||||
|
||||
for (int i = 0; i < password.Length; ++i) {
|
||||
UpdateKeys((byte)password[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateKeys(byte ch)
|
||||
{
|
||||
keys[0] = Crc32.ComputeCrc32(keys[0], ch);
|
||||
keys[1] = keys[1] + (byte)keys[0];
|
||||
keys[1] = keys[1] * 134775813 + 1;
|
||||
keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+24
-63
@@ -39,10 +39,8 @@ using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// This filter stream is used to decompress data compressed baseInputStream the "deflate"
|
||||
@@ -62,6 +60,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
protected Inflater inf;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Byte array used as a buffer
|
||||
/// </summary>
|
||||
@@ -80,8 +79,6 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
protected Stream baseInputStream;
|
||||
|
||||
protected long csize;
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
@@ -96,8 +93,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return false;
|
||||
// return baseInputStream.CanSeek;
|
||||
return baseInputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +140,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003
|
||||
return baseInputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -171,12 +167,6 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
baseInputStream.WriteByte(val);
|
||||
}
|
||||
|
||||
// -jr- 01-Dec-2003 This may be flawed for some base streams? Depends on implementation of BeginWrite
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new NotSupportedException("Asynch write not currently supported");
|
||||
}
|
||||
|
||||
//Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -203,6 +193,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </param>
|
||||
public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -224,8 +215,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
this.inf = inf;
|
||||
try {
|
||||
this.len = (int)baseInputStream.Length;
|
||||
} catch (Exception) {
|
||||
// the stream may not support .Length
|
||||
} catch (Exception) { // the stream may not support .Length
|
||||
this.len = 0;
|
||||
}
|
||||
|
||||
@@ -253,7 +243,9 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
baseInputStream.Close();
|
||||
// Do not close the parent, it might be used by a ZipFile, and
|
||||
// we do not want to close the "master" source.
|
||||
// baseInputStream.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -262,12 +254,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
protected void Fill()
|
||||
{
|
||||
len = baseInputStream.Read(buf, 0, buf.Length);
|
||||
// decrypting crypted data
|
||||
if (cryptbuffer != null) {
|
||||
DecryptBlock(buf, 0, System.Math.Min((int)(csize - inf.TotalIn), buf.Length));
|
||||
}
|
||||
|
||||
if (len <= 0) {
|
||||
if (len < 0) {
|
||||
throw new ApplicationException("Deflated stream ends early.");
|
||||
}
|
||||
inf.SetInput(buf, 0, len);
|
||||
@@ -284,7 +272,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
if (nread > 0) {
|
||||
return onebytebuffer[0] & 0xff;
|
||||
}
|
||||
return -1; // ok
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -340,47 +328,20 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
if (n < len) {
|
||||
len = (int) n;
|
||||
}
|
||||
byte[] tmp = new byte[len];
|
||||
return (long)baseInputStream.Read(tmp, 0, tmp.Length);
|
||||
}
|
||||
|
||||
#region Encryption stuff
|
||||
protected byte[] cryptbuffer = null;
|
||||
|
||||
uint[] keys = null;
|
||||
protected byte DecryptByte()
|
||||
{
|
||||
uint temp = ((keys[2] & 0xFFFF) | 2);
|
||||
return (byte)((temp * (temp ^ 1)) >> 8);
|
||||
}
|
||||
|
||||
protected void DecryptBlock(byte[] buf, int off, int len)
|
||||
{
|
||||
for (int i = off; i < off + len; ++i) {
|
||||
buf[i] ^= DecryptByte();
|
||||
UpdateKeys(buf[i]);
|
||||
if (false && baseInputStream.CanSeek){
|
||||
baseInputStream.Seek (len, SeekOrigin.Current);
|
||||
} else {
|
||||
byte[] tmp = new byte[8192];
|
||||
|
||||
for (long i = 0; i < len; ){
|
||||
long left = len - i;
|
||||
int count = left < 8192 ? ((int) left) : 8192;
|
||||
|
||||
baseInputStream.Read (tmp, 0, count);
|
||||
i += count;
|
||||
}
|
||||
}
|
||||
return (long) len;
|
||||
}
|
||||
|
||||
protected void InitializePassword(string password)
|
||||
{
|
||||
keys = new uint[] {
|
||||
0x12345678,
|
||||
0x23456789,
|
||||
0x34567890
|
||||
};
|
||||
for (int i = 0; i < password.Length; ++i) {
|
||||
UpdateKeys((byte)password[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateKeys(byte ch)
|
||||
{
|
||||
keys[0] = Crc32.ComputeCrc32(keys[0], ch);
|
||||
keys[1] = keys[1] + (byte)keys[0];
|
||||
keys[1] = keys[1] * 134775813 + 1;
|
||||
keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+36
-36
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// Contains the output from the Inflation process.
|
||||
@@ -53,45 +52,45 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
private static int WINDOW_MASK = WINDOW_SIZE - 1;
|
||||
|
||||
private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes
|
||||
private int windowEnd = 0;
|
||||
private int windowFilled = 0;
|
||||
private int window_end = 0;
|
||||
private int window_filled = 0;
|
||||
|
||||
public void Write(int abyte)
|
||||
{
|
||||
if (windowFilled++ == WINDOW_SIZE) {
|
||||
if (window_filled++ == WINDOW_SIZE) {
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
window[windowEnd++] = (byte) abyte;
|
||||
windowEnd &= WINDOW_MASK;
|
||||
window[window_end++] = (byte) abyte;
|
||||
window_end &= WINDOW_MASK;
|
||||
}
|
||||
|
||||
|
||||
private void SlowRepeat(int repStart, int len, int dist)
|
||||
private void SlowRepeat(int rep_start, int len, int dist)
|
||||
{
|
||||
while (len-- > 0) {
|
||||
window[windowEnd++] = window[repStart++];
|
||||
windowEnd &= WINDOW_MASK;
|
||||
repStart &= WINDOW_MASK;
|
||||
window[window_end++] = window[rep_start++];
|
||||
window_end &= WINDOW_MASK;
|
||||
rep_start &= WINDOW_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
public void Repeat(int len, int dist)
|
||||
{
|
||||
if ((windowFilled += len) > WINDOW_SIZE) {
|
||||
if ((window_filled += len) > WINDOW_SIZE) {
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
|
||||
int rep_start = (windowEnd - dist) & WINDOW_MASK;
|
||||
int rep_start = (window_end - dist) & WINDOW_MASK;
|
||||
int border = WINDOW_SIZE - len;
|
||||
if (rep_start <= border && windowEnd < border) {
|
||||
if (rep_start <= border && window_end < border) {
|
||||
if (len <= dist) {
|
||||
System.Array.Copy(window, rep_start, window, windowEnd, len);
|
||||
windowEnd += len;
|
||||
} else {
|
||||
System.Array.Copy(window, rep_start, window, window_end, len);
|
||||
window_end += len;
|
||||
} else {
|
||||
/* We have to copy manually, since the repeat pattern overlaps.
|
||||
*/
|
||||
while (len-- > 0) {
|
||||
window[windowEnd++] = window[rep_start++];
|
||||
window[window_end++] = window[rep_start++];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -101,27 +100,27 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
|
||||
public int CopyStored(StreamManipulator input, int len)
|
||||
{
|
||||
len = Math.Min(Math.Min(len, WINDOW_SIZE - windowFilled), input.AvailableBytes);
|
||||
len = Math.Min(Math.Min(len, WINDOW_SIZE - window_filled), input.AvailableBytes);
|
||||
int copied;
|
||||
|
||||
int tailLen = WINDOW_SIZE - windowEnd;
|
||||
int tailLen = WINDOW_SIZE - window_end;
|
||||
if (len > tailLen) {
|
||||
copied = input.CopyBytes(window, windowEnd, tailLen);
|
||||
copied = input.CopyBytes(window, window_end, tailLen);
|
||||
if (copied == tailLen) {
|
||||
copied += input.CopyBytes(window, 0, len - tailLen);
|
||||
}
|
||||
} else {
|
||||
copied = input.CopyBytes(window, windowEnd, len);
|
||||
copied = input.CopyBytes(window, window_end, len);
|
||||
}
|
||||
|
||||
windowEnd = (windowEnd + copied) & WINDOW_MASK;
|
||||
windowFilled += copied;
|
||||
window_end = (window_end + copied) & WINDOW_MASK;
|
||||
window_filled += copied;
|
||||
return copied;
|
||||
}
|
||||
|
||||
public void CopyDict(byte[] dict, int offset, int len)
|
||||
{
|
||||
if (windowFilled > 0) {
|
||||
if (window_filled > 0) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
@@ -130,39 +129,40 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
len = WINDOW_SIZE;
|
||||
}
|
||||
System.Array.Copy(dict, offset, window, 0, len);
|
||||
windowEnd = len & WINDOW_MASK;
|
||||
window_end = len & WINDOW_MASK;
|
||||
}
|
||||
|
||||
public int GetFreeSpace()
|
||||
{
|
||||
return WINDOW_SIZE - windowFilled;
|
||||
return WINDOW_SIZE - window_filled;
|
||||
}
|
||||
|
||||
public int GetAvailable()
|
||||
{
|
||||
return windowFilled;
|
||||
return window_filled;
|
||||
}
|
||||
|
||||
public int CopyOutput(byte[] output, int offset, int len)
|
||||
{
|
||||
int copy_end = windowEnd;
|
||||
if (len > windowFilled) {
|
||||
len = windowFilled;
|
||||
int copy_end = window_end;
|
||||
if (len > window_filled) {
|
||||
len = window_filled;
|
||||
} else {
|
||||
copy_end = (windowEnd - windowFilled + len) & WINDOW_MASK;
|
||||
copy_end = (window_end - window_filled + len) & WINDOW_MASK;
|
||||
}
|
||||
|
||||
int copied = len;
|
||||
int tailLen = len - copy_end;
|
||||
|
||||
if (tailLen > 0) {
|
||||
System.Array.Copy(window, WINDOW_SIZE - tailLen, output, offset, tailLen);
|
||||
System.Array.Copy(window, WINDOW_SIZE - tailLen,
|
||||
output, offset, tailLen);
|
||||
offset += tailLen;
|
||||
len = copy_end;
|
||||
}
|
||||
System.Array.Copy(window, copy_end - len, output, offset, len);
|
||||
windowFilled -= copied;
|
||||
if (windowFilled < 0) {
|
||||
window_filled -= copied;
|
||||
if (window_filled < 0) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
return copied;
|
||||
@@ -170,7 +170,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
windowFilled = windowEnd = 0;
|
||||
window_filled = window_end = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// This class allows us to retrieve a specified amount of bits from
|
||||
@@ -76,7 +75,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
if (bits_in_buffer < n) {
|
||||
if (window_start == window_end) {
|
||||
return -1; // ok
|
||||
return -1;
|
||||
}
|
||||
buffer |= (uint)((window[window_start++] & 0xff |
|
||||
(window[window_start++] & 0xff) << 8) << bits_in_buffer);
|
||||
@@ -175,7 +174,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
if (length < 0) {
|
||||
throw new ArgumentOutOfRangeException("length negative");
|
||||
}
|
||||
if ((bits_in_buffer & 7) != 0) {
|
||||
if ((bits_in_buffer & 7) != 0) {
|
||||
/* bits_in_buffer may only be 0 or 8 */
|
||||
throw new InvalidOperationException("Bit buffer is not aligned!");
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for zip.
|
||||
@@ -59,9 +58,6 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
public const int LOCNAM = 26;
|
||||
public const int LOCEXT = 28;
|
||||
|
||||
public const int SPANNINGSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
|
||||
public const int SPANTEMPSIG = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24);
|
||||
|
||||
/* The Data descriptor */
|
||||
public const int EXTSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
|
||||
public const int EXTHDR = 16;
|
||||
@@ -74,7 +70,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
public const int CENSIG = 'P' | ('K' << 8) | (1 << 16) | (2 << 24);
|
||||
|
||||
/* The central directory file header for 64bit ZIP*/
|
||||
public const int CENSIG64 = 'P' | ('K' << 8) | (6 << 16) | (6 << 24);
|
||||
public const int CENSIG64 = 0x06064b50;
|
||||
|
||||
public const int CENHDR = 46;
|
||||
|
||||
@@ -98,9 +94,6 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
public const int ENDSIG = 'P' | ('K' << 8) | (5 << 16) | (6 << 24);
|
||||
public const int ENDHDR = 22;
|
||||
|
||||
public const int HDRDIGITALSIG = 'P' | ('K' << 8) | (5 << 16) | (5 << 24);
|
||||
public const int CENDIGITALSIG = 'P' | ('K' << 8) | (5 << 16) | (5 << 24);
|
||||
|
||||
/* The following two fields are missing in SUN JDK */
|
||||
public const int ENDNRD = 4;
|
||||
public const int ENDDCD = 6;
|
||||
@@ -111,36 +104,21 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
public const int ENDOFF = 16;
|
||||
public const int ENDCOM = 20;
|
||||
|
||||
|
||||
static int defaultCodePage = 0; // 0 gives default code page, set it to whatever you like or alternatively alter it via property at runtime for more flexibility
|
||||
// Some care for compatability purposes is required as you can specify unicode code pages here.... if this way of working seems ok
|
||||
// then some protection may be added to make the interface a bit more robust perhaps.
|
||||
|
||||
public static int DefaultCodePage {
|
||||
get {
|
||||
return defaultCodePage;
|
||||
}
|
||||
set {
|
||||
defaultCodePage = value;
|
||||
}
|
||||
}
|
||||
|
||||
/* Using the codepage 1252 doesn't solve the 8bit ASCII problem :/
|
||||
any help would be appreciated.
|
||||
|
||||
// get encoding for latin characters (like ö, ü, ß or ô)
|
||||
static Encoding ecp1252 = Encoding.GetEncoding(1252);
|
||||
*/
|
||||
public static string ConvertToString(byte[] data)
|
||||
{
|
||||
#if COMACT_FRAMEWORK
|
||||
return Encoding.ASCII.GetString(data,0, data.Length);
|
||||
#else
|
||||
return Encoding.GetEncoding(DefaultCodePage).GetString(data, 0, data.Length);
|
||||
#endif
|
||||
|
||||
return Encoding.ASCII.GetString(data);
|
||||
}
|
||||
|
||||
public static byte[] ConvertToArray(string str)
|
||||
{
|
||||
#if COMACT_FRAMEWORK
|
||||
return Encoding.ASCII.GetBytes(str);
|
||||
#else
|
||||
return Encoding.GetEncoding(DefaultCodePage).GetBytes(str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,7 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
public enum CompressionMethod
|
||||
{
|
||||
@@ -61,63 +60,22 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
static int KNOWN_CRC = 4;
|
||||
static int KNOWN_TIME = 8;
|
||||
|
||||
DateTime cal = DateTime.Now;
|
||||
|
||||
string name;
|
||||
uint size;
|
||||
ushort version;
|
||||
uint compressedSize;
|
||||
uint crc;
|
||||
uint dosTime;
|
||||
int crc;
|
||||
|
||||
ushort known = 0;
|
||||
CompressionMethod method = CompressionMethod.Deflated;
|
||||
byte[] extra = null;
|
||||
string comment = null;
|
||||
bool isCrypted;
|
||||
|
||||
int zipFileIndex = -1; /* used by ZipFile */
|
||||
int flags; /* used by ZipOutputStream */
|
||||
int offset; /* used by ZipFile and ZipOutputStream */
|
||||
|
||||
public bool IsEncrypted {
|
||||
get {
|
||||
return (flags & 1) != 0;
|
||||
}
|
||||
set {
|
||||
if (value) {
|
||||
flags |= 1;
|
||||
} else {
|
||||
flags &= ~1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int ZipFileIndex {
|
||||
get {
|
||||
return zipFileIndex;
|
||||
}
|
||||
set {
|
||||
zipFileIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Offset {
|
||||
get {
|
||||
return offset;
|
||||
}
|
||||
set {
|
||||
offset = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Flags { // Stops having two things represent same concept in class (flag isCrypted removed)
|
||||
get {
|
||||
return flags;
|
||||
}
|
||||
set {
|
||||
flags = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int zipFileIndex = -1; /* used by ZipFile */
|
||||
public int flags; /* used by ZipOutputStream */
|
||||
public int offset; /* used by ZipFile and ZipOutputStream */
|
||||
|
||||
/// <summary>
|
||||
/// Creates a zip entry with the given name.
|
||||
@@ -127,10 +85,9 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
/// </param>
|
||||
public ZipEntry(string name)
|
||||
{
|
||||
if (name == null) {
|
||||
if (name == null) {
|
||||
throw new System.ArgumentNullException("name");
|
||||
}
|
||||
this.DateTime = System.DateTime.Now;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -142,64 +99,72 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
/// </param>
|
||||
public ZipEntry(ZipEntry e)
|
||||
{
|
||||
name = e.name;
|
||||
known = e.known;
|
||||
size = e.size;
|
||||
name = e.name;
|
||||
known = e.known;
|
||||
size = e.size;
|
||||
compressedSize = e.compressedSize;
|
||||
crc = e.crc;
|
||||
dosTime = e.dosTime;
|
||||
method = e.method;
|
||||
extra = e.extra;
|
||||
comment = e.comment;
|
||||
crc = e.crc;
|
||||
// time = e.time;
|
||||
method = e.method;
|
||||
extra = e.extra;
|
||||
comment = e.comment;
|
||||
}
|
||||
|
||||
public int Version {
|
||||
public ushort Version {
|
||||
get {
|
||||
return version;
|
||||
}
|
||||
set {
|
||||
version = (ushort)value;
|
||||
version = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long DosTime {
|
||||
public int DosTime {
|
||||
get {
|
||||
if ((known & KNOWN_TIME) == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return dosTime;
|
||||
// if ((known & KNOWN_TIME) == 0) {
|
||||
// return 0;
|
||||
// }
|
||||
lock (this) {
|
||||
return (cal.Year - 1980 & 0x7f) << 25 |
|
||||
(cal.Month + 1) << 21 |
|
||||
(cal.Day ) << 16 |
|
||||
(cal.Hour) << 11 |
|
||||
(cal.Minute) << 5 |
|
||||
(cal.Second) >> 1;
|
||||
}
|
||||
}
|
||||
set {
|
||||
this.dosTime = (uint)value;
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
// Guard against invalid or missing date causing
|
||||
// IndexOutOfBoundsException.
|
||||
try {
|
||||
lock (this) {
|
||||
cal = CalculateDateTime(value);
|
||||
// time = (int) (cal.Millisecond / 1000L);
|
||||
}
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
} catch (Exception) {
|
||||
/* Ignore illegal time stamp */
|
||||
known &= (ushort)~KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the time of last modification of the entry.
|
||||
/// </summary>
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
uint sec = 2 * (dosTime & 0x1f);
|
||||
uint min = (dosTime >> 5) & 0x3f;
|
||||
uint hrs = (dosTime >> 11) & 0x1f;
|
||||
uint day = (dosTime >> 16) & 0x1f;
|
||||
uint mon = ((dosTime >> 21) & 0xf);
|
||||
uint year = ((dosTime >> 25) & 0x7f) + 1980; /* since 1900 */
|
||||
return new System.DateTime((int)year, (int)mon, (int)day, (int)hrs, (int)min, (int)sec);
|
||||
return cal;
|
||||
}
|
||||
set {
|
||||
DosTime = ((uint)value.Year - 1980 & 0x7f) << 25 |
|
||||
((uint)value.Month) << 21 |
|
||||
((uint)value.Day) << 16 |
|
||||
((uint)value.Hour) << 11 |
|
||||
((uint)value.Minute) << 5 |
|
||||
((uint)value.Second) >> 1;
|
||||
lock (this) {
|
||||
cal = value;
|
||||
// time = (int) (cal.Millisecond / 1000L);
|
||||
}
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the entry name. The path components in the entry are
|
||||
/// always separated by slashes ('/').
|
||||
@@ -210,21 +175,21 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets/Sets the time of last modification of the entry.
|
||||
// /// </summary>
|
||||
// /// <returns>
|
||||
// /// the time of last modification of the entry, or -1 if unknown.
|
||||
// /// </returns>
|
||||
// public long Time {
|
||||
// get {
|
||||
// return (known & KNOWN_TIME) != 0 ? time * 1000L : -1;
|
||||
// }
|
||||
// set {
|
||||
// this.time = (int) (value / 1000L);
|
||||
// this.known |= (ushort)KNOWN_TIME;
|
||||
// }
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Gets/Sets the time of last modification of the entry.
|
||||
// /// </summary>
|
||||
// /// <returns>
|
||||
// /// the time of last modification of the entry, or -1 if unknown.
|
||||
// /// </returns>
|
||||
// public long Time {
|
||||
// get {
|
||||
// return (known & KNOWN_TIME) != 0 ? time * 1000L : -1;
|
||||
// }
|
||||
// set {
|
||||
// this.time = (int) (value / 1000L);
|
||||
// this.known |= (ushort)KNOWN_TIME;
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the size of the uncompressed data.
|
||||
@@ -239,7 +204,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
get {
|
||||
return (known & KNOWN_SIZE) != 0 ? (long)size : -1L;
|
||||
}
|
||||
set {
|
||||
set {
|
||||
if (((ulong)value & 0xFFFFFFFF00000000L) != 0) {
|
||||
throw new ArgumentOutOfRangeException("size");
|
||||
}
|
||||
@@ -284,11 +249,10 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
return (known & KNOWN_CRC) != 0 ? crc & 0xffffffffL : -1L;
|
||||
}
|
||||
set {
|
||||
if (((ulong)crc & 0xffffffff00000000L) != 0)
|
||||
{
|
||||
if (((ulong)crc & 0xffffffff00000000L) != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
this.crc = (uint)value;
|
||||
this.crc = (int)value;
|
||||
this.known |= (ushort)KNOWN_CRC;
|
||||
}
|
||||
}
|
||||
@@ -309,7 +273,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
return method;
|
||||
}
|
||||
set {
|
||||
this.method = value;
|
||||
this.method = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,12 +309,13 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
/* extended time stamp, unix format by Rainer Prem <[email protected]> */
|
||||
int flags = extra[pos];
|
||||
if ((flags & 1) != 0) {
|
||||
int iTime = ((extra[pos+1] & 0xff) |
|
||||
(extra[pos+2] & 0xff) << 8 |
|
||||
(extra[pos+3] & 0xff) << 16 |
|
||||
(extra[pos+4] & 0xff) << 24);
|
||||
int iTime = ((extra[pos+1] & 0xff) |
|
||||
(extra[pos+2] & 0xff) << 8 |
|
||||
(extra[pos+3] & 0xff) << 16 |
|
||||
(extra[pos+4] & 0xff) << 24);
|
||||
|
||||
DateTime = (new DateTime ( 1970, 1, 1, 0, 0, 0 ) + new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime ();
|
||||
cal = (new DateTime ( 1970, 1, 1, 0, 0, 0 ) +
|
||||
new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime ();
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
@@ -377,8 +342,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
return comment;
|
||||
}
|
||||
set {
|
||||
if (value.Length > 0xffff)
|
||||
{
|
||||
if (value.Length > 0xffff) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
this.comment = value;
|
||||
@@ -396,18 +360,6 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
}
|
||||
}
|
||||
|
||||
/// <value>
|
||||
/// True, if the entry is encrypted.
|
||||
/// </value>
|
||||
public bool IsCrypted {
|
||||
get {
|
||||
return isCrypted;
|
||||
}
|
||||
set {
|
||||
isCrypted = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of this zip entry.
|
||||
/// </summary>
|
||||
@@ -424,5 +376,18 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
DateTime CalculateDateTime(int dosTime)
|
||||
{
|
||||
int sec = 2 * (dosTime & 0x1f);
|
||||
int min = (dosTime >> 5) & 0x3f;
|
||||
int hrs = (dosTime >> 11) & 0x1f;
|
||||
int day = (dosTime >> 16) & 0x1f;
|
||||
int mon = ((dosTime >> 21) & 0xf);
|
||||
int year = ((dosTime >> 25) & 0x7f) + 1980; /* since 1900 */
|
||||
|
||||
return new DateTime(year, mon, day, hrs, min, sec);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,7 @@ using System.Text;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
/// <summary>
|
||||
/// This class represents a Zip archive. You can ask for the contained
|
||||
@@ -69,13 +68,13 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
/// static public void Main(string[] args)
|
||||
/// {
|
||||
/// ZipFile zFile = new ZipFile(args[0]);
|
||||
/// //Console.WriteLine("Listing of : " + zFile.Name);
|
||||
/// //Console.WriteLine("");
|
||||
/// //Console.WriteLine("Raw Size Size Date Time Name");
|
||||
/// //Console.WriteLine("-------- -------- -------- ------ ---------");
|
||||
/// Console.WriteLine("Listing of : " + zFile.Name);
|
||||
/// Console.WriteLine("");
|
||||
/// Console.WriteLine("Raw Size Size Date Time Name");
|
||||
/// Console.WriteLine("-------- -------- -------- ------ ---------");
|
||||
/// foreach (ZipEntry e in zFile) {
|
||||
/// DateTime d = e.DateTime;
|
||||
/// //Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize,
|
||||
/// Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize,
|
||||
/// d.ToString("dd-MM-yy"), d.ToString("t"),
|
||||
/// e.Name);
|
||||
/// }
|
||||
@@ -85,7 +84,6 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
public class ZipFile : IEnumerable
|
||||
{
|
||||
string name;
|
||||
string comment;
|
||||
Stream baseStream;
|
||||
ZipEntry[] entries;
|
||||
|
||||
@@ -205,12 +203,6 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
|
||||
int centralOffset = ReadLeInt();
|
||||
|
||||
// GET COMMENT SIZE (COMES AFTER CENTRALOFFSET)
|
||||
int commentSize = ReadLeShort();
|
||||
byte[] zipComment = new byte[commentSize];
|
||||
baseStream.Read(zipComment, 0, zipComment.Length);
|
||||
comment = ZipConstants.ConvertToString(zipComment);
|
||||
|
||||
entries = new ZipEntry[count];
|
||||
baseStream.Seek(centralOffset, SeekOrigin.Begin);
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -250,7 +242,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
entry.Crc = crc & 0xffffffffL;
|
||||
entry.Size = size & 0xffffffffL;
|
||||
entry.CompressedSize = csize & 0xffffffffL;
|
||||
entry.DosTime = (uint)dostime;
|
||||
entry.DosTime = dostime;
|
||||
if (extraLen > 0) {
|
||||
byte[] extra = new byte[extraLen];
|
||||
baseStream.Read(extra, 0, extraLen);
|
||||
@@ -260,8 +252,8 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
baseStream.Read(buffer, 0, commentLen);
|
||||
entry.Comment = ZipConstants.ConvertToString(buffer);
|
||||
}
|
||||
entry.ZipFileIndex = i;
|
||||
entry.Offset = offset;
|
||||
entry.zipFileIndex = i;
|
||||
entry.offset = offset;
|
||||
entries[i] = entry;
|
||||
}
|
||||
}
|
||||
@@ -301,7 +293,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1; // ok
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -338,7 +330,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
long CheckLocalHeader(ZipEntry entry)
|
||||
{
|
||||
lock(baseStream) {
|
||||
baseStream.Seek(entry.Offset, SeekOrigin.Begin);
|
||||
baseStream.Seek(entry.offset, SeekOrigin.Begin);
|
||||
if (ReadLeInt() != ZipConstants.LOCSIG) {
|
||||
throw new ZipException("Wrong Local header signature");
|
||||
}
|
||||
@@ -367,7 +359,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
}
|
||||
|
||||
int extraLen = entry.Name.Length + ReadLeShort();
|
||||
return entry.Offset + ZipConstants.LOCHDR + extraLen;
|
||||
return entry.offset + ZipConstants.LOCHDR + extraLen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +383,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
throw new InvalidOperationException("ZipFile has closed");
|
||||
}
|
||||
|
||||
int index = entry.ZipFileIndex;
|
||||
int index = entry.zipFileIndex;
|
||||
if (index < 0 || index >= entries.Length || entries[index].Name != entry.Name) {
|
||||
index = GetEntryIndex(entry.Name);
|
||||
if (index < 0) {
|
||||
@@ -412,15 +404,6 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The comment for the whole zip file.
|
||||
/// </summary>
|
||||
public string ZipFileComment {
|
||||
get {
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this zip file.
|
||||
/// </summary>
|
||||
@@ -482,8 +465,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
end = start + len;
|
||||
}
|
||||
|
||||
public override int Available
|
||||
{
|
||||
public override int Available {
|
||||
get {
|
||||
long amount = end - filepos;
|
||||
if (amount > Int32.MaxValue) {
|
||||
@@ -497,9 +479,8 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (filepos == end) {
|
||||
return -1; //ok
|
||||
return -1;
|
||||
}
|
||||
|
||||
lock(baseStream) {
|
||||
baseStream.Seek(filepos++, SeekOrigin.Begin);
|
||||
return baseStream.ReadByte();
|
||||
@@ -511,7 +492,7 @@ namespace ICSharpCode.SharpZipLib.Zip
|
||||
if (len > end - filepos) {
|
||||
len = (int) (end - filepos);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
lock(baseStream) {
|
||||
|
||||
Loaded 100 of 2033 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user