mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c055406f44 | ||
|
|
4b541b39b1 | ||
|
|
bf7f10d598 | ||
|
|
b346b5fdd2 | ||
|
|
6dd9ea60dd | ||
|
|
3f625156e6 | ||
|
|
d311a8974f | ||
|
|
a9dc7c1423 | ||
|
|
560e4580b9 | ||
|
|
ddc29a68dc | ||
|
|
b767d8ce93 | ||
|
|
31d3a9249b | ||
|
|
31ce1e8731 | ||
|
|
0ea9548259 | ||
|
|
6966c937a7 | ||
|
|
4ed05be113 | ||
|
|
468605ade8 | ||
|
|
8e85175c9f | ||
|
|
52b617c26d | ||
|
|
33a27d220a | ||
|
|
14fd5a011c | ||
|
|
fbc5540411 | ||
|
|
5c116b3809 | ||
|
|
041074c05c | ||
|
|
2eec15c2c2 | ||
|
|
c036498ee3 | ||
|
|
348cc03c6b | ||
|
|
bf10762927 | ||
|
|
539f93dc9b | ||
|
|
100b11f54e | ||
|
|
9c5054496a | ||
|
|
44e346f730 | ||
|
|
e803963be2 | ||
|
|
00afe48c72 | ||
|
|
20205363c3 | ||
|
|
c5ee2c6e20 | ||
|
|
0462988716 | ||
|
|
9df2d2b132 | ||
|
|
ab9ac534ec | ||
|
|
443a7ccc56 | ||
|
|
bbc196f353 | ||
|
|
f712d57b1d | ||
|
|
2bba2cb921 | ||
|
|
84b44740df | ||
|
|
659bbbf9ed | ||
|
|
2f2dc9b0d1 | ||
|
|
4a36e8f8d3 | ||
|
|
df9f0d3bf7 | ||
|
|
3d8ec43e8e | ||
|
|
d9ac812f0e | ||
|
|
ccf4e0f3ad | ||
|
|
0d0977764d | ||
|
|
b7b4ddd52f | ||
|
|
be04be228d | ||
|
|
095130eca6 | ||
|
|
d18c179d5e | ||
|
|
778d849ef0 | ||
|
|
0a2fccb980 | ||
|
|
12561b45b4 | ||
|
|
4dc959ad28 | ||
|
|
37dc7f44c1 | ||
|
|
d8e15dec91 | ||
|
|
11f4b5566f |
No files matched your search
@@ -1,3 +1,12 @@
|
||||
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.
|
||||
|
||||
+4
-2
@@ -1,7 +1,7 @@
|
||||
AC_INIT(README)
|
||||
AC_CANONICAL_SYSTEM
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,0.92)
|
||||
AM_INIT_AUTOMAKE(mono,0.94)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
dnl
|
||||
@@ -42,6 +42,8 @@ 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"
|
||||
@@ -317,7 +319,7 @@ esac
|
||||
|
||||
|
||||
# tell libgc/configure about what we want
|
||||
ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads CC=$CC"
|
||||
ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
|
||||
|
||||
AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
|
||||
AC_SUBST(LIBGC_CFLAGS)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
dots := $(shell echo $(thisdir) |sed -e 's,[^./][^/]*,..,g')
|
||||
topdir := $(dots)
|
||||
|
||||
VERSION = 0.91.99
|
||||
VERSION = 0.93
|
||||
|
||||
USE_MCS_FLAGS = $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
|
||||
USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
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.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")]
|
||||
// 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")]
|
||||
@@ -35,7 +35,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
namespace ICSharpCode.SharpZipLib.BZip2
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Does all the compress and decompress pre-operation stuff.
|
||||
@@ -46,16 +47,8 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
{
|
||||
public static void Decompress(Stream instream, Stream outstream)
|
||||
{
|
||||
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;
|
||||
}
|
||||
System.IO.Stream bos = outstream;
|
||||
System.IO.Stream bis = instream;
|
||||
BZip2InputStream bzis = new BZip2InputStream(bis);
|
||||
int ch = bzis.ReadByte();
|
||||
while (ch != -1) {
|
||||
@@ -66,13 +59,11 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
}
|
||||
|
||||
public static void Compress(Stream instream, Stream outstream, int blockSize)
|
||||
{
|
||||
BufferedStream bos = new BufferedStream(outstream);
|
||||
bos.WriteByte((byte)'B');
|
||||
bos.WriteByte((byte)'Z');
|
||||
BufferedStream bis = new BufferedStream(instream);
|
||||
{
|
||||
System.IO.Stream bos = outstream;
|
||||
System.IO.Stream bis = instream;
|
||||
int ch = bis.ReadByte();
|
||||
BZip2OutputStream bzos = new BZip2OutputStream(bos);
|
||||
BZip2OutputStream bzos = new BZip2OutputStream(bos, blockSize);
|
||||
while(ch != -1) {
|
||||
bzos.WriteByte((byte)ch);
|
||||
ch = bis.ReadByte();
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
// 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.
|
||||
@@ -41,59 +42,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;
|
||||
|
||||
|
||||
+34
-21
@@ -37,7 +37,8 @@ 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
|
||||
@@ -159,23 +160,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()
|
||||
@@ -209,8 +210,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();
|
||||
@@ -284,7 +285,7 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (streamEnd) {
|
||||
return -1;
|
||||
return -1; // ok
|
||||
}
|
||||
|
||||
int retChar = currentChar;
|
||||
@@ -313,10 +314,14 @@ 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 (magic3 != 'h' || magic4 < '1' || magic4 > '9') {
|
||||
if (magic1 != 'B' || magic2 != 'Z' || magic3 != 'h' || magic4 < '1' || magic4 > '9') {
|
||||
streamEnd = true;
|
||||
return;
|
||||
}
|
||||
@@ -365,7 +370,7 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
CrcError();
|
||||
}
|
||||
|
||||
// 1528150659
|
||||
// 1528150659
|
||||
computedCombinedCRC = ((computedCombinedCRC << 1) & 0xFFFFFFFF) | (computedCombinedCRC >> 31);
|
||||
computedCombinedCRC = computedCombinedCRC ^ (uint)computedBlockCRC;
|
||||
}
|
||||
@@ -382,17 +387,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");
|
||||
}
|
||||
|
||||
|
||||
@@ -518,6 +523,10 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,6 +631,9 @@ 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();
|
||||
@@ -630,10 +642,12 @@ 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;
|
||||
}
|
||||
@@ -643,9 +657,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;
|
||||
@@ -762,7 +776,7 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
void SetupRandPartA()
|
||||
{
|
||||
if(i2 <= last) {
|
||||
if (i2 <= last) {
|
||||
chPrev = ch2;
|
||||
ch2 = ll8[tPos];
|
||||
tPos = tt[tPos];
|
||||
@@ -886,11 +900,10 @@ 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) {
|
||||
|
||||
+80
-50
@@ -37,7 +37,8 @@ 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
|
||||
@@ -152,7 +153,7 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
static void Panic()
|
||||
{
|
||||
Console.WriteLine("panic");
|
||||
//Console.WriteLine("panic");
|
||||
}
|
||||
|
||||
void MakeMaps()
|
||||
@@ -222,7 +223,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;
|
||||
@@ -241,13 +242,15 @@ 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;
|
||||
}
|
||||
@@ -255,7 +258,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;
|
||||
@@ -319,7 +322,7 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
bool blockRandomised;
|
||||
|
||||
// int bytesIn;
|
||||
// int bytesIn;
|
||||
int bytesOut;
|
||||
int bsBuff;
|
||||
int bsLive;
|
||||
@@ -475,14 +478,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();
|
||||
}
|
||||
|
||||
@@ -490,13 +493,16 @@ 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);
|
||||
|
||||
@@ -522,6 +528,10 @@ 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;
|
||||
@@ -609,7 +619,8 @@ 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;
|
||||
@@ -740,7 +751,6 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
totc = 0;
|
||||
gs = 0;
|
||||
while (true) {
|
||||
|
||||
/*--- Set group start & end marks. --*/
|
||||
if (gs >= nMTF) {
|
||||
break;
|
||||
@@ -831,7 +841,6 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
Panic();
|
||||
}
|
||||
|
||||
|
||||
/*--- Compute MTF values for the selectors. ---*/
|
||||
char[] pos = new char[BZip2Constants.N_GROUPS];
|
||||
char ll_i, tmp2, tmp;
|
||||
@@ -1011,35 +1020,40 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1088,8 +1102,9 @@ 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;
|
||||
|
||||
@@ -1110,8 +1125,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -1143,8 +1159,9 @@ 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;
|
||||
@@ -1154,19 +1171,21 @@ 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--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1233,18 +1252,20 @@ 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++) {
|
||||
@@ -1253,8 +1274,9 @@ 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++) {
|
||||
@@ -1292,8 +1314,9 @@ 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;
|
||||
}
|
||||
@@ -1318,7 +1341,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) {
|
||||
@@ -1393,15 +1416,17 @@ 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);
|
||||
@@ -1482,8 +1507,9 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
c1 = block[i1 + 1];
|
||||
c2 = block[i2 + 1];
|
||||
if (c1 != c2)
|
||||
if (c1 != c2) {
|
||||
return c1 > c2;
|
||||
}
|
||||
i1++;
|
||||
i2++;
|
||||
|
||||
@@ -1572,9 +1598,11 @@ 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()
|
||||
{
|
||||
@@ -1636,7 +1664,7 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
j = 0;
|
||||
tmp = yy[j];
|
||||
while ( ll_i != tmp ) {
|
||||
while (ll_i != tmp) {
|
||||
j++;
|
||||
tmp2 = tmp;
|
||||
tmp = yy[j];
|
||||
@@ -1661,11 +1689,12 @@ 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);
|
||||
@@ -1689,8 +1718,9 @@ namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
mtfFreq[BZip2Constants.RUNB]++;
|
||||
break;
|
||||
}
|
||||
if (zPend < 2)
|
||||
if (zPend < 2) {
|
||||
break;
|
||||
}
|
||||
zPend = (zPend - 2) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
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,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
namespace ICSharpCode.SharpZipLib.Checksums
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Computes Adler32 checksum for a stream of data. An Adler32
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
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:
|
||||
@@ -96,7 +97,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,
|
||||
@@ -118,10 +119,15 @@ 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>
|
||||
@@ -134,6 +140,9 @@ namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
get {
|
||||
return (long)crc;
|
||||
}
|
||||
set {
|
||||
crc = (uint)value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
// 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.
|
||||
@@ -49,7 +50,8 @@ namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
/// <summary>
|
||||
/// Returns the data checksum computed so far.
|
||||
/// </summary>
|
||||
long Value {
|
||||
long Value
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,76 +38,77 @@
|
||||
|
||||
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,7 +35,8 @@
|
||||
// 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,7 +42,8 @@ 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.
|
||||
@@ -80,9 +81,6 @@ namespace ICSharpCode.SharpZipLib.GZip {
|
||||
/// </example>
|
||||
public class GZipInputStream : InflaterInputStream
|
||||
{
|
||||
|
||||
//Variables
|
||||
|
||||
/// <summary>
|
||||
/// CRC-32 value for uncompressed data
|
||||
/// </summary>
|
||||
@@ -93,6 +91,9 @@ 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>
|
||||
@@ -165,8 +166,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)) {
|
||||
@@ -246,7 +247,8 @@ 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);
|
||||
@@ -330,8 +332,5 @@ namespace ICSharpCode.SharpZipLib.GZip {
|
||||
*/
|
||||
eos = true;
|
||||
}
|
||||
|
||||
/* Have we read the GZIP header yet? */
|
||||
private bool readGZIPHeader;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,8 @@ 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.
|
||||
@@ -55,7 +56,7 @@ namespace ICSharpCode.SharpZipLib.GZip {
|
||||
/// using System;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using NZlib.GZip;
|
||||
/// using ICSharpCode.SharpZipLib.GZip; // -jr- corrected
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
@@ -103,7 +104,12 @@ namespace ICSharpCode.SharpZipLib.GZip {
|
||||
/// </param>
|
||||
public GZipOutputStream(Stream baseOutputStream, int size) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size)
|
||||
{
|
||||
// TODO : find out correctness, orgininally this was : (int) (System.currentTimeMillis() / 1000L);
|
||||
WriteHeader();
|
||||
// System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )");
|
||||
}
|
||||
|
||||
void WriteHeader()
|
||||
{
|
||||
int mod_time = (int)(DateTime.Now.Ticks / 10000L); // Ticks give back 100ns intervals
|
||||
byte[] gzipHeader = {
|
||||
/* The two magic bytes */
|
||||
@@ -125,9 +131,7 @@ 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)
|
||||
@@ -162,7 +166,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 @@
|
||||
// BZip2OutputStream.cs
|
||||
// InvalidHeaderException.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, string message);
|
||||
public delegate void ProgressMessageHandler(TarArchive archive, TarEntry entry, 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 record. Directory entries
|
||||
/// consist only of the header record, and are followed by entries
|
||||
/// the archive consists of a header block. Directory entries
|
||||
/// consist only of the header block, and are followed by entries
|
||||
/// for the directory's contents. File entries consist of a
|
||||
/// header record followed by the number of records needed to
|
||||
/// header followed by the number of blocks needed to
|
||||
/// contain the file's contents. All entries are written on
|
||||
/// record boundaries. Records are 512 bytes long.
|
||||
/// block boundaries. Blocks 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
|
||||
{
|
||||
protected bool verbose;
|
||||
protected bool debug;
|
||||
protected bool keepOldFiles;
|
||||
protected bool asciiTranslate;
|
||||
bool verbose;
|
||||
bool debug;
|
||||
bool keepOldFiles;
|
||||
bool asciiTranslate;
|
||||
|
||||
protected int userId;
|
||||
protected string userName;
|
||||
protected int groupId;
|
||||
protected string groupName;
|
||||
int userId;
|
||||
string userName;
|
||||
int groupId;
|
||||
string groupName;
|
||||
|
||||
protected string rootPath;
|
||||
protected string pathPrefix;
|
||||
string rootPath;
|
||||
string pathPrefix;
|
||||
|
||||
protected int recordSize;
|
||||
protected byte[] recordBuf;
|
||||
int recordSize;
|
||||
byte[] recordBuf;
|
||||
|
||||
protected TarInputStream tarIn;
|
||||
protected TarOutputStream tarOut;
|
||||
TarInputStream tarIn;
|
||||
TarOutputStream tarOut;
|
||||
|
||||
public event ProgressMessageHandler ProgressMessageEvent;
|
||||
|
||||
protected virtual void OnProgressMessageEvent(string message)
|
||||
protected virtual void OnProgressMessageEvent(TarEntry entry, string message)
|
||||
{
|
||||
if (ProgressMessageEvent != null) {
|
||||
ProgressMessageEvent(this, message);
|
||||
ProgressMessageEvent(this, entry, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,19 +103,14 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream)
|
||||
{
|
||||
return CreateInputTarArchive(inputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
return CreateInputTarArchive(inputStream, TarBuffer.DefaultBlockFactor);
|
||||
}
|
||||
|
||||
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)
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream, int blockFactor)
|
||||
{
|
||||
TarArchive archive = new TarArchive();
|
||||
archive.tarIn = new TarInputStream(inputStream, blockSize, recordSize);
|
||||
archive.Initialize(recordSize);
|
||||
archive.tarIn = new TarInputStream(inputStream, blockFactor);
|
||||
archive.Initialize(blockFactor * TarBuffer.BlockSize);
|
||||
return archive;
|
||||
}
|
||||
|
||||
@@ -126,28 +121,23 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream)
|
||||
{
|
||||
return CreateOutputTarArchive(outputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
return CreateOutputTarArchive(outputStream, TarBuffer.DefaultBlockFactor);
|
||||
}
|
||||
|
||||
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)
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockFactor)
|
||||
{
|
||||
TarArchive archive = new TarArchive();
|
||||
archive.tarOut = new TarOutputStream(outputStream, blockSize, recordSize);
|
||||
archive.Initialize(recordSize);
|
||||
archive.tarOut = new TarOutputStream(outputStream, blockFactor);
|
||||
archive.Initialize(blockFactor * TarBuffer.BlockSize);
|
||||
return archive;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Common constructor initialization code.
|
||||
/// </summary>
|
||||
void Initialize(int recordSize)
|
||||
{
|
||||
this.recordSize = recordSize;
|
||||
this.rootPath = null;
|
||||
this.pathPrefix = null;
|
||||
|
||||
@@ -165,11 +155,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
this.recordBuf = new byte[RecordSize];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the debugging flag.
|
||||
*
|
||||
* @param debugF The new debug setting.
|
||||
*/
|
||||
///
|
||||
/// <summary> Set the debugging flag. </summary>
|
||||
///
|
||||
/// <param name=debugF> The new debug setting. </param>
|
||||
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugF;
|
||||
@@ -206,7 +196,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the ascii file translation flag. If ascii file translatio
|
||||
/// Set the ascii file translation flag. If ascii file translation
|
||||
/// 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
|
||||
@@ -214,8 +204,7 @@ 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, and since most tar implementations
|
||||
/// text files compatible with UNIX, and since most tar implementations
|
||||
/// text files compatible with UNIX.
|
||||
/// </summary>
|
||||
/// <param name= "asciiTranslate">
|
||||
/// If true, translate ascii text files.
|
||||
@@ -225,7 +214,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.
|
||||
@@ -236,7 +225,8 @@ 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
|
||||
@@ -315,11 +305,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 BLOCKS of
|
||||
/// RECORDS. This allowed tar to match the IO characteristics of
|
||||
/// supports the concept of buffered IO consisting of RECORDS of
|
||||
/// BLOCKS. 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 propertly "blocked". Thus, all of the horrible TarBuffer
|
||||
/// to be properly "blocked". Thus, all of the horrible TarBuffer
|
||||
/// support boils down to simply getting the "boundaries" correct.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
@@ -329,10 +319,11 @@ 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.DEFAULT_RCDSIZE;
|
||||
return TarBuffer.DefaultRecordSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +335,8 @@ 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();
|
||||
}
|
||||
@@ -364,11 +356,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
if (entry == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ EOF RECORD");
|
||||
Console.Error.WriteLine("READ EOF BLOCK");
|
||||
}
|
||||
break;
|
||||
}
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
OnProgressMessageEvent(entry, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +377,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
if (entry == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ EOF RECORD");
|
||||
Console.Error.WriteLine("READ EOF BLOCK");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -399,20 +391,22 @@ 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);
|
||||
|
||||
byte[] content = new byte[fs.Length];
|
||||
int sampleSize = System.Math.Min(4096, (int)fs.Length);
|
||||
byte[] content = new byte[sampleSize];
|
||||
|
||||
fs.Read(content, 0, (int)fs.Length);
|
||||
fs.Read(content, 0, sampleSize);
|
||||
fs.Close();
|
||||
|
||||
// assume that ascii 0 or
|
||||
@@ -440,7 +434,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
void ExtractEntry(string destDir, TarEntry entry)
|
||||
{
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
OnProgressMessageEvent(entry, null);
|
||||
}
|
||||
|
||||
string name = entry.Name;
|
||||
@@ -454,15 +448,17 @@ 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("not overwriting " + entry.Name);
|
||||
OnProgressMessageEvent(entry, "Destination file already exists");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bool asciiTrans = false;
|
||||
Stream outputStream = File.Create(destFile);
|
||||
if (this.asciiTranslate) {
|
||||
@@ -512,14 +508,16 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
off = b + 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
outputStream.Write(rdbuf, 0, numRead);
|
||||
}
|
||||
}
|
||||
|
||||
if (asciiTrans) {
|
||||
outw.Close();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
outputStream.Close();
|
||||
}
|
||||
}
|
||||
@@ -551,7 +549,8 @@ 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
|
||||
@@ -564,11 +563,12 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
OnProgressMessageEvent(entry, null);
|
||||
}
|
||||
|
||||
if (this.asciiTranslate && !entry.IsDirectory) {
|
||||
asciiTrans = !IsBinary(eFile);
|
||||
|
||||
// original java source :
|
||||
// MimeType mime = null;
|
||||
// string contentType = null;
|
||||
@@ -616,6 +616,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
inStream.Close();
|
||||
|
||||
outStream.Flush();
|
||||
outStream.Close();
|
||||
|
||||
@@ -650,7 +651,8 @@ 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];
|
||||
@@ -664,7 +666,8 @@ 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,14 +36,15 @@ 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 "block"
|
||||
/// performs is to ensure that files have the correct "record"
|
||||
/// size, or other tars will complain.
|
||||
/// <p>
|
||||
/// You should never have a need to access this class directly.
|
||||
@@ -52,20 +53,68 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public class TarBuffer
|
||||
{
|
||||
public static readonly int DEFAULT_RCDSIZE = 512;
|
||||
public static readonly int DEFAULT_BLKSIZE = DEFAULT_RCDSIZE * 20;
|
||||
|
||||
/* 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;
|
||||
|
||||
Stream inputStream;
|
||||
Stream outputStream;
|
||||
|
||||
byte[] blockBuffer;
|
||||
int currBlkIdx;
|
||||
int currRecIdx;
|
||||
int blockSize;
|
||||
int recordSize;
|
||||
int recsPerBlock;
|
||||
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;
|
||||
}
|
||||
|
||||
bool debug;
|
||||
|
||||
protected TarBuffer()
|
||||
{
|
||||
@@ -73,36 +122,30 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream)
|
||||
{
|
||||
return CreateInputTarBuffer(inputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
return CreateInputTarBuffer(inputStream, TarBuffer.DefaultBlockFactor);
|
||||
}
|
||||
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)
|
||||
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockFactor)
|
||||
{
|
||||
TarBuffer tarBuffer = new TarBuffer();
|
||||
tarBuffer.inputStream = inputStream;
|
||||
tarBuffer.outputStream = null;
|
||||
tarBuffer.Initialize(blockSize, recordSize);
|
||||
tarBuffer.Initialize(blockFactor);
|
||||
|
||||
return tarBuffer;
|
||||
}
|
||||
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream)
|
||||
{
|
||||
return CreateOutputTarBuffer(outputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
return CreateOutputTarBuffer(outputStream, TarBuffer.DefaultBlockFactor);
|
||||
}
|
||||
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)
|
||||
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockFactor)
|
||||
{
|
||||
TarBuffer tarBuffer = new TarBuffer();
|
||||
tarBuffer.inputStream = null;
|
||||
tarBuffer.outputStream = outputStream;
|
||||
tarBuffer.Initialize(blockSize, recordSize);
|
||||
tarBuffer.Initialize(blockFactor);
|
||||
|
||||
return tarBuffer;
|
||||
}
|
||||
@@ -110,29 +153,32 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <summary>
|
||||
/// Initialization common to all constructors.
|
||||
/// </summary>
|
||||
void Initialize(int blockSize, int recordSize)
|
||||
void Initialize(int blockFactor)
|
||||
{
|
||||
this.debug = false;
|
||||
this.blockSize = blockSize;
|
||||
this.recordSize = recordSize;
|
||||
this.recsPerBlock = this.blockSize / this.recordSize;
|
||||
this.blockBuffer = new byte[this.blockSize];
|
||||
this.blockFactor = blockFactor;
|
||||
this.recordSize = blockFactor * BlockSize;
|
||||
|
||||
this.recordBuffer = new byte[RecordSize];
|
||||
|
||||
if (inputStream != null) {
|
||||
this.currBlkIdx = -1;
|
||||
this.currRecIdx = this.recsPerBlock;
|
||||
} else {
|
||||
this.currBlkIdx = 0;
|
||||
this.currRecIdx = 0;
|
||||
if (inputStream != null)
|
||||
{
|
||||
this.currentRecordIndex = -1;
|
||||
this.currentBlockIndex = BlockFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentRecordIndex = 0;
|
||||
this.currentBlockIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the TAR Buffer's block size. Blocks consist of multiple records.
|
||||
/// Get the TAR Buffer's block factor
|
||||
/// </summary>
|
||||
public int GetBlockSize()
|
||||
public int GetBlockFactor()
|
||||
{
|
||||
return this.blockSize;
|
||||
return this.blockFactor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,24 +190,21 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the debugging flag for the buffer.
|
||||
/// 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
|
||||
/// </summary>
|
||||
public void SetDebug(bool debug)
|
||||
{
|
||||
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 name = "block">
|
||||
/// The block data to check.
|
||||
/// </param>
|
||||
public bool IsEOFRecord(byte[] record)
|
||||
public bool IsEOFBlock(byte[] block)
|
||||
{
|
||||
for (int i = 0, sz = this.GetRecordSize(); i < sz; ++i) {
|
||||
if (record[i] != 0) {
|
||||
for (int i = 0, sz = BlockSize; i < sz; ++i)
|
||||
{
|
||||
if (block[i] != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -170,156 +213,175 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skip over a record on the input stream.
|
||||
/// Skip over a block on the input stream.
|
||||
/// </summary>
|
||||
public void SkipRecord()
|
||||
public void SkipBlock()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("SkipRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("SkipBlock: recIdx = " + this.currentRecordIndex + " blkIdx = " + this.currentBlockIndex);
|
||||
}
|
||||
|
||||
if (this.inputStream == null) {
|
||||
if (this.inputStream == null)
|
||||
{
|
||||
throw new System.IO.IOException("no input stream defined");
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
if (!this.ReadBlock()) {
|
||||
if (this.currentBlockIndex >= this.BlockFactor)
|
||||
{
|
||||
if (!this.ReadRecord())
|
||||
{
|
||||
return; // UNDONE
|
||||
}
|
||||
}
|
||||
|
||||
this.currRecIdx++;
|
||||
this.currentBlockIndex++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a record from the input stream and return the data.
|
||||
/// Read a block from the input stream and return the data.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The record data.
|
||||
/// The block data.
|
||||
/// </returns>
|
||||
public byte[] ReadRecord()
|
||||
public byte[] ReadBlock()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine( "ReadRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine( "ReadBlock: blockIndex = " + this.currentBlockIndex + " recordIndex = " + this.currentRecordIndex );
|
||||
}
|
||||
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream defined");
|
||||
if (this.inputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.ReadBlock - no input stream defined");
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
if (!this.ReadBlock()) {
|
||||
if (this.currentBlockIndex >= this.BlockFactor)
|
||||
{
|
||||
if (!this.ReadRecord())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] result = new byte[this.recordSize];
|
||||
byte[] result = new byte[BlockSize];
|
||||
|
||||
Array.Copy(this.blockBuffer, (this.currRecIdx * this.recordSize), result, 0, this.recordSize );
|
||||
this.currRecIdx++;
|
||||
Array.Copy(this.recordBuffer, (this.currentBlockIndex * BlockSize), result, 0, BlockSize );
|
||||
this.currentBlockIndex++;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <returns>
|
||||
/// false if End-Of-File, else true
|
||||
/// </returns>
|
||||
bool ReadBlock()
|
||||
bool ReadRecord()
|
||||
{
|
||||
Console.WriteLine(this.debug);
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("ReadBlock: blkIdx = " + this.currBlkIdx);
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("ReadRecord: recordIndex = " + this.currentRecordIndex);
|
||||
}
|
||||
|
||||
if (this.inputStream == null) {
|
||||
if (this.inputStream == null)
|
||||
{
|
||||
throw new System.IO.IOException("no input stream stream defined");
|
||||
}
|
||||
|
||||
this.currRecIdx = 0;
|
||||
this.currentBlockIndex = 0;
|
||||
|
||||
int offset = 0;
|
||||
int bytesNeeded = this.blockSize;
|
||||
for (; bytesNeeded > 0 ;) {
|
||||
long numBytes = this.inputStream.Read(this.blockBuffer, offset, bytesNeeded);
|
||||
int bytesNeeded = RecordSize;
|
||||
|
||||
while (bytesNeeded > 0)
|
||||
{
|
||||
long numBytes = this.inputStream.Read(this.recordBuffer, offset, bytesNeeded);
|
||||
|
||||
//
|
||||
// NOTE
|
||||
// We have fit EOF, and the block is not full!
|
||||
// We have found EOF, and the record 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 block were read. This does
|
||||
// and continue as if the entire record 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 != this.blockSize) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("ReadBlock: INCOMPLETE READ " + numBytes + " of " + this.blockSize + " bytes read.");
|
||||
if (numBytes != RecordSize)
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("ReadRecord: INCOMPLETE READ " + numBytes + " of " + this.blockSize + " bytes read.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.currBlkIdx++;
|
||||
this.currentRecordIndex++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current block number, zero based.
|
||||
/// Get the current block number, within the current record, zero based.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current zero based block number.
|
||||
/// </returns>
|
||||
public int GetCurrentBlockNum()
|
||||
{
|
||||
return this.currBlkIdx;
|
||||
return this.currentBlockIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current record number, within the current block, zero based.
|
||||
/// Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum.
|
||||
/// Get the current record number
|
||||
/// Absolute block number in file = (currentRecordNum * block factor) + currentBlockNum.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current zero based record number.
|
||||
/// </returns>
|
||||
public int GetCurrentRecordNum()
|
||||
{
|
||||
return this.currRecIdx - 1;
|
||||
return this.currentRecordIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an archive record to the archive.
|
||||
/// Write an archive block to the archive.
|
||||
/// </summary>
|
||||
/// <param name="record">
|
||||
/// The record data to write to the archive.
|
||||
/// <param name="block">
|
||||
/// The data to write to the archive.
|
||||
/// </param>
|
||||
///
|
||||
public void WriteRecord(byte[] record)
|
||||
public void WriteBlock(byte[] block)
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("WriteRecord: recIdx = " + this.currentRecordIndex + " blkIdx = " + this.currentBlockIndex );
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream defined");
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - no output stream defined");
|
||||
}
|
||||
|
||||
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 (block.Length != BlockSize)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - block to write has length '" + block.Length + "' which is not the block size of '" + BlockSize + "'" );
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.WriteBlock();
|
||||
if (this.currentBlockIndex >= BlockFactor)
|
||||
{
|
||||
this.WriteRecord();
|
||||
}
|
||||
Array.Copy(record, 0, this.blockBuffer, (this.currRecIdx * this.recordSize), this.recordSize );
|
||||
this.currRecIdx++;
|
||||
|
||||
Array.Copy(block, 0, this.recordBuffer, (this.currentBlockIndex * BlockSize), BlockSize);
|
||||
this.currentBlockIndex++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -333,47 +395,53 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <param name="offset">
|
||||
/// The offset of the record data within buf.
|
||||
/// </param>
|
||||
public void WriteRecord(byte[] buf, int offset)
|
||||
public void WriteBlock(byte[] buf, int offset)
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("WriteBlock: recIdx = " + this.currentRecordIndex + " blkIdx = " + this.currentBlockIndex );
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream stream defined");
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteBlock - no output stream stream defined");
|
||||
}
|
||||
|
||||
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 ((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 (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.WriteBlock();
|
||||
if (this.currentBlockIndex >= this.BlockFactor)
|
||||
{
|
||||
this.WriteRecord();
|
||||
}
|
||||
|
||||
Array.Copy(buf, offset, this.blockBuffer, (this.currRecIdx * this.recordSize), this.recordSize );
|
||||
Array.Copy(buf, offset, this.recordBuffer, (this.currentBlockIndex * BlockSize), BlockSize);
|
||||
|
||||
this.currRecIdx++;
|
||||
this.currentBlockIndex++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a TarBuffer block to the archive.
|
||||
/// Write a TarBuffer record to the archive.
|
||||
/// </summary>
|
||||
void WriteBlock()
|
||||
void WriteRecord()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteBlock: blkIdx = " + this.currBlkIdx);
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("Writerecord: record index = " + this.currentRecordIndex);
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream defined");
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.WriteRecord no output stream defined");
|
||||
}
|
||||
|
||||
this.outputStream.Write(this.blockBuffer, 0, this.blockSize);
|
||||
this.outputStream.Write(this.recordBuffer, 0, RecordSize);
|
||||
this.outputStream.Flush();
|
||||
|
||||
this.currRecIdx = 0;
|
||||
this.currBlkIdx++;
|
||||
this.currentBlockIndex = 0;
|
||||
this.currentRecordIndex++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -381,16 +449,19 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
void Flush()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarBuffer.FlushBlock() called.");
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("TarBuffer.FlushBlock() called.");
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output base stream defined");
|
||||
if (this.outputStream == null)
|
||||
{
|
||||
throw new ApplicationException("TarBuffer.Flush no output stream defined");
|
||||
}
|
||||
|
||||
if (this.currRecIdx > 0) {
|
||||
this.WriteBlock();
|
||||
if (this.currentBlockIndex > 0)
|
||||
{
|
||||
this.WriteRecord();
|
||||
}
|
||||
outputStream.Flush();
|
||||
}
|
||||
@@ -401,25 +472,27 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarBuffer.Close().");
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.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) {
|
||||
// if (this.inStream != System.in ) {
|
||||
}
|
||||
else if (inputStream != null)
|
||||
{
|
||||
inputStream.Close();
|
||||
inputStream = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
|
||||
@@ -36,7 +36,8 @@ 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
|
||||
@@ -64,27 +65,6 @@ 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
|
||||
@@ -92,12 +72,12 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <summary>
|
||||
/// If this entry represents a File, this references it.
|
||||
/// </summary>
|
||||
protected string file;
|
||||
string file;
|
||||
|
||||
/// <summary>
|
||||
/// This is the entry's header information.
|
||||
/// </summary>
|
||||
protected TarHeader header;
|
||||
TarHeader header;
|
||||
|
||||
/// <summary>
|
||||
/// Only Create Entries with the static CreateXYZ methods or a headerBuffer.
|
||||
@@ -116,10 +96,15 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
public TarEntry(byte[] headerBuf)
|
||||
{
|
||||
this.Initialize();
|
||||
this.ParseTarHeader(this.header, headerBuf);
|
||||
this.header.ParseBuffer(headerBuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TarEntry(TarHeader header)
|
||||
{
|
||||
file = null;
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct an entry with only a name. This allows the programmer
|
||||
@@ -149,7 +134,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialization code common to all constructors.
|
||||
/// Initialization code common to all pseudo constructors.
|
||||
/// </summary>
|
||||
void Initialize()
|
||||
{
|
||||
@@ -166,7 +151,8 @@ 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());
|
||||
@@ -203,8 +189,10 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <returns>
|
||||
/// This entry's TarHeader.
|
||||
/// </returns>
|
||||
public TarHeader TarHeader {
|
||||
get {
|
||||
public TarHeader TarHeader
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.header;
|
||||
}
|
||||
}
|
||||
@@ -212,11 +200,14 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -224,11 +215,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -236,11 +230,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -248,11 +245,14 @@ 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,11 +260,14 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -299,17 +302,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
|
||||
/**
|
||||
@@ -317,11 +320,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -332,8 +338,10 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <returns>
|
||||
/// This entry's file.
|
||||
/// </returns>
|
||||
public string File {
|
||||
get {
|
||||
public string File
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.file;
|
||||
}
|
||||
}
|
||||
@@ -341,11 +349,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -374,13 +385,17 @@ 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.linkFlag == TarHeader.LF_DIR || this.header.name.ToString().EndsWith( "/" )) {
|
||||
if (this.header != null)
|
||||
{
|
||||
if (this.header.typeFlag == TarHeader.LF_DIR || this.header.name.ToString().EndsWith( "/" ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -400,50 +415,61 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
public void GetFileTarHeader(TarHeader hdr, string file)
|
||||
{
|
||||
this.file = file;
|
||||
|
||||
string name = Path.GetDirectoryName(file);
|
||||
|
||||
if (Path.DirectorySeparatorChar == '\\') { // check if the OS is a windows
|
||||
|
||||
// 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
|
||||
// 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, '/');
|
||||
|
||||
name = name.Replace(Path.DirectorySeparatorChar, '/').ToLower();
|
||||
|
||||
// No absolute pathnames
|
||||
// Windows (and Posix?) paths can start with "\\NetworkDrive\",
|
||||
// Windows (and Posix?) paths can start with UNC style "\\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 = 040755; // TODO : what does this magic number ?? Mike
|
||||
hdr.linkFlag = TarHeader.LF_DIR;
|
||||
if (hdr.name[hdr.name.Length - 1] != '/') {
|
||||
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.name.Append("/");
|
||||
}
|
||||
|
||||
hdr.size = 0;
|
||||
} else {
|
||||
hdr.mode = 0100644; // TODO : again a magic number
|
||||
hdr.linkFlag = TarHeader.LF_NORMAL;
|
||||
Console.WriteLine(file.Replace('/', Path.DirectorySeparatorChar));
|
||||
hdr.mode = 33216; // 0100700 -jr- // 0100644; // Magic number for security access for a UNIX filesystem
|
||||
hdr.typeFlag = TarHeader.LF_NORMAL;
|
||||
hdr.size = new FileInfo(file.Replace('/', Path.DirectorySeparatorChar)).Length;
|
||||
}
|
||||
|
||||
// UNDONE When File lets us get the userName, use it!
|
||||
hdr.modTime = System.IO.File.GetLastAccessTime(file.Replace('/', Path.DirectorySeparatorChar));
|
||||
hdr.checkSum = 0;
|
||||
hdr.modTime = System.IO.File.GetLastWriteTimeUtc(file.Replace('/', Path.DirectorySeparatorChar)); // -jr- Unix times are in UTC
|
||||
hdr.checkSum = 0;
|
||||
hdr.devMajor = 0;
|
||||
hdr.devMinor = 0;
|
||||
}
|
||||
@@ -457,44 +483,23 @@ 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];
|
||||
|
||||
string dirName = file;
|
||||
if (!dirName.EndsWith(Path.DirectorySeparatorChar.ToString())) {
|
||||
dirName += Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.Length; ++i) {
|
||||
|
||||
for (int i = 0; i < list.Length; ++i)
|
||||
{
|
||||
result[i] = TarEntry.CreateEntryFromFile(list[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <summary>
|
||||
/// Write an entry's header information to a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "outbuf">
|
||||
@@ -502,120 +507,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </param>
|
||||
public void WriteEntryHeader(byte[] 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);
|
||||
this.header.WriteHeader(outbuf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -629,22 +521,22 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </param>
|
||||
public void NameTarHeader(TarHeader hdr, string name)
|
||||
{
|
||||
bool isDir = name.EndsWith("/");
|
||||
bool isDir = name.EndsWith("/"); // -jr- this is true for BSD tar but not all others I think?
|
||||
|
||||
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.userId = 0;
|
||||
// hdr.mode = isDir ? 040755 : 0100644; // TODO : I think I've seen these magics before ...
|
||||
hdr.mode = isDir ? 1003 : 33216;
|
||||
hdr.userId = 0;
|
||||
hdr.groupId = 0;
|
||||
hdr.size = 0;
|
||||
hdr.checkSum = 0;
|
||||
|
||||
hdr.modTime = DateTime.Now;//(new java.util.Date()).getTime() / 1000;
|
||||
hdr.modTime = DateTime.UtcNow; // -jr- 24-Jan-2004 Unix times are in utc!
|
||||
// hdr.modTime = DateTime.Now; // (new java.util.Date()).getTime() / 1000;
|
||||
|
||||
hdr.linkFlag = isDir ? TarHeader.LF_DIR : TarHeader.LF_NORMAL;
|
||||
hdr.typeFlag = isDir ? TarHeader.LF_DIR : TarHeader.LF_NORMAL;
|
||||
|
||||
hdr.linkName = new StringBuilder(String.Empty);
|
||||
hdr.userName = new StringBuilder(String.Empty);
|
||||
@@ -655,6 +547,9 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// TarHeader.cs
|
||||
//
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
@@ -32,10 +33,41 @@
|
||||
// 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>
|
||||
@@ -77,8 +109,13 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <summary>
|
||||
/// The length of the magic field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int MAGICLEN = 8;
|
||||
public readonly static int MAGICLEN = 6;
|
||||
|
||||
/// <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>
|
||||
@@ -100,58 +137,109 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
public readonly static int DEVLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// LF_ constants represents the "type" of an entry
|
||||
/// </summary>
|
||||
public readonly static byte LF_OLDNORM = 0;
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// This is the "old way" of indicating a normal file.
|
||||
/// </summary>
|
||||
public const byte LF_OLDNORM = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Normal file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_NORMAL = (byte) '0';
|
||||
public const byte LF_NORMAL = (byte) '0';
|
||||
|
||||
/// <summary>
|
||||
/// Link file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_LINK = (byte) '1';
|
||||
public const byte LF_LINK = (byte) '1';
|
||||
|
||||
/// <summary>
|
||||
/// Symbolic link file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_SYMLINK = (byte) '2';
|
||||
public const byte LF_SYMLINK = (byte) '2';
|
||||
|
||||
/// <summary>
|
||||
/// Character device file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_CHR = (byte) '3';
|
||||
public const byte LF_CHR = (byte) '3';
|
||||
|
||||
/// <summary>
|
||||
/// Block device file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_BLK = (byte) '4';
|
||||
public const byte LF_BLK = (byte) '4';
|
||||
|
||||
/// <summary>
|
||||
/// Directory file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_DIR = (byte) '5';
|
||||
public const byte LF_DIR = (byte) '5';
|
||||
|
||||
/// <summary>
|
||||
/// FIFO (pipe) file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_FIFO = (byte) '6';
|
||||
public const byte LF_FIFO = (byte) '6';
|
||||
|
||||
/// <summary>
|
||||
/// Contiguous file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_CONTIG = (byte) '7';
|
||||
public const byte LF_CONTIG = (byte) '7';
|
||||
|
||||
/// <summary>
|
||||
/// The magic tag representing a POSIX tar archive.
|
||||
/// Posix.1 2001 global extended header
|
||||
/// </summary>
|
||||
public readonly static string TMAGIC = "ustar";
|
||||
///
|
||||
public const byte LF_GHDR = (byte) 'g';
|
||||
|
||||
/// <summary>
|
||||
/// The magic tag representing a GNU tar archive.
|
||||
/// 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
|
||||
/// </summary>
|
||||
public readonly static string GNU_TMAGIC = "ustar ";
|
||||
|
||||
@@ -191,9 +279,9 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
public int checkSum;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's link flag.
|
||||
/// The entry's type flag.
|
||||
/// </summary>
|
||||
public byte linkFlag;
|
||||
public byte typeFlag;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's link name.
|
||||
@@ -205,6 +293,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public StringBuilder magic;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's version.
|
||||
/// </summary>
|
||||
public StringBuilder version;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's user name.
|
||||
/// </summary>
|
||||
@@ -228,20 +321,27 @@ 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 = 0;
|
||||
this.groupId = 0;
|
||||
this.userId = 1003; // -jr- was 0
|
||||
this.groupId = 513; // -jr- was 0
|
||||
this.userName = new StringBuilder(user);
|
||||
this.groupName = new StringBuilder(String.Empty);
|
||||
// -jr-
|
||||
// this.groupName = new StringBuilder(String.Empty);
|
||||
// this.groupName = new StringBuilder("Everyone"); Attempt2
|
||||
this.groupName = new StringBuilder("None"); // Gnu compatible
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -258,9 +358,10 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
hdr.size = this.size;
|
||||
hdr.modTime = this.modTime;
|
||||
hdr.checkSum = this.checkSum;
|
||||
hdr.linkFlag = this.linkFlag;
|
||||
hdr.typeFlag = this.typeFlag;
|
||||
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;
|
||||
@@ -302,17 +403,22 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -344,8 +450,10 @@ 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]);
|
||||
@@ -354,7 +462,24 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
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>
|
||||
/// Determine the number of bytes in an entry name.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
@@ -373,17 +498,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </returns>
|
||||
public static int GetNameBytes(StringBuilder name, byte[] buf, int offset, int 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;
|
||||
return GetNameBytes(name, 0, buf, offset, length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -405,27 +520,26 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </returns>
|
||||
public static int GetOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
byte[] result = new byte[length];
|
||||
|
||||
// TODO check for values too large...
|
||||
|
||||
int idx = length - 1;
|
||||
|
||||
|
||||
// Either a space or null is valid here. We use NULL as per GNUTar
|
||||
buf[offset + idx] = 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) {
|
||||
|
||||
if (val > 0)
|
||||
{
|
||||
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)' ';
|
||||
for (; idx >= 0; --idx)
|
||||
{
|
||||
buf[offset + idx] = (byte)'0';
|
||||
}
|
||||
|
||||
return offset + length;
|
||||
@@ -450,37 +564,176 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </returns>
|
||||
public static int GetLongOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
byte[] temp = new byte[length + 1];
|
||||
TarHeader.GetOctalBytes(val, temp, 0, length + 1);
|
||||
Array.Copy(temp, 0, buf, offset, length);
|
||||
return offset + length;
|
||||
return GetOctalBytes(val, buf, offset, length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse the checksum octal integer from a header buffer.
|
||||
/// Add the checksum octal integer to header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "val">
|
||||
/// </param>
|
||||
/// <param name = "buf">
|
||||
/// The header buffer from which to parse.
|
||||
/// The header buffer to set the checksum for
|
||||
/// </param>
|
||||
/// <param name = "offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// The offset into the buffer for the checksum
|
||||
/// </param>
|
||||
/// <param name = "length">
|
||||
/// The number of header bytes to parse.
|
||||
/// 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
|
||||
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The integer value of the entry's checksum.
|
||||
/// The modified buffer offset
|
||||
/// </returns>
|
||||
public static int GetCheckSumOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
private static int GetCheckSumOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
TarHeader.GetOctalBytes(val, buf, offset, length);
|
||||
buf[offset + length - 1] = (byte)' ';
|
||||
buf[offset + length - 2] = 0;
|
||||
TarHeader.GetOctalBytes(val, buf, offset, length - 1);
|
||||
// buf[offset + length - 1] = (byte)' '; -jr- 23-Jan-2004 this causes failure!!!
|
||||
// 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,7 +36,8 @@ 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.
|
||||
@@ -59,11 +60,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -71,8 +75,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
public override bool CanSeek
|
||||
{
|
||||
// TODO is this valid? should it return false?
|
||||
get
|
||||
{
|
||||
return inputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
@@ -80,8 +87,10 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -89,8 +98,10 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -98,11 +109,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -120,6 +134,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
// TODO allow this?
|
||||
return inputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
@@ -148,30 +163,27 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
}
|
||||
|
||||
|
||||
public TarInputStream(Stream inputStream) : this(inputStream, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE)
|
||||
public TarInputStream(Stream inputStream) : this(inputStream, TarBuffer.DefaultBlockFactor)
|
||||
{
|
||||
}
|
||||
|
||||
public TarInputStream(Stream inputStream, int blockSize) : this(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarInputStream(Stream inputStream, int blockSize, int recordSize)
|
||||
public TarInputStream(Stream inputStream, int blockFactor)
|
||||
{
|
||||
this.inputStream = inputStream;
|
||||
this.buffer = TarBuffer.CreateInputTarBuffer(inputStream, blockSize, recordSize);
|
||||
this.buffer = TarBuffer.CreateInputTarBuffer(inputStream, blockFactor);
|
||||
|
||||
this.readBuf = null;
|
||||
this.readBuf = null;
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.eFactory = null;
|
||||
}
|
||||
|
||||
public void SetDebug(bool debugF)
|
||||
public void SetDebug(bool debugFlag)
|
||||
{
|
||||
this.debug = debugF;
|
||||
SetBufferDebug(debugF);
|
||||
this.debug = debugFlag;
|
||||
SetBufferDebug(debugFlag);
|
||||
}
|
||||
|
||||
public void SetBufferDebug(bool debug)
|
||||
{
|
||||
this.buffer.SetDebug(debug);
|
||||
@@ -214,8 +226,10 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -231,16 +245,18 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </param>
|
||||
public void Skip(int numToSkip)
|
||||
{
|
||||
// REVIEW
|
||||
// TODO 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;
|
||||
}
|
||||
|
||||
@@ -251,8 +267,10 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +291,24 @@ 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
|
||||
@@ -289,68 +324,144 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </returns>
|
||||
public TarEntry GetNextEntry()
|
||||
{
|
||||
if (this.hasHitEOF) {
|
||||
if (this.hasHitEOF)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
if (this.currEntry != null)
|
||||
{
|
||||
SkipToNextEntry();
|
||||
}
|
||||
|
||||
byte[] headerBuf = this.buffer.ReadRecord();
|
||||
byte[] headerBuf = this.buffer.ReadBlock();
|
||||
|
||||
if (headerBuf == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ NULL RECORD");
|
||||
if (headerBuf == null)
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("READ NULL BLOCK");
|
||||
}
|
||||
|
||||
this.hasHitEOF = true;
|
||||
} else if (this.buffer.IsEOFRecord(headerBuf)) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine( "READ EOF RECORD" );
|
||||
}
|
||||
else if (this.buffer.IsEOFBlock(headerBuf))
|
||||
{
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine( "READ EOF BLOCK" );
|
||||
}
|
||||
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
|
||||
if (this.hasHitEOF) {
|
||||
if (this.hasHitEOF)
|
||||
{
|
||||
this.currEntry = null;
|
||||
} else {
|
||||
try {
|
||||
if (this.eFactory == null) {
|
||||
this.currEntry = new TarEntry(headerBuf);
|
||||
} else {
|
||||
this.currEntry = this.eFactory.CreateEntry(headerBuf);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (!(headerBuf[257] == 'u' && headerBuf[258] == 's' && headerBuf[259] == 't' && headerBuf[260] == 'a' && headerBuf[261] == 'r')) {
|
||||
|
||||
// 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'))
|
||||
{
|
||||
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.Error.WriteLine("TarInputStream: SET CURRENTRY '" + this.currEntry.Name + "' size = " + this.currEntry.Size);
|
||||
if (this.debug)
|
||||
{
|
||||
//Console.WriteLine.WriteLine("TarInputStream: SET CURRENTRY '" + this.currEntry.Name + "' size = " + this.currEntry.Size);
|
||||
}
|
||||
|
||||
this.entryOffset = 0;
|
||||
|
||||
// REVIEW How do we resolve this discrepancy?!
|
||||
// TODO 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 block " + this.buffer.GetCurrentBlockNum() + " record " + this.buffer.GetCurrentRecordNum() + ", " + ex.Message);
|
||||
throw new InvalidHeaderException("bad header in record " + this.buffer.GetCurrentBlockNum() + " block " + this.buffer.GetCurrentBlockNum() + ", " + ex.Message);
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
@@ -364,7 +475,8 @@ 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];
|
||||
@@ -374,10 +486,9 @@ 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 as if they
|
||||
/// entry in the archive and will deal with them as if they
|
||||
/// entry in the archive and will deal with them appropriately
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// <param name="outputBuffer">
|
||||
/// The buffer into which to place bytes read.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
@@ -387,30 +498,36 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// The number of bytes to read.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The number of bytes read, or -1 at EOF.
|
||||
/// The number of bytes read, or 0 at end of stream/EOF.
|
||||
/// </returns>
|
||||
public override int Read(byte[] buf, int offset, int numToRead)
|
||||
public override int Read(byte[] outputBuffer, int offset, int numToRead)
|
||||
{
|
||||
int totalRead = 0;
|
||||
|
||||
if (this.entryOffset >= this.entrySize) {
|
||||
return -1;
|
||||
if (this.entryOffset >= this.entrySize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
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, buf, offset, sz);
|
||||
Array.Copy(this.readBuf, 0, outputBuffer, 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;
|
||||
}
|
||||
@@ -420,9 +537,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
offset += sz;
|
||||
}
|
||||
|
||||
while (numToRead > 0) {
|
||||
byte[] rec = this.buffer.ReadRecord();
|
||||
if (rec == null) {
|
||||
while (numToRead > 0)
|
||||
{
|
||||
byte[] rec = this.buffer.ReadBlock();
|
||||
if (rec == null)
|
||||
{
|
||||
// Unexpected EOF!
|
||||
throw new IOException("unexpected EOF with " + numToRead + " bytes unread");
|
||||
}
|
||||
@@ -430,13 +549,16 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
int sz = numToRead;
|
||||
int recLen = rec.Length;
|
||||
|
||||
if (recLen > sz) {
|
||||
Array.Copy(rec, 0, buf, offset, sz);
|
||||
if (recLen > sz)
|
||||
{
|
||||
Array.Copy(rec, 0, outputBuffer, 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, buf, offset, recLen);
|
||||
Array.Copy(rec, 0, outputBuffer, offset, recLen);
|
||||
}
|
||||
|
||||
totalRead += sz;
|
||||
@@ -460,9 +582,11 @@ 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,7 +36,8 @@ 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.
|
||||
@@ -49,7 +50,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
protected bool debug;
|
||||
protected int currSize;
|
||||
protected int currBytes;
|
||||
protected byte[] recordBuf;
|
||||
protected byte[] blockBuf;
|
||||
protected int assemLen;
|
||||
protected byte[] assemBuf;
|
||||
|
||||
@@ -59,8 +60,10 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -68,17 +71,21 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return outputStream.CanSeek;
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return outputStream.CanSeek; // -jr- Should be false?
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return outputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
@@ -86,8 +93,10 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -95,11 +104,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -141,35 +153,31 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
outputStream.Flush();
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream) : this(outputStream, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE)
|
||||
public TarOutputStream(Stream outputStream) : this(outputStream, TarBuffer.DefaultBlockFactor)
|
||||
{
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream, int blockSize) : this(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream, int blockSize, int recordSize)
|
||||
public TarOutputStream(Stream outputStream, int blockFactor)
|
||||
{
|
||||
this.outputStream = outputStream;
|
||||
this.buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockSize, recordSize);
|
||||
this.buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockFactor);
|
||||
|
||||
this.debug = false;
|
||||
this.assemLen = 0;
|
||||
this.assemBuf = new byte[recordSize];
|
||||
this.recordBuf = new byte[recordSize];
|
||||
this.assemBuf = new byte[TarBuffer.BlockSize];
|
||||
this.blockBuf = new byte[TarBuffer.BlockSize];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the debugging flag.
|
||||
/// </summary>
|
||||
/// <param name = "debugF">
|
||||
/// <param name = "debugFlag">
|
||||
/// True to turn on debugging.
|
||||
/// </param>
|
||||
public void SetDebug(bool debugF)
|
||||
public void SetDebug(bool debugFlag)
|
||||
{
|
||||
this.debug = debugF;
|
||||
SetBufferDebug(debugF);
|
||||
this.debug = debugFlag;
|
||||
SetBufferDebug(debugFlag);
|
||||
}
|
||||
|
||||
public void SetBufferDebug(bool debug)
|
||||
@@ -210,7 +218,7 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// Put an entry on the output stream. This writes the entry's
|
||||
/// header record and positions the output stream for writing
|
||||
/// header 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()
|
||||
@@ -222,12 +230,36 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </param>
|
||||
public void PutNextEntry(TarEntry entry)
|
||||
{
|
||||
if (entry.TarHeader.name.Length > TarHeader.NAMELEN) {
|
||||
throw new InvalidHeaderException("file name '" + entry.TarHeader.name + "' is too long ( > " + TarHeader.NAMELEN + " bytes )");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
entry.WriteEntryHeader(this.recordBuf);
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
entry.WriteEntryHeader(this.blockBuf);
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
|
||||
this.currBytes = 0;
|
||||
|
||||
@@ -238,25 +270,28 @@ 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 record based writes. Thus, there may be
|
||||
/// the buffer's block 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.WriteRecord(this.assemBuf);
|
||||
this.buffer.WriteBlock(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");
|
||||
}
|
||||
}
|
||||
@@ -293,7 +328,8 @@ 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");
|
||||
}
|
||||
|
||||
@@ -304,23 +340,27 @@ 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.recordBuf.Length) {
|
||||
int aLen = this.recordBuf.Length - this.assemLen;
|
||||
if (this.assemLen > 0)
|
||||
{
|
||||
if ((this.assemLen + numToWrite ) >= this.blockBuf.Length)
|
||||
{
|
||||
int aLen = this.blockBuf.Length - this.assemLen;
|
||||
|
||||
Array.Copy(this.assemBuf, 0, this.recordBuf, 0, this.assemLen);
|
||||
Array.Copy(this.assemBuf, 0, this.blockBuf, 0, this.assemLen);
|
||||
|
||||
Array.Copy(wBuf, wOffset, this.recordBuf, this.assemLen, aLen);
|
||||
Array.Copy(wBuf, wOffset, this.blockBuf, this.assemLen, aLen);
|
||||
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
|
||||
this.currBytes += this.recordBuf.Length;
|
||||
this.currBytes += this.blockBuf.Length;
|
||||
|
||||
wOffset += aLen;
|
||||
numToWrite -= aLen;
|
||||
|
||||
this.assemLen = 0;
|
||||
} else {// ( (this.assemLen + numToWrite ) < this.recordBuf.length )
|
||||
}
|
||||
else
|
||||
{// ( (this.assemLen + numToWrite ) < this.blockBuf.length )
|
||||
Array.Copy(wBuf, wOffset, this.assemBuf, this.assemLen, numToWrite);
|
||||
wOffset += numToWrite;
|
||||
this.assemLen += numToWrite;
|
||||
@@ -333,16 +373,18 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
// o An empty "assemble" buffer.
|
||||
// o No bytes to write (numToWrite == 0)
|
||||
//
|
||||
while (numToWrite > 0) {
|
||||
if (numToWrite < this.recordBuf.Length) {
|
||||
while (numToWrite > 0)
|
||||
{
|
||||
if (numToWrite < this.blockBuf.Length)
|
||||
{
|
||||
Array.Copy(wBuf, wOffset, this.assemBuf, this.assemLen, numToWrite);
|
||||
this.assemLen += numToWrite;
|
||||
break;
|
||||
}
|
||||
|
||||
this.buffer.WriteRecord(wBuf, wOffset);
|
||||
this.buffer.WriteBlock(wBuf, wOffset);
|
||||
|
||||
int num = this.recordBuf.Length;
|
||||
int num = this.blockBuf.Length;
|
||||
this.currBytes += num;
|
||||
numToWrite -= num;
|
||||
wOffset += num;
|
||||
@@ -355,10 +397,11 @@ namespace ICSharpCode.SharpZipLib.Tar {
|
||||
/// </summary>
|
||||
void WriteEOFRecord()
|
||||
{
|
||||
for (int i = 0; i < this.recordBuf.Length; ++i) {
|
||||
this.recordBuf[i] = 0;
|
||||
for (int i = 0; i < this.blockBuf.Length; ++i)
|
||||
{
|
||||
this.blockBuf[i] = 0;
|
||||
}
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
this.buffer.WriteBlock(this.blockBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -37,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This is the Deflater class. The deflater class compresses input
|
||||
@@ -119,8 +120,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;
|
||||
@@ -137,10 +138,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.
|
||||
@@ -360,7 +361,6 @@ 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;
|
||||
|
||||
+2
-1
@@ -37,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for the deflater.
|
||||
|
||||
+85
-82
@@ -39,9 +39,11 @@ 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,
|
||||
|
||||
@@ -60,7 +62,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
static int TOO_FAR = 4096;
|
||||
|
||||
int ins_h;
|
||||
// private byte[] buffer;
|
||||
// private byte[] buffer;
|
||||
short[] head;
|
||||
short[] prev;
|
||||
|
||||
@@ -175,15 +177,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();
|
||||
@@ -191,7 +193,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
case DEFLATE_FAST:
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
false);
|
||||
false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
break;
|
||||
@@ -200,8 +202,7 @@ 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;
|
||||
@@ -212,29 +213,29 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHash()
|
||||
void UpdateHash()
|
||||
{
|
||||
// if (DEBUGGING) {
|
||||
// Console.WriteLine("updateHash: "+strstart);
|
||||
// }
|
||||
// if (DEBUGGING) {
|
||||
// //Console.WriteLine("updateHash: "+strstart);
|
||||
// }
|
||||
ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1];
|
||||
}
|
||||
|
||||
private int InsertString()
|
||||
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;
|
||||
@@ -296,7 +297,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
}
|
||||
}
|
||||
|
||||
private bool FindLongestMatch(int curMatch)
|
||||
bool FindLongestMatch(int curMatch)
|
||||
{
|
||||
int chainLength = this.max_chain;
|
||||
int niceLength = this.niceLength;
|
||||
@@ -325,7 +326,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 {
|
||||
@@ -333,10 +334,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;
|
||||
@@ -345,14 +346,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)
|
||||
@@ -360,6 +361,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
matchStart = curMatch;
|
||||
best_end = scan;
|
||||
best_len = scan - strstart;
|
||||
|
||||
if (best_len >= niceLength) {
|
||||
break;
|
||||
}
|
||||
@@ -400,7 +402,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
blockStart = strstart;
|
||||
}
|
||||
|
||||
private bool DeflateStored(bool flush, bool finish)
|
||||
bool DeflateStored(bool flush, bool finish)
|
||||
{
|
||||
if (!flush && lookahead == 0) {
|
||||
return false;
|
||||
@@ -420,9 +422,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;
|
||||
@@ -445,8 +447,7 @@ 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.
|
||||
@@ -456,20 +457,25 @@ 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();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
huffman.TallyDist(strstart - matchStart, matchLen);
|
||||
// -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;
|
||||
}
|
||||
|
||||
lookahead -= matchLen;
|
||||
if (matchLen <= max_lazy && lookahead >= MIN_MATCH) {
|
||||
@@ -495,8 +501,7 @@ 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;
|
||||
}
|
||||
@@ -504,7 +509,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DeflateSlow(bool flush, bool finish)
|
||||
bool DeflateSlow(bool flush, bool finish)
|
||||
{
|
||||
if (lookahead < MIN_LOOKAHEAD && !flush) {
|
||||
return false;
|
||||
@@ -522,43 +527,41 @@ 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 {
|
||||
@@ -601,10 +604,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);
|
||||
|
||||
+104
-102
@@ -37,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This is the DeflaterHuffman class.
|
||||
@@ -78,15 +79,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;
|
||||
public int maxLength;
|
||||
|
||||
short[] codes;
|
||||
int[] bl_counts;
|
||||
int maxLength;
|
||||
DeflaterHuffman dh;
|
||||
|
||||
public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength)
|
||||
@@ -109,10 +110,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]);
|
||||
}
|
||||
|
||||
@@ -121,14 +122,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)
|
||||
@@ -144,17 +145,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!");
|
||||
@@ -163,17 +164,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildLength(int[] childs)
|
||||
void BuildLength(int[] childs)
|
||||
{
|
||||
this.length = new byte [freqs.Length];
|
||||
int numNodes = childs.Length / 2;
|
||||
@@ -204,13 +205,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;
|
||||
@@ -258,13 +259,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()
|
||||
@@ -332,16 +333,17 @@ 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.
|
||||
*/
|
||||
@@ -364,16 +366,17 @@ 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];
|
||||
@@ -476,8 +479,7 @@ 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) {
|
||||
@@ -509,10 +511,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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -570,7 +572,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
blTree.Reset();
|
||||
}
|
||||
|
||||
private int L_code(int len)
|
||||
int Lcode(int len)
|
||||
{
|
||||
if (len == 255) {
|
||||
return 285;
|
||||
@@ -584,7 +586,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
return code + len;
|
||||
}
|
||||
|
||||
private int D_code(int distance)
|
||||
int Dcode(int distance)
|
||||
{
|
||||
int code = 0;
|
||||
while (distance >= 4) {
|
||||
@@ -607,9 +609,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()
|
||||
@@ -618,11 +620,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 = L_code(litlen);
|
||||
int lc = Lcode(litlen);
|
||||
literalTree.WriteSymbol(lc);
|
||||
|
||||
int bits = (lc - 261) / 4;
|
||||
@@ -630,7 +632,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
pending.WriteBits(litlen & ((1 << bits) - 1), bits);
|
||||
}
|
||||
|
||||
int dc = D_code(dist);
|
||||
int dc = Dcode(dist);
|
||||
distTree.WriteSymbol(dc);
|
||||
|
||||
bits = dc / 2 - 1;
|
||||
@@ -638,41 +640,40 @@ 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 stored_offset, int stored_len, bool lastBlock)
|
||||
public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Flushing stored block "+ stored_len);
|
||||
// }
|
||||
pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1)
|
||||
+ (lastBlock ? 1 : 0), 3);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("Flushing stored block "+ storedLength);
|
||||
// }
|
||||
pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3);
|
||||
pending.AlignToByte();
|
||||
pending.WriteShort(stored_len);
|
||||
pending.WriteShort(~stored_len);
|
||||
pending.WriteBlock(stored, stored_offset, stored_len);
|
||||
pending.WriteShort(storedLength);
|
||||
pending.WriteShort(~storedLength);
|
||||
pending.WriteBlock(stored, storedOffset, storedLength);
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void FlushBlock(byte[] stored, int stored_offset, int stored_len, bool lastBlock)
|
||||
public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
|
||||
{
|
||||
literalTree.freqs[EOF_SYMBOL]++;
|
||||
|
||||
@@ -694,8 +695,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++) {
|
||||
@@ -709,13 +710,13 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
opt_len = static_len;
|
||||
}
|
||||
|
||||
if (stored_offset >= 0 && stored_len+4 < (opt_len >> 3)) {
|
||||
if ((storedOffset >= 0) && (storedLength + 4 < (opt_len >> 3))) {
|
||||
/* Store Block */
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Storing, since " + stored_len + " < " + opt_len
|
||||
// + " <= " + static_len);
|
||||
// }
|
||||
FlushStoredBlock(stored, stored_offset, stored_len, lastBlock);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len
|
||||
// + " <= " + static_len);
|
||||
// }
|
||||
FlushStoredBlock(stored, storedOffset, storedLength, lastBlock);
|
||||
} else if (opt_len == static_len) {
|
||||
/* Encode with static tree */
|
||||
pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3);
|
||||
@@ -734,18 +735,19 @@ 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 + 16 >= BUFSIZE; // HACK: This was == 'last_lit == BUFSIZE', but errors occured with DeflateFast
|
||||
return last_lit >= BUFSIZE; // -jr- This is the correct form!
|
||||
}
|
||||
|
||||
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]++;
|
||||
@@ -754,20 +756,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 = L_code(len - 3);
|
||||
int lc = Lcode(len - 3);
|
||||
literalTree.freqs[lc]++;
|
||||
if (lc >= 265 && lc < 285) {
|
||||
extra_bits += (lc - 261) / 4;
|
||||
}
|
||||
|
||||
int dc = D_code(dist - 1);
|
||||
int dc = Dcode(dist - 1);
|
||||
distTree.freqs[dc]++;
|
||||
if (dc >= 4) {
|
||||
extra_bits += dc / 2 - 1;
|
||||
|
||||
+2
-1
@@ -35,7 +35,8 @@
|
||||
// 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.
|
||||
|
||||
+35
-31
@@ -40,7 +40,8 @@ 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
|
||||
@@ -69,35 +70,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.
|
||||
@@ -384,9 +385,7 @@ 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;
|
||||
@@ -433,7 +432,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;
|
||||
@@ -452,15 +451,17 @@ 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;
|
||||
@@ -471,8 +472,9 @@ 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) {
|
||||
@@ -554,7 +556,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();
|
||||
@@ -660,12 +662,15 @@ 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 {
|
||||
@@ -687,8 +692,7 @@ 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
-85
@@ -39,7 +39,8 @@ using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
|
||||
class InflaterDynHeader
|
||||
{
|
||||
@@ -64,7 +65,8 @@ 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()
|
||||
{
|
||||
@@ -73,91 +75,93 @@ 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) {
|
||||
for (;;) {
|
||||
switch (mode) {
|
||||
case LNUM:
|
||||
lnum = input.PeekBits(5);
|
||||
if (lnum < 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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();
|
||||
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;
|
||||
}
|
||||
repSymbol = symbol-16;
|
||||
}
|
||||
mode = REPS;
|
||||
goto case REPS; // fall through
|
||||
case REPS:
|
||||
mode = REPS;
|
||||
goto case REPS; // fall through
|
||||
case REPS:
|
||||
{
|
||||
int bits = repBits[repSymbol];
|
||||
int count = input.PeekBits(bits);
|
||||
@@ -180,10 +184,10 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
mode = LENS;
|
||||
goto decode_loop;
|
||||
mode = LENS;
|
||||
goto decode_loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InflaterHuffmanTree BuildLitLenTree()
|
||||
|
||||
+8
-3
@@ -39,7 +39,8 @@ using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
|
||||
public class InflaterHuffmanTree
|
||||
{
|
||||
@@ -96,8 +97,9 @@ 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;
|
||||
@@ -112,9 +114,12 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
treeSize += (end - start) >> (16 - bits);
|
||||
}
|
||||
}
|
||||
if (code != 65536) {
|
||||
/* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g
|
||||
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.
|
||||
*/
|
||||
|
||||
+8
-6
@@ -37,7 +37,8 @@
|
||||
|
||||
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.
|
||||
@@ -73,8 +74,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -133,9 +135,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) {
|
||||
@@ -198,7 +200,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;
|
||||
|
||||
+92
-9
@@ -37,10 +37,11 @@
|
||||
|
||||
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
|
||||
@@ -80,7 +81,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return baseOutputStream.CanSeek;
|
||||
return false;
|
||||
// return baseOutputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +121,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return baseOutputStream.Seek(offset, origin);
|
||||
throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003
|
||||
// return baseOutputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,14 +148,24 @@ 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);
|
||||
@@ -177,7 +190,6 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </param>
|
||||
public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -228,7 +240,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
public override void Flush()
|
||||
{
|
||||
def.Flush();
|
||||
deflate();
|
||||
Deflate();
|
||||
baseOutputStream.Flush();
|
||||
}
|
||||
|
||||
@@ -238,11 +250,18 @@ 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) {
|
||||
@@ -289,8 +308,72 @@ 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
|
||||
}
|
||||
}
|
||||
+64
-25
@@ -39,8 +39,10 @@ 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"
|
||||
@@ -60,7 +62,6 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
protected Inflater inf;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Byte array used as a buffer
|
||||
/// </summary>
|
||||
@@ -79,6 +80,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
protected Stream baseInputStream;
|
||||
|
||||
protected long csize;
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
@@ -93,7 +96,8 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return baseInputStream.CanSeek;
|
||||
return false;
|
||||
// return baseInputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +144,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return baseInputStream.Seek(offset, origin);
|
||||
throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -167,6 +171,12 @@ 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>
|
||||
@@ -193,7 +203,6 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </param>
|
||||
public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -215,7 +224,8 @@ 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;
|
||||
}
|
||||
|
||||
@@ -243,9 +253,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
/// </summary>
|
||||
public override void 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();
|
||||
baseInputStream.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -254,8 +262,12 @@ 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);
|
||||
@@ -272,7 +284,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
if (nread > 0) {
|
||||
return onebytebuffer[0] & 0xff;
|
||||
}
|
||||
return -1;
|
||||
return -1; // ok
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,20 +340,47 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
if (n < len) {
|
||||
len = (int) n;
|
||||
}
|
||||
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;
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
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,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains the output from the Inflation process.
|
||||
@@ -52,45 +53,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 window_end = 0;
|
||||
private int window_filled = 0;
|
||||
private int windowEnd = 0;
|
||||
private int windowFilled = 0;
|
||||
|
||||
public void Write(int abyte)
|
||||
{
|
||||
if (window_filled++ == WINDOW_SIZE) {
|
||||
if (windowFilled++ == WINDOW_SIZE) {
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
window[window_end++] = (byte) abyte;
|
||||
window_end &= WINDOW_MASK;
|
||||
window[windowEnd++] = (byte) abyte;
|
||||
windowEnd &= WINDOW_MASK;
|
||||
}
|
||||
|
||||
|
||||
private void SlowRepeat(int rep_start, int len, int dist)
|
||||
private void SlowRepeat(int repStart, int len, int dist)
|
||||
{
|
||||
while (len-- > 0) {
|
||||
window[window_end++] = window[rep_start++];
|
||||
window_end &= WINDOW_MASK;
|
||||
rep_start &= WINDOW_MASK;
|
||||
window[windowEnd++] = window[repStart++];
|
||||
windowEnd &= WINDOW_MASK;
|
||||
repStart &= WINDOW_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
public void Repeat(int len, int dist)
|
||||
{
|
||||
if ((window_filled += len) > WINDOW_SIZE) {
|
||||
if ((windowFilled += len) > WINDOW_SIZE) {
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
|
||||
int rep_start = (window_end - dist) & WINDOW_MASK;
|
||||
int rep_start = (windowEnd - dist) & WINDOW_MASK;
|
||||
int border = WINDOW_SIZE - len;
|
||||
if (rep_start <= border && window_end < border) {
|
||||
if (rep_start <= border && windowEnd < border) {
|
||||
if (len <= dist) {
|
||||
System.Array.Copy(window, rep_start, window, window_end, len);
|
||||
window_end += len;
|
||||
} else {
|
||||
System.Array.Copy(window, rep_start, window, windowEnd, len);
|
||||
windowEnd += len;
|
||||
} else {
|
||||
/* We have to copy manually, since the repeat pattern overlaps.
|
||||
*/
|
||||
while (len-- > 0) {
|
||||
window[window_end++] = window[rep_start++];
|
||||
window[windowEnd++] = window[rep_start++];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -100,27 +101,27 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
public int CopyStored(StreamManipulator input, int len)
|
||||
{
|
||||
len = Math.Min(Math.Min(len, WINDOW_SIZE - window_filled), input.AvailableBytes);
|
||||
len = Math.Min(Math.Min(len, WINDOW_SIZE - windowFilled), input.AvailableBytes);
|
||||
int copied;
|
||||
|
||||
int tailLen = WINDOW_SIZE - window_end;
|
||||
int tailLen = WINDOW_SIZE - windowEnd;
|
||||
if (len > tailLen) {
|
||||
copied = input.CopyBytes(window, window_end, tailLen);
|
||||
copied = input.CopyBytes(window, windowEnd, tailLen);
|
||||
if (copied == tailLen) {
|
||||
copied += input.CopyBytes(window, 0, len - tailLen);
|
||||
}
|
||||
} else {
|
||||
copied = input.CopyBytes(window, window_end, len);
|
||||
copied = input.CopyBytes(window, windowEnd, len);
|
||||
}
|
||||
|
||||
window_end = (window_end + copied) & WINDOW_MASK;
|
||||
window_filled += copied;
|
||||
windowEnd = (windowEnd + copied) & WINDOW_MASK;
|
||||
windowFilled += copied;
|
||||
return copied;
|
||||
}
|
||||
|
||||
public void CopyDict(byte[] dict, int offset, int len)
|
||||
{
|
||||
if (window_filled > 0) {
|
||||
if (windowFilled > 0) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
@@ -129,40 +130,39 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
len = WINDOW_SIZE;
|
||||
}
|
||||
System.Array.Copy(dict, offset, window, 0, len);
|
||||
window_end = len & WINDOW_MASK;
|
||||
windowEnd = len & WINDOW_MASK;
|
||||
}
|
||||
|
||||
public int GetFreeSpace()
|
||||
{
|
||||
return WINDOW_SIZE - window_filled;
|
||||
return WINDOW_SIZE - windowFilled;
|
||||
}
|
||||
|
||||
public int GetAvailable()
|
||||
{
|
||||
return window_filled;
|
||||
return windowFilled;
|
||||
}
|
||||
|
||||
public int CopyOutput(byte[] output, int offset, int len)
|
||||
{
|
||||
int copy_end = window_end;
|
||||
if (len > window_filled) {
|
||||
len = window_filled;
|
||||
int copy_end = windowEnd;
|
||||
if (len > windowFilled) {
|
||||
len = windowFilled;
|
||||
} else {
|
||||
copy_end = (window_end - window_filled + len) & WINDOW_MASK;
|
||||
copy_end = (windowEnd - windowFilled + 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);
|
||||
window_filled -= copied;
|
||||
if (window_filled < 0) {
|
||||
windowFilled -= copied;
|
||||
if (windowFilled < 0) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
return copied;
|
||||
@@ -170,7 +170,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
window_filled = window_end = 0;
|
||||
windowFilled = windowEnd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -37,7 +37,8 @@
|
||||
|
||||
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
|
||||
@@ -75,7 +76,7 @@ namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
{
|
||||
if (bits_in_buffer < n) {
|
||||
if (window_start == window_end) {
|
||||
return -1;
|
||||
return -1; // ok
|
||||
}
|
||||
buffer |= (uint)((window[window_start++] & 0xff |
|
||||
(window[window_start++] & 0xff) << 8) << bits_in_buffer);
|
||||
@@ -174,7 +175,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,7 +37,8 @@
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for zip.
|
||||
@@ -58,6 +59,9 @@ 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;
|
||||
@@ -70,7 +74,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 = 0x06064b50;
|
||||
public const int CENSIG64 = 'P' | ('K' << 8) | (6 << 16) | (6 << 24);
|
||||
|
||||
public const int CENHDR = 46;
|
||||
|
||||
@@ -94,6 +98,9 @@ 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;
|
||||
@@ -104,21 +111,36 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
public const int ENDOFF = 16;
|
||||
public const int ENDCOM = 20;
|
||||
|
||||
/* 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);
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ConvertToString(byte[] data)
|
||||
{
|
||||
|
||||
return Encoding.ASCII.GetString(data);
|
||||
#if COMACT_FRAMEWORK
|
||||
return Encoding.ASCII.GetString(data,0, data.Length);
|
||||
#else
|
||||
return Encoding.GetEncoding(DefaultCodePage).GetString(data, 0, data.Length);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static byte[] ConvertToArray(string str)
|
||||
{
|
||||
#if COMACT_FRAMEWORK
|
||||
return Encoding.ASCII.GetBytes(str);
|
||||
#else
|
||||
return Encoding.GetEncoding(DefaultCodePage).GetBytes(str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
|
||||
public enum CompressionMethod
|
||||
{
|
||||
@@ -60,22 +61,63 @@ 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;
|
||||
int crc;
|
||||
uint crc;
|
||||
uint dosTime;
|
||||
|
||||
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.
|
||||
@@ -85,9 +127,10 @@ 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;
|
||||
}
|
||||
|
||||
@@ -99,72 +142,64 @@ 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;
|
||||
// time = e.time;
|
||||
method = e.method;
|
||||
extra = e.extra;
|
||||
comment = e.comment;
|
||||
crc = e.crc;
|
||||
dosTime = e.dosTime;
|
||||
method = e.method;
|
||||
extra = e.extra;
|
||||
comment = e.comment;
|
||||
}
|
||||
|
||||
public ushort Version {
|
||||
public int Version {
|
||||
get {
|
||||
return version;
|
||||
}
|
||||
set {
|
||||
version = value;
|
||||
version = (ushort)value;
|
||||
}
|
||||
}
|
||||
|
||||
public int DosTime {
|
||||
public long DosTime {
|
||||
get {
|
||||
// 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;
|
||||
if ((known & KNOWN_TIME) == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return dosTime;
|
||||
}
|
||||
}
|
||||
set {
|
||||
// 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;
|
||||
}
|
||||
this.dosTime = (uint)value;
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the time of last modification of the entry.
|
||||
/// </summary>
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
return cal;
|
||||
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);
|
||||
}
|
||||
set {
|
||||
lock (this) {
|
||||
cal = value;
|
||||
// time = (int) (cal.Millisecond / 1000L);
|
||||
}
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the entry name. The path components in the entry are
|
||||
/// always separated by slashes ('/').
|
||||
@@ -175,21 +210,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.
|
||||
@@ -204,7 +239,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");
|
||||
}
|
||||
@@ -249,10 +284,11 @@ 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 = (int)value;
|
||||
this.crc = (uint)value;
|
||||
this.known |= (ushort)KNOWN_CRC;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +309,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
return method;
|
||||
}
|
||||
set {
|
||||
this.method = value;
|
||||
this.method = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,13 +345,12 @@ 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);
|
||||
|
||||
cal = (new DateTime ( 1970, 1, 1, 0, 0, 0 ) +
|
||||
new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime ();
|
||||
DateTime = (new DateTime ( 1970, 1, 1, 0, 0, 0 ) + new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime ();
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
@@ -342,7 +377,8 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
return comment;
|
||||
}
|
||||
set {
|
||||
if (value.Length > 0xffff) {
|
||||
if (value.Length > 0xffff)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
this.comment = value;
|
||||
@@ -360,6 +396,18 @@ 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>
|
||||
@@ -376,18 +424,5 @@ 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,7 +43,8 @@ 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
|
||||
@@ -68,13 +69,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);
|
||||
/// }
|
||||
@@ -84,6 +85,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
public class ZipFile : IEnumerable
|
||||
{
|
||||
string name;
|
||||
string comment;
|
||||
Stream baseStream;
|
||||
ZipEntry[] entries;
|
||||
|
||||
@@ -203,6 +205,12 @@ 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++) {
|
||||
@@ -242,7 +250,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
entry.Crc = crc & 0xffffffffL;
|
||||
entry.Size = size & 0xffffffffL;
|
||||
entry.CompressedSize = csize & 0xffffffffL;
|
||||
entry.DosTime = dostime;
|
||||
entry.DosTime = (uint)dostime;
|
||||
if (extraLen > 0) {
|
||||
byte[] extra = new byte[extraLen];
|
||||
baseStream.Read(extra, 0, extraLen);
|
||||
@@ -252,8 +260,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;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +301,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return -1; // ok
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -330,7 +338,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");
|
||||
}
|
||||
@@ -359,7 +367,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
}
|
||||
|
||||
int extraLen = entry.Name.Length + ReadLeShort();
|
||||
return entry.offset + ZipConstants.LOCHDR + extraLen;
|
||||
return entry.Offset + ZipConstants.LOCHDR + extraLen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +391,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) {
|
||||
@@ -404,6 +412,15 @@ 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>
|
||||
@@ -465,7 +482,8 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
end = start + len;
|
||||
}
|
||||
|
||||
public override int Available {
|
||||
public override int Available
|
||||
{
|
||||
get {
|
||||
long amount = end - filepos;
|
||||
if (amount > Int32.MaxValue) {
|
||||
@@ -479,8 +497,9 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (filepos == end) {
|
||||
return -1;
|
||||
return -1; //ok
|
||||
}
|
||||
|
||||
lock(baseStream) {
|
||||
baseStream.Seek(filepos++, SeekOrigin.Begin);
|
||||
return baseStream.ReadByte();
|
||||
@@ -492,7 +511,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
if (len > end - filepos) {
|
||||
len = (int) (end - filepos);
|
||||
if (len == 0) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
lock(baseStream) {
|
||||
|
||||
@@ -43,8 +43,8 @@ using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a FilterInputStream that reads the files baseInputStream an zip archive
|
||||
/// one after another. It has a special method to get the zip entry of
|
||||
@@ -55,7 +55,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
/// <example> This sample shows how to read a zip file
|
||||
/// <code>
|
||||
/// <code lang="C#">
|
||||
/// using System;
|
||||
/// using System.Text;
|
||||
/// using System.IO;
|
||||
@@ -70,7 +70,6 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
///
|
||||
/// ZipEntry theEntry;
|
||||
/// while ((theEntry = s.GetNextEntry()) != null) {
|
||||
/// Console.WriteLine("File " + theEntry.Name);
|
||||
/// int size = 2048;
|
||||
/// byte[] data = new byte[2048];
|
||||
///
|
||||
@@ -85,7 +84,6 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// Console.WriteLine();
|
||||
/// }
|
||||
/// s.Close();
|
||||
/// }
|
||||
@@ -94,34 +92,42 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// </example>
|
||||
public class ZipInputStream : InflaterInputStream
|
||||
{
|
||||
private Crc32 crc = new Crc32();
|
||||
private ZipEntry entry = null;
|
||||
Crc32 crc = new Crc32();
|
||||
ZipEntry entry = null;
|
||||
|
||||
private long csize;
|
||||
private long size;
|
||||
private int method;
|
||||
private int flags;
|
||||
private long avail;
|
||||
long size;
|
||||
int method;
|
||||
int flags;
|
||||
long avail;
|
||||
string password = null;
|
||||
|
||||
public string Password {
|
||||
get {
|
||||
return password;
|
||||
}
|
||||
set {
|
||||
password = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Zip input stream, reading a zip archive.
|
||||
/// </summary>
|
||||
public ZipInputStream(Stream baseInputStream) : base(baseInputStream, new Inflater(true))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FillBuf()
|
||||
void FillBuf()
|
||||
{
|
||||
avail = len = baseInputStream.Read(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
private int ReadBuf(byte[] outBuf, int offset, int length)
|
||||
int ReadBuf(byte[] outBuf, int offset, int length)
|
||||
{
|
||||
if (avail <= 0) {
|
||||
FillBuf();
|
||||
if (avail <= 0) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (length > avail) {
|
||||
@@ -132,7 +138,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
return length;
|
||||
}
|
||||
|
||||
private void ReadFully(byte[] outBuf)
|
||||
void ReadFully(byte[] outBuf)
|
||||
{
|
||||
int off = 0;
|
||||
int len = outBuf.Length;
|
||||
@@ -146,7 +152,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
}
|
||||
}
|
||||
|
||||
private int ReadLeByte()
|
||||
int ReadLeByte()
|
||||
{
|
||||
if (avail <= 0) {
|
||||
FillBuf();
|
||||
@@ -160,7 +166,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// <summary>
|
||||
/// Read an unsigned short baseInputStream little endian byte order.
|
||||
/// </summary>
|
||||
private int ReadLeShort()
|
||||
int ReadLeShort()
|
||||
{
|
||||
return ReadLeByte() | (ReadLeByte() << 8);
|
||||
}
|
||||
@@ -168,7 +174,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// <summary>
|
||||
/// Read an int baseInputStream little endian byte order.
|
||||
/// </summary>
|
||||
private int ReadLeInt()
|
||||
int ReadLeInt()
|
||||
{
|
||||
return ReadLeShort() | (ReadLeShort() << 16);
|
||||
}
|
||||
@@ -176,7 +182,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// <summary>
|
||||
/// Read an int baseInputStream little endian byte order.
|
||||
/// </summary>
|
||||
private long ReadLeLong()
|
||||
long ReadLeLong()
|
||||
{
|
||||
return ReadLeInt() | (ReadLeInt() << 32);
|
||||
}
|
||||
@@ -194,28 +200,48 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
if (this.cryptbuffer != null) {
|
||||
if (avail == 0 && inf.RemainingInput != 0) {
|
||||
avail = inf.RemainingInput - 16;
|
||||
inf.Reset();
|
||||
}
|
||||
baseInputStream.Position -= this.len;
|
||||
baseInputStream.Read(this.buf, 0, this.len);
|
||||
}
|
||||
|
||||
int header = ReadLeInt();
|
||||
if (header == ZipConstants.CENSIG) {
|
||||
/* Central Header reached. */
|
||||
|
||||
// -jr- added end sig for empty zip files, Zip64 end sig and digital sig for files that have them...
|
||||
if (header == ZipConstants.CENSIG ||
|
||||
header == ZipConstants.ENDSIG ||
|
||||
header == ZipConstants.CENDIGITALSIG ||
|
||||
header == ZipConstants.CENSIG64) {
|
||||
// Central Header reached or end of empty zip file
|
||||
Close();
|
||||
return null;
|
||||
}
|
||||
// -jr- 07-Dec-2003 ignore spanning temporary signatures if found
|
||||
// SPANNINGSIG is same as descriptor signature and is untested as yet.
|
||||
if (header == ZipConstants.SPANTEMPSIG || header == ZipConstants.SPANNINGSIG) {
|
||||
header = ReadLeInt();
|
||||
}
|
||||
|
||||
if (header != ZipConstants.LOCSIG) {
|
||||
throw new ZipException("Wrong Local header signature" + header);
|
||||
throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header));
|
||||
}
|
||||
|
||||
short version = (short)ReadLeShort();
|
||||
|
||||
flags = ReadLeShort();
|
||||
method = ReadLeShort();
|
||||
int dostime = ReadLeInt();
|
||||
uint dostime = (uint)ReadLeInt();
|
||||
int crc2 = ReadLeInt();
|
||||
csize = ReadLeInt();
|
||||
size = ReadLeInt();
|
||||
int nameLen = ReadLeShort();
|
||||
int extraLen = ReadLeShort();
|
||||
|
||||
if (method == ZipOutputStream.STORED && csize != size) {
|
||||
bool isCrypted = (flags & 1) == 1;
|
||||
if (method == ZipOutputStream.STORED && (!isCrypted && csize != size || (isCrypted && csize - 12 != size))) {
|
||||
throw new ZipException("Stored, but compressed != uncompressed");
|
||||
}
|
||||
|
||||
@@ -225,7 +251,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
string name = ZipConstants.ConvertToString(buffer);
|
||||
|
||||
entry = new ZipEntry(name);
|
||||
|
||||
entry.IsCrypted = isCrypted;
|
||||
entry.Version = (ushort)version;
|
||||
if (method != 0 && method != 8) {
|
||||
throw new ZipException("unknown compression method " + method);
|
||||
@@ -237,22 +263,43 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
entry.Size = size & 0xFFFFFFFFL;
|
||||
entry.CompressedSize = csize & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
entry.DosTime = dostime;
|
||||
|
||||
if (extraLen > 0) {
|
||||
byte[] extra = new byte[extraLen];
|
||||
ReadFully(extra);
|
||||
entry.ExtraData = extra;
|
||||
}
|
||||
|
||||
// test for encryption
|
||||
if (isCrypted) {
|
||||
if (password == null) {
|
||||
throw new ZipException("No password set.");
|
||||
}
|
||||
InitializePassword(password);
|
||||
cryptbuffer = new byte[12];
|
||||
ReadFully(cryptbuffer);
|
||||
DecryptBlock(cryptbuffer, 0, cryptbuffer.Length);
|
||||
if ((flags & 8) == 0) {// -jr- 10-Feb-2004 Dont yet know correct size here....
|
||||
csize -= 12;
|
||||
}
|
||||
} else {
|
||||
cryptbuffer = null;
|
||||
}
|
||||
|
||||
if (method == ZipOutputStream.DEFLATED && avail > 0) {
|
||||
System.Array.Copy(buf, len - (int)avail, buf, 0, (int)avail);
|
||||
len = (int)avail;
|
||||
avail = 0;
|
||||
if (isCrypted) {
|
||||
DecryptBlock(buf, 0, Math.Min((int)csize, len));
|
||||
}
|
||||
inf.SetInput(buf, 0, len);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
private void ReadDataDescr()
|
||||
{
|
||||
if (ReadLeInt() != ZipConstants.EXTSIG) {
|
||||
@@ -273,6 +320,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
if (crc == null) {
|
||||
throw new InvalidOperationException("Closed.");
|
||||
}
|
||||
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
@@ -335,7 +383,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
{
|
||||
byte[] b = new byte[1];
|
||||
if (Read(b, 0, 1) <= 0) {
|
||||
return -1;
|
||||
return -1; // ok
|
||||
}
|
||||
return b[0] & 0xff;
|
||||
}
|
||||
@@ -355,24 +403,23 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
if (crc == null) {
|
||||
throw new InvalidOperationException("Closed.");
|
||||
}
|
||||
|
||||
if (entry == null) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
bool finished = false;
|
||||
|
||||
switch (method) {
|
||||
case ZipOutputStream.DEFLATED:
|
||||
len = base.Read(b, off, len);
|
||||
if (len < 0) {
|
||||
if (len <= 0) { // TODO BUG1 -jr- Check this was < 0 but avail was not adjusted causing failure in later calls
|
||||
if (!inf.IsFinished) {
|
||||
throw new ZipException("Inflater not finished!?");
|
||||
}
|
||||
avail = inf.RemainingInput;
|
||||
if ((flags & 8) != 0) {
|
||||
ReadDataDescr();
|
||||
}
|
||||
|
||||
if (inf.TotalIn != csize || inf.TotalOut != size) {
|
||||
// BUG1 -jr- With bit 3 set you dont yet know the size
|
||||
if ((flags & 8) == 0 && (inf.TotalIn != csize || inf.TotalOut != size)) {
|
||||
throw new ZipException("size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut);
|
||||
}
|
||||
inf.Reset();
|
||||
@@ -381,7 +428,6 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
break;
|
||||
|
||||
case ZipOutputStream.STORED:
|
||||
|
||||
if (len > csize && csize >= 0) {
|
||||
len = (int)csize;
|
||||
}
|
||||
@@ -398,15 +444,25 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
throw new ZipException("EOF in stored block");
|
||||
}
|
||||
}
|
||||
|
||||
// decrypting crypted data
|
||||
if (cryptbuffer != null) {
|
||||
DecryptBlock(b, off, len);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (len > 0) {
|
||||
crc.Update(b, off, len);
|
||||
}
|
||||
|
||||
if (finished) {
|
||||
if ((crc.Value & 0xFFFFFFFFL) != entry.Crc) {
|
||||
if ((flags & 8) != 0) {
|
||||
ReadDataDescr();
|
||||
}
|
||||
|
||||
if ((crc.Value & 0xFFFFFFFFL) != entry.Crc && entry.Crc != -1) {
|
||||
throw new ZipException("CRC mismatch");
|
||||
}
|
||||
crc.Reset();
|
||||
@@ -427,5 +483,6 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
crc = null;
|
||||
entry = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,8 @@ using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a FilterOutputStream that writes the files into a zip
|
||||
/// archive one after another. It has a special method to start a new
|
||||
@@ -107,7 +107,6 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
private byte[] zipComment = new byte[0];
|
||||
private int defaultMethod = DEFLATED;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Our Zip version is hard coded to 1.0 resp. 2.0
|
||||
/// </summary>
|
||||
@@ -212,6 +211,14 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
|
||||
bool shouldWriteBack = false;
|
||||
// -jr- Having a hard coded flag for seek capability requires this so users can determine
|
||||
// if the entries will be patched or not.
|
||||
public bool CanPatchEntries {
|
||||
get {
|
||||
return baseOutputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
long seekPos = -1;
|
||||
/// <summary>
|
||||
/// Starts a new Zip entry. It automatically closes the previous
|
||||
@@ -237,7 +244,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
CompressionMethod method = entry.CompressionMethod;
|
||||
int flags = 0;
|
||||
|
||||
entry.IsCrypted = Password != null;
|
||||
switch (method) {
|
||||
case CompressionMethod.Stored:
|
||||
if (entry.CompressedSize >= 0) {
|
||||
@@ -250,6 +257,10 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
entry.CompressedSize = entry.Size;
|
||||
}
|
||||
|
||||
if (entry.IsCrypted) {
|
||||
entry.CompressedSize += 12;
|
||||
}
|
||||
|
||||
if (entry.Size < 0) {
|
||||
throw new ZipException("Method STORED, but size not set");
|
||||
} else if (entry.Crc < 0) {
|
||||
@@ -267,12 +278,14 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
// if (entry.DosTime < 0) {
|
||||
// entry.Time = System.Environment.TickCount;
|
||||
// }
|
||||
|
||||
entry.flags = flags;
|
||||
entry.offset = offset;
|
||||
// if (entry.DosTime < 0) {
|
||||
// entry.Time = System.Environment.TickCount;
|
||||
// }
|
||||
if (entry.IsCrypted) {
|
||||
flags |= 1;
|
||||
}
|
||||
entry.Flags = flags;
|
||||
entry.Offset = offset;
|
||||
entry.CompressionMethod = (CompressionMethod)method;
|
||||
|
||||
curMethod = method;
|
||||
@@ -284,7 +297,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
if ((flags & 8) == 0) {
|
||||
WriteLeShort(flags);
|
||||
WriteLeShort((byte)method);
|
||||
WriteLeInt(entry.DosTime);
|
||||
WriteLeInt((int)entry.DosTime);
|
||||
WriteLeInt((int)entry.Crc);
|
||||
WriteLeInt((int)entry.CompressedSize);
|
||||
WriteLeInt((int)entry.Size);
|
||||
@@ -297,8 +310,10 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
WriteLeShort(flags);
|
||||
}
|
||||
WriteLeShort((byte)method);
|
||||
WriteLeInt(entry.DosTime);
|
||||
seekPos = baseOutputStream.Position;
|
||||
WriteLeInt((int)entry.DosTime);
|
||||
if (baseOutputStream.CanSeek) {
|
||||
seekPos = baseOutputStream.Position;
|
||||
}
|
||||
WriteLeInt(0);
|
||||
WriteLeInt(0);
|
||||
WriteLeInt(0);
|
||||
@@ -321,6 +336,16 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
baseOutputStream.Write(name, 0, name.Length);
|
||||
baseOutputStream.Write(extra, 0, extra.Length);
|
||||
|
||||
if (Password != null) {
|
||||
InitializePassword(Password);
|
||||
byte[] cryptbuffer = new byte[12];
|
||||
Random rnd = new Random();
|
||||
for (int i = 0; i < cryptbuffer.Length; ++i) {
|
||||
cryptbuffer[i] = (byte)rnd.Next();
|
||||
}
|
||||
EncryptBlock(cryptbuffer, 0, cryptbuffer.Length);
|
||||
baseOutputStream.Write(cryptbuffer, 0, cryptbuffer.Length);
|
||||
}
|
||||
offset += ZipConstants.LOCHDR + name.Length + extra.Length;
|
||||
|
||||
/* Activate the entry. */
|
||||
@@ -357,30 +382,33 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
if (curEntry.Size < 0) {
|
||||
curEntry.Size = size;
|
||||
} else if (curEntry.Size != size) {
|
||||
throw new ZipException("size was " + size +
|
||||
", but I expected " + curEntry.Size);
|
||||
throw new ZipException("size was " + size + ", but I expected " + curEntry.Size);
|
||||
}
|
||||
|
||||
if (curEntry.IsCrypted) {
|
||||
csize += 12;
|
||||
}
|
||||
|
||||
if (curEntry.CompressedSize < 0) {
|
||||
curEntry.CompressedSize = csize;
|
||||
} else if (curEntry.CompressedSize != csize) {
|
||||
throw new ZipException("compressed size was " + csize +
|
||||
", but I expected " + curEntry.CompressedSize);
|
||||
throw new ZipException("compressed size was " + csize + ", but I expected " + curEntry.CompressedSize);
|
||||
}
|
||||
|
||||
if (curEntry.Crc < 0) {
|
||||
curEntry.Crc = crc.Value;
|
||||
} else if (curEntry.Crc != crc.Value) {
|
||||
throw new ZipException("crc was " + crc.Value +
|
||||
", but I expected " +
|
||||
curEntry.Crc);
|
||||
", but I expected " +
|
||||
curEntry.Crc);
|
||||
}
|
||||
|
||||
offset += csize;
|
||||
|
||||
/* Now write the data descriptor entry if needed. */
|
||||
if (curMethod == CompressionMethod.Deflated && (curEntry.flags & 8) != 0) {
|
||||
if (curMethod == CompressionMethod.Deflated && (curEntry.Flags & 8) != 0) {
|
||||
if (shouldWriteBack) {
|
||||
curEntry.Flags &= ~8;
|
||||
long curPos = baseOutputStream.Position;
|
||||
baseOutputStream.Seek(seekPos, SeekOrigin.Begin);
|
||||
WriteLeInt((int)curEntry.Crc);
|
||||
@@ -400,8 +428,7 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
entries.Add(curEntry);
|
||||
curEntry = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Writes the given buffer to the current entry.
|
||||
/// </summary>
|
||||
@@ -422,15 +449,21 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
base.Write(b, off, len);
|
||||
break;
|
||||
case CompressionMethod.Stored:
|
||||
baseOutputStream.Write(b, off, len);
|
||||
if (Password != null) {
|
||||
byte[] buf = new byte[len];
|
||||
Array.Copy(b, off, buf, 0, len);
|
||||
EncryptBlock(buf, 0, len);
|
||||
baseOutputStream.Write(buf, off, len);
|
||||
} else {
|
||||
baseOutputStream.Write(b, off, len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
crc.Update(b, off, len);
|
||||
|
||||
size += len;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finishes the stream. This will write the central directory at the
|
||||
/// end of the zip file and flush the stream.
|
||||
@@ -438,72 +471,80 @@ namespace ICSharpCode.SharpZipLib.Zip {
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// if an I/O error occured.
|
||||
/// </exception>
|
||||
public override void Finish()
|
||||
{
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
if (curEntry != null) {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
int numEntries = 0;
|
||||
int sizeEntries = 0;
|
||||
|
||||
foreach (ZipEntry entry in entries) {
|
||||
// TODO : check the appnote file for compilance with the central directory standard
|
||||
CompressionMethod method = entry.CompressionMethod;
|
||||
WriteLeInt(ZipConstants.CENSIG);
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
WriteLeShort(entry.flags);
|
||||
WriteLeShort((short)method);
|
||||
WriteLeInt(entry.DosTime);
|
||||
WriteLeInt((int)entry.Crc);
|
||||
WriteLeInt((int)entry.CompressedSize);
|
||||
WriteLeInt((int)entry.Size);
|
||||
|
||||
byte[] name = ZipConstants.ConvertToArray(entry.Name);
|
||||
|
||||
if (name.Length > 0xffff) {
|
||||
throw new ZipException("Name too long.");
|
||||
}
|
||||
byte[] extra = entry.ExtraData;
|
||||
if (extra == null) {
|
||||
extra = new byte[0];
|
||||
}
|
||||
string strComment = entry.Comment;
|
||||
byte[] comment = strComment != null ? ZipConstants.ConvertToArray(strComment) : new byte[0];
|
||||
if (comment.Length > 0xffff) {
|
||||
throw new ZipException("Comment too long.");
|
||||
}
|
||||
|
||||
WriteLeShort(name.Length);
|
||||
WriteLeShort(extra.Length);
|
||||
WriteLeShort(comment.Length);
|
||||
WriteLeShort(0); /* disk number */
|
||||
WriteLeShort(0); /* internal file attr */
|
||||
WriteLeInt(0); /* external file attr */
|
||||
WriteLeInt(entry.offset);
|
||||
|
||||
baseOutputStream.Write(name, 0, name.Length);
|
||||
baseOutputStream.Write(extra, 0, extra.Length);
|
||||
baseOutputStream.Write(comment, 0, comment.Length);
|
||||
++numEntries;
|
||||
sizeEntries += ZipConstants.CENHDR + name.Length + extra.Length + comment.Length;
|
||||
}
|
||||
|
||||
WriteLeInt(ZipConstants.ENDSIG);
|
||||
WriteLeShort(0); /* disk number */
|
||||
WriteLeShort(0); /* disk with start of central dir */
|
||||
WriteLeShort(numEntries);
|
||||
WriteLeShort(numEntries);
|
||||
WriteLeInt(sizeEntries);
|
||||
WriteLeInt(offset);
|
||||
WriteLeShort(zipComment.Length);
|
||||
baseOutputStream.Write(zipComment, 0, zipComment.Length);
|
||||
baseOutputStream.Flush();
|
||||
entries = null;
|
||||
}
|
||||
public override void Finish()
|
||||
{
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (curEntry != null) {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
int numEntries = 0;
|
||||
int sizeEntries = 0;
|
||||
|
||||
foreach (ZipEntry entry in entries) {
|
||||
// TODO : check the appnote file for compilance with the central directory standard
|
||||
CompressionMethod method = entry.CompressionMethod;
|
||||
WriteLeInt(ZipConstants.CENSIG);
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
|
||||
WriteLeShort(entry.Flags);
|
||||
WriteLeShort((short)method);
|
||||
WriteLeInt((int)entry.DosTime);
|
||||
WriteLeInt((int)entry.Crc);
|
||||
WriteLeInt((int)entry.CompressedSize);
|
||||
WriteLeInt((int)entry.Size);
|
||||
|
||||
byte[] name = ZipConstants.ConvertToArray(entry.Name);
|
||||
|
||||
if (name.Length > 0xffff) {
|
||||
throw new ZipException("Name too long.");
|
||||
}
|
||||
|
||||
byte[] extra = entry.ExtraData;
|
||||
if (extra == null) {
|
||||
extra = new byte[0];
|
||||
}
|
||||
|
||||
string strComment = entry.Comment;
|
||||
byte[] comment = strComment != null ? ZipConstants.ConvertToArray(strComment) : new byte[0];
|
||||
if (comment.Length > 0xffff) {
|
||||
throw new ZipException("Comment too long.");
|
||||
}
|
||||
|
||||
WriteLeShort(name.Length);
|
||||
WriteLeShort(extra.Length);
|
||||
WriteLeShort(comment.Length);
|
||||
WriteLeShort(0); // disk number
|
||||
WriteLeShort(0); // internal file attr
|
||||
if (entry.IsDirectory) { // -jr- 17-12-2003 mark entry as directory (from nikolam.AT.perfectinfo.com)
|
||||
WriteLeInt(16);
|
||||
} else {
|
||||
WriteLeInt(0); // external file attr
|
||||
}
|
||||
WriteLeInt(entry.Offset);
|
||||
|
||||
baseOutputStream.Write(name, 0, name.Length);
|
||||
baseOutputStream.Write(extra, 0, extra.Length);
|
||||
baseOutputStream.Write(comment, 0, comment.Length);
|
||||
++numEntries;
|
||||
sizeEntries += ZipConstants.CENHDR + name.Length + extra.Length + comment.Length;
|
||||
}
|
||||
|
||||
WriteLeInt(ZipConstants.ENDSIG);
|
||||
WriteLeShort(0); // disk number
|
||||
WriteLeShort(0); // disk with start of central dir
|
||||
WriteLeShort(numEntries);
|
||||
WriteLeShort(numEntries);
|
||||
WriteLeInt(sizeEntries);
|
||||
WriteLeInt(offset);
|
||||
WriteLeShort(zipComment.Length);
|
||||
baseOutputStream.Write(zipComment, 0, zipComment.Length);
|
||||
baseOutputStream.Flush();
|
||||
entries = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib {
|
||||
namespace ICSharpCode.SharpZipLib
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Is thrown during the creation or input of a zip file.
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
I imported the 0.6 version of the library. The only changes from the origional were
|
||||
the case of some of the file names -- I changed them to match the names in cvs.
|
||||
|
||||
Ben Maurer. May, 2004.
|
||||
|
||||
--------------------
|
||||
|
||||
This directory contains a local copy of the Zip library from the NZipLib project.
|
||||
|
||||
I have added this as a temporary measure to simplify the building and development
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,11 @@
|
||||
2004-05-28 Cesar Lopez Nataren <[email protected]>
|
||||
|
||||
* Statement.cs: changed parent_is_itr_stm method to ParentIsItrStm
|
||||
property. Added initial pieces for Break's Resolve. Fixed bug that
|
||||
did not let Emit the code for case clauses that came after the
|
||||
default clause (we match the jsc behavior).
|
||||
* jscript-lexer-parser.g: set parent of switch's clauses.
|
||||
|
||||
2004-05-27 Cesar Lopez Nataren <[email protected]>
|
||||
|
||||
* Statement.cs: added parent as a parameter on Continue constructor. Added parent_is_itr_stm
|
||||
|
||||
@@ -915,16 +915,27 @@ _loop15_breakloop: ;
|
||||
|
||||
match(LITERAL_switch);
|
||||
match(OPEN_PARENS);
|
||||
exp=expr(parent);
|
||||
exp=expr(sw);
|
||||
match(CLOSE_PARENS);
|
||||
clauses=case_block(parent);
|
||||
clauses=case_block(sw);
|
||||
if (0==inputState.guessing)
|
||||
{
|
||||
|
||||
sw.exp = exp;
|
||||
exp.parent = sw;
|
||||
|
||||
sw.case_clauses = clauses [0];
|
||||
sw.default_clauses = clauses [1];
|
||||
sw.sec_case_clauses = clauses [2];
|
||||
|
||||
foreach (Clause cc in sw.case_clauses)
|
||||
foreach (AST ast in cc.stm_list)
|
||||
ast.parent = sw;
|
||||
foreach (AST dc in sw.default_clauses)
|
||||
dc.parent = sw;
|
||||
foreach (Clause cc in sw.case_clauses)
|
||||
foreach (AST ast in cc.stm_list)
|
||||
ast.parent = sw;
|
||||
|
||||
}
|
||||
return sw;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Microsoft.JScript {
|
||||
|
||||
internal override bool Resolve (IdentificationTable context)
|
||||
{
|
||||
if ((parent == null || (!parent_is_itr_stm ())) && identifier == string.Empty)
|
||||
if ((parent == null || !ParentIsItrStm) && identifier == string.Empty)
|
||||
throw new Exception ("A continue can't be outside a iteration stm");
|
||||
return false;
|
||||
}
|
||||
@@ -104,11 +104,12 @@ namespace Microsoft.JScript {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
private bool parent_is_itr_stm ()
|
||||
{
|
||||
if (parent is DoWhile || parent is While || parent is For || parent is ForIn)
|
||||
return true;
|
||||
return false;
|
||||
private bool ParentIsItrStm {
|
||||
get {
|
||||
if (parent is DoWhile || parent is While || parent is For || parent is ForIn)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +124,17 @@ namespace Microsoft.JScript {
|
||||
|
||||
internal override bool Resolve (IdentificationTable context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if ((parent == null || !ParentIsCorrect) && identifier == string.Empty)
|
||||
throw new Exception ("A break statement can't be outside a switch or iteration stm");
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ParentIsCorrect {
|
||||
get {
|
||||
if (parent is DoWhile || parent is While || parent is For || parent is ForIn || parent is Switch)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Emit (EmitContext ec)
|
||||
@@ -332,25 +343,45 @@ namespace Microsoft.JScript {
|
||||
{
|
||||
if (exp != null)
|
||||
exp.Emit (ec);
|
||||
|
||||
ILGenerator ig = ec.ig;
|
||||
Label init_default = ig.DefineLabel ();
|
||||
Label end_of_default = ig.DefineLabel ();
|
||||
|
||||
LocalBuilder loc = ig.DeclareLocal (typeof (object));
|
||||
ig.Emit (OpCodes.Stloc, loc);
|
||||
|
||||
foreach (Clause c in case_clauses) {
|
||||
ig.Emit (OpCodes.Ldloc, loc);
|
||||
c.EmitConditional (ec);
|
||||
}
|
||||
Label end = ig.DefineLabel ();
|
||||
ig.Emit (OpCodes.Br, end);
|
||||
|
||||
/* emit conditionals from clauses that come after the default clause */
|
||||
if (sec_case_clauses != null && sec_case_clauses.Count > 0) {
|
||||
foreach (Clause c in sec_case_clauses) {
|
||||
ig.Emit (OpCodes.Ldloc, loc);
|
||||
c.EmitConditional (ec);
|
||||
}
|
||||
}
|
||||
ig.Emit (OpCodes.Br, init_default);
|
||||
|
||||
/* emit the stms from case_clauses */
|
||||
foreach (Clause c in case_clauses) {
|
||||
ig.MarkLabel (c.matched_block);
|
||||
c.EmitStms (ec);
|
||||
}
|
||||
ig.MarkLabel (end);
|
||||
|
||||
ig.MarkLabel (init_default);
|
||||
foreach (AST ast in default_clauses)
|
||||
ast.Emit (ec);
|
||||
// FIXME: clauses after default clause are not being generated.
|
||||
foreach (Clause sc in sec_case_clauses)
|
||||
sc.Emit (ec);
|
||||
ig.MarkLabel (end_of_default);
|
||||
|
||||
if (sec_case_clauses != null && sec_case_clauses.Count > 0) {
|
||||
foreach (Clause c in sec_case_clauses) {
|
||||
ig.MarkLabel (c.matched_block);
|
||||
c.EmitStms (ec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,6 +424,6 @@ namespace Microsoft.JScript {
|
||||
|
||||
internal override void Emit (EmitContext ec)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,12 +159,23 @@ switch_stm [AST parent] returns [Switch sw]
|
||||
AST exp = null;
|
||||
ArrayList [] clauses = null;
|
||||
}
|
||||
: "switch" OPEN_PARENS exp = expr [parent] CLOSE_PARENS clauses = case_block [parent]
|
||||
: "switch" OPEN_PARENS exp = expr [sw] CLOSE_PARENS clauses = case_block [sw]
|
||||
{
|
||||
sw.exp = exp;
|
||||
exp.parent = sw;
|
||||
|
||||
sw.case_clauses = clauses [0];
|
||||
sw.default_clauses = clauses [1];
|
||||
sw.sec_case_clauses = clauses [2];
|
||||
|
||||
foreach (Clause cc in sw.case_clauses)
|
||||
foreach (AST ast in cc.stm_list)
|
||||
ast.parent = sw;
|
||||
foreach (AST dc in sw.default_clauses)
|
||||
dc.parent = sw;
|
||||
foreach (Clause cc in sw.case_clauses)
|
||||
foreach (AST ast in cc.stm_list)
|
||||
ast.parent = sw;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2004-05-28 Peter Bartok <[email protected]>
|
||||
* ContainerControl.cs: First attempt at implementing some missing
|
||||
methods
|
||||
* ScrollableControl.cs: Fixed creation parameters and cleaned up a bit
|
||||
* UserControl.cs: Clean up and small fixes
|
||||
|
||||
2004-05-25 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* PrintDialog.cs : Build fix related to win32functions.cs changes.
|
||||
|
||||
@@ -21,18 +21,30 @@ namespace System.Windows.Forms {
|
||||
|
||||
public class ContainerControl : ScrollableControl, IContainerControl {
|
||||
|
||||
private Control activeControl;
|
||||
|
||||
public ContainerControl () : base ()
|
||||
{
|
||||
controlStyles_ |= ControlStyles.ContainerControl;
|
||||
}
|
||||
|
||||
|
||||
[MonoTODO]
|
||||
public Control ActiveControl {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
return(activeControl);
|
||||
}
|
||||
set {
|
||||
//FIXME:
|
||||
if ((value==activeControl) || (value==null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Contains(value)) {
|
||||
throw new ArgumentException("Not a child control");
|
||||
}
|
||||
|
||||
// FIXME; need to let Wine know
|
||||
activeControl=value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +64,14 @@ namespace System.Windows.Forms {
|
||||
get { return base.CreateParams; }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public Form ParentForm {
|
||||
get { throw new NotImplementedException (); }
|
||||
get {
|
||||
if (Parent != null) {
|
||||
return(Parent.FindForm());
|
||||
} else {
|
||||
return(FindForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// --- Methods ---
|
||||
@@ -74,39 +91,76 @@ namespace System.Windows.Forms {
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
// not memeber?
|
||||
bool IContainerControl.ActivateControl(Control control)
|
||||
public bool ActivateControl(Control control)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
Control parent=Parent;
|
||||
ContainerControl container;
|
||||
bool result=true;
|
||||
|
||||
// We might have a container inside a container, etc...
|
||||
// if we do, make sure that the whole chain up knows about the activation
|
||||
if (parent!=null) {
|
||||
container=parent.GetContainerControl() as ContainerControl;
|
||||
if ((container!=null) && (container.ActiveControl!=this)) {
|
||||
container.ActivateControl(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (activeControl!=control) {
|
||||
// FIXME - let wine know
|
||||
activeControl=control;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
// [event methods]
|
||||
protected override void OnControlRemoved (ControlEventArgs e)
|
||||
{
|
||||
//FIXME:
|
||||
base.OnControlRemoved (e);
|
||||
if ((e.Control==activeControl) || (e.Control.Contains(activeControl))) {
|
||||
ActiveControl=null;
|
||||
}
|
||||
base.OnControlRemoved(e);
|
||||
}
|
||||
|
||||
protected override void OnCreateControl ()
|
||||
{
|
||||
//FIXME:
|
||||
base.OnCreateControl ();
|
||||
OnBindingContextChanged(EventArgs.Empty);
|
||||
}
|
||||
// end of [event methods]
|
||||
|
||||
[MonoTODO]
|
||||
protected override bool ProcessDialogChar (char charCode)
|
||||
{
|
||||
//FIXME:
|
||||
// Only process if we own the whole thing
|
||||
if (GetTopLevel()) {
|
||||
if (ProcessMnemonic(charCode)) {
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return base.ProcessDialogChar(charCode);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected override bool ProcessDialogKey (Keys keyData)
|
||||
protected override bool ProcessDialogKey (Keys keyData)
|
||||
{
|
||||
if ( keyData == Keys.Tab ) {
|
||||
return ProcessTabKey ( Control.ModifierKeys != Keys.Shift );
|
||||
} else if ((keyData==Keys.Left) || (keyData==Keys.Right) || (keyData==Keys.Up) || (keyData==Keys.Down)) {
|
||||
// Select the next control
|
||||
|
||||
Control select=this;
|
||||
bool forward=true;
|
||||
|
||||
if ((keyData==Keys.Left) || (keyData==Keys.Up)) {
|
||||
forward=false;
|
||||
}
|
||||
|
||||
if (activeControl!=null) {
|
||||
select=activeControl.Parent;
|
||||
}
|
||||
|
||||
select.SelectNextControl(activeControl, forward, false, false, true);
|
||||
return(true);
|
||||
}
|
||||
return base.ProcessDialogKey(keyData);
|
||||
}
|
||||
@@ -145,7 +199,6 @@ namespace System.Windows.Forms {
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//FIXME:
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace System.Windows.Forms {
|
||||
// --- Constructor
|
||||
//
|
||||
public ScrollableControl () : base () {
|
||||
base.SetStyle(ControlStyles.ContainerControl, true);
|
||||
dockPadding = new ScrollableControl.DockPaddingEdges();
|
||||
TabStop = false;
|
||||
}
|
||||
@@ -108,10 +109,10 @@ namespace System.Windows.Forms {
|
||||
RegisterDefaultWindowClass ( );
|
||||
|
||||
CreateParams createParams = base.CreateParams;
|
||||
createParams.Caption = "Hello World";
|
||||
createParams.Caption = "ScrollableControl";
|
||||
createParams.ClassName = Win32.DEFAULT_WINDOW_CLASS;
|
||||
|
||||
createParams.Style = (int) (WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CHILD);
|
||||
createParams.Style = (int) (WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE);
|
||||
//test version with scroll bars.
|
||||
//createParams.Style = (int) (WindowStyles.WS_OVERLAPPEDWINDOW | WindowStyles.WS_HSCROLL | WindowStyles.WS_VSCROLL);
|
||||
|
||||
@@ -142,17 +143,6 @@ namespace System.Windows.Forms {
|
||||
//
|
||||
// --- Protected Methods
|
||||
//
|
||||
static private IntPtr WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) {
|
||||
Message message = new Message();
|
||||
|
||||
message.HWnd = hWnd;
|
||||
message.Msg = (int) msg;
|
||||
message.WParam = wParam;
|
||||
message.LParam = lParam;
|
||||
message.Result = (IntPtr)0;
|
||||
|
||||
return (IntPtr)0;
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected virtual void AdjustFormScrollbars (
|
||||
|
||||
@@ -13,60 +13,54 @@ using System.Drawing;
|
||||
namespace System.Windows.Forms {
|
||||
|
||||
public class UserControl : ContainerControl{
|
||||
// --- Events ---
|
||||
public event EventHandler Load;
|
||||
|
||||
// --- Properties ---
|
||||
[MonoTODO]
|
||||
protected override Size DefaultSize {
|
||||
get { return new Size ( 150, 150 ); }
|
||||
get {
|
||||
return new Size(150, 150);
|
||||
}
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override string Text {
|
||||
|
||||
get {
|
||||
//FIXME:
|
||||
return base.Text;
|
||||
}
|
||||
set {
|
||||
//FIXME:
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Constructor ---
|
||||
[MonoTODO]
|
||||
public UserControl()
|
||||
{
|
||||
|
||||
// Nothing to do at this time
|
||||
}
|
||||
|
||||
// --- Methods ---
|
||||
[MonoTODO]
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
//FIXME:
|
||||
base.OnCreateControl();
|
||||
OnLoad(EventArgs.Empty);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected virtual void OnLoad(EventArgs e)
|
||||
{
|
||||
//FIXME:
|
||||
if (Load!=null) {
|
||||
Load(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
//FIXME:
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//FIXME:
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
// --- Events ---
|
||||
public event EventHandler Load;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
2004-05-29 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnectionStream.cs: fixed CanRead property. Closes bug #59273.
|
||||
|
||||
2004-05-28 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* DigestClient.cs: cache the sessions based on address and
|
||||
|
||||
@@ -464,7 +464,7 @@ namespace System.Net
|
||||
}
|
||||
|
||||
public override bool CanRead {
|
||||
get { return isRead && (contentLength == Int32.MaxValue || totalRead < contentLength); }
|
||||
get { return isRead; }
|
||||
}
|
||||
|
||||
public override bool CanWrite {
|
||||
|
||||
@@ -475,10 +475,6 @@ namespace System.Reflection.Emit {
|
||||
throw not_supported ();
|
||||
}
|
||||
|
||||
public override FileStream[] GetFiles() {
|
||||
throw not_supported ();
|
||||
}
|
||||
|
||||
public override FileStream[] GetFiles(bool getResourceModules) {
|
||||
throw not_supported ();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
2004-05-29 Gert Driesen ([email protected])
|
||||
|
||||
* AssemblyBuilder.cs: removed extra method, fixes public API
|
||||
compatibility with MS.NET
|
||||
* TypeBuilder.cs: removed extra method, fixes public API
|
||||
compatibility with MS.NET
|
||||
|
||||
2004-05-28 Jackson Harper <[email protected]>
|
||||
|
||||
* CustomAttributeBuilder.cs: GetBlob now takes a ref to the
|
||||
assembly so it can encode type names properly.
|
||||
|
||||
2004-05-25 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* MethodBuilder.cs: Now use FastNewGuidArray to create new random
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace System.Reflection.Emit {
|
||||
}
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
static extern byte[] GetBlob(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues);
|
||||
static extern byte[] GetBlob(Assembly asmb, ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues);
|
||||
|
||||
internal CustomAttributeBuilder( ConstructorInfo con, byte[] cdata) {
|
||||
ctor = con;
|
||||
@@ -138,7 +138,7 @@ namespace System.Reflection.Emit {
|
||||
i ++;
|
||||
}
|
||||
|
||||
data = GetBlob (con, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues);
|
||||
data = GetBlob (atype.Assembly, con, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues);
|
||||
}
|
||||
|
||||
/* helper methods */
|
||||
|
||||
@@ -1284,12 +1284,6 @@ namespace System.Reflection.Emit {
|
||||
return base.IsAssignableFrom (c);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override bool IsInstanceOfType (object o)
|
||||
{
|
||||
return base.IsInstanceOfType (o);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override bool IsSubclassOf (Type c)
|
||||
{
|
||||
|
||||
@@ -399,8 +399,12 @@ namespace System
|
||||
if (assemblyRef == null)
|
||||
throw new ArgumentNullException ("assemblyRef");
|
||||
|
||||
if (assemblyRef.Name == null || assemblyRef.Name.Length == 0)
|
||||
throw new ArgumentException (Locale.GetText ("assemblyRef.Name cannot be empty."), "assemblyRef");
|
||||
if (assemblyRef.Name == null || assemblyRef.Name.Length == 0) {
|
||||
if (assemblyRef.CodeBase != null)
|
||||
return Assembly.LoadFrom (assemblyRef.CodeBase, assemblySecurity);
|
||||
else
|
||||
throw new ArgumentException (Locale.GetText ("assemblyRef.Name cannot be empty."), "assemblyRef");
|
||||
}
|
||||
|
||||
return LoadAssembly (assemblyRef.FullName, assemblySecurity);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
2004-05-28 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* Convert.cs: Fixed integer parsing for special cases (0x, 0X for base
|
||||
16), non-base 10 negative numbers ... see new unit tests. Fixed the
|
||||
case when we parse Int64.MinValue (positive doesn't fit a signed long).
|
||||
|
||||
2004-05-28 Jackson Harper <[email protected]>
|
||||
|
||||
* Environment.cs: Increment version number.
|
||||
|
||||
2004-05-28 Zoltan Varga <[email protected]>
|
||||
|
||||
* AppDomain.cs (Load): Try loading from assemblyRef.CodeBase if exists.
|
||||
Fixes #59189.
|
||||
|
||||
2004-05-28 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* DateTime.cs : I reverted my fix by accident :(
|
||||
|
||||
@@ -1031,10 +1031,17 @@ namespace System {
|
||||
return Int16.Parse (value, provider);
|
||||
}
|
||||
|
||||
|
||||
public static short ToInt16 (string value, int fromBase)
|
||||
{
|
||||
return Convert.ToInt16 (ConvertFromBase (value, fromBase, false));
|
||||
{
|
||||
int result = ConvertFromBase (value, fromBase, false);
|
||||
if (fromBase != 10) {
|
||||
// note: no sign are available to detect negatives
|
||||
if (result > Int16.MaxValue) {
|
||||
// return negative 2's complement
|
||||
return Convert.ToInt16 (-(65536 - result));
|
||||
}
|
||||
}
|
||||
return Convert.ToInt16 (result);
|
||||
}
|
||||
|
||||
[CLSCompliant (false)]
|
||||
@@ -1307,10 +1314,7 @@ namespace System {
|
||||
}
|
||||
|
||||
public static long ToInt64 (string value, int fromBase)
|
||||
{
|
||||
if (NotValidBase (fromBase))
|
||||
throw new ArgumentException ("fromBase is not valid.");
|
||||
|
||||
{
|
||||
return ConvertFromBase64 (value, fromBase, false);
|
||||
}
|
||||
|
||||
@@ -1472,15 +1476,15 @@ namespace System {
|
||||
[CLSCompliant (false)]
|
||||
public static sbyte ToSByte (string value, int fromBase)
|
||||
{
|
||||
int retVal = ConvertFromBase (value, fromBase, false);
|
||||
|
||||
if (retVal == 255)
|
||||
return (sbyte)-1;
|
||||
|
||||
if (retVal < (int) SByte.MinValue || retVal > (int) SByte.MaxValue)
|
||||
throw new OverflowException ();
|
||||
else
|
||||
return (sbyte) retVal;
|
||||
int result = ConvertFromBase (value, fromBase, false);
|
||||
if (fromBase != 10) {
|
||||
// note: no sign are available to detect negatives
|
||||
if (result > SByte.MaxValue) {
|
||||
// return negative 2's complement
|
||||
return Convert.ToSByte (-(256 - result));
|
||||
}
|
||||
}
|
||||
return Convert.ToSByte (result);
|
||||
}
|
||||
|
||||
[CLSCompliant (false)]
|
||||
@@ -2384,9 +2388,15 @@ namespace System {
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
// 0x00 or 0X00
|
||||
if ((value[i] == '0') && ((value [i+1] == 'x') || (value [i+1] == 'X'))) {
|
||||
i+=2;
|
||||
if (len >= i+2) {
|
||||
// 0x00 or 0X00
|
||||
if ((value[i] == '0') && ((value [i+1] == 'x') || (value [i+1] == 'X'))) {
|
||||
i+=2;
|
||||
}
|
||||
if (len == i) {
|
||||
throw new OverflowException (
|
||||
Locale.GetText ("Missing number after prefix"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2431,33 +2441,43 @@ namespace System {
|
||||
{
|
||||
if (NotValidBase (fromBase))
|
||||
throw new ArgumentException ("fromBase is not valid.");
|
||||
if (value == null)
|
||||
return 0;
|
||||
|
||||
int chars = 0;
|
||||
int digitValue;
|
||||
long result = 0;
|
||||
int digitValue = -1;
|
||||
uint Base = (uint) fromBase;
|
||||
ulong result = 0;
|
||||
bool negative = false;
|
||||
|
||||
foreach (char c in value) {
|
||||
if (Char.IsNumber (c))
|
||||
digitValue = c - '0';
|
||||
else if (Char.IsLetter (c))
|
||||
digitValue = Char.ToLowerInvariant (c) - 'a' + 10;
|
||||
digitValue = Char.ToLowerInvariant (c) - 'a' + 10;
|
||||
else if ((c == '-') && (!unsigned)) {
|
||||
if (fromBase != 10)
|
||||
throw new ArgumentException ("Negative are valid only for base 10");
|
||||
negative = true;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
throw new FormatException ("This is an invalid string: " + value);
|
||||
|
||||
if (digitValue >= fromBase)
|
||||
throw new FormatException ("the digits are invalid.");
|
||||
|
||||
result = (fromBase) * result + digitValue;
|
||||
result = (ulong) (Base * result + (uint)digitValue);
|
||||
chars ++;
|
||||
}
|
||||
|
||||
if (chars == 0)
|
||||
throw new FormatException ("Could not find any digits.");
|
||||
|
||||
if (result > Int64.MaxValue || result < Int64.MinValue)
|
||||
throw new OverflowException ("There is an overflow.");
|
||||
|
||||
return result;
|
||||
|
||||
if (negative)
|
||||
return -1 * (long) result;
|
||||
else
|
||||
return (long) result;
|
||||
}
|
||||
|
||||
private static string ConvertToBase (int value, int toBase)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace System
|
||||
* Changes which are already detected at runtime, like the addition
|
||||
* of icalls, do not require an increment.
|
||||
*/
|
||||
private const int mono_corlib_version = 20;
|
||||
private const int mono_corlib_version = 21;
|
||||
|
||||
private Environment ()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
2004-05-28 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* ConvertTest.cs: Removed extra 0 from ToInt16_MinValue. Added overflow
|
||||
testing for integer types convertion.
|
||||
testing for integer types convertion. Added new tests for pasring
|
||||
MinValue and MaxValue of integer types in all supported bases. Added
|
||||
case for a prefixed hexadecimal without a number.
|
||||
|
||||
2004-05-27 Sebastien Pouliot <[email protected]>
|
||||
|
||||
|
||||
@@ -2983,6 +2983,15 @@ namespace MonoTests.System {
|
||||
AssertEquals ("0XfF", 255, Convert.ToByte ("0XfF", 16));
|
||||
AssertEquals ("0XFf", 255, Convert.ToByte ("0XFf", 16));
|
||||
AssertEquals ("0XFF", 255, Convert.ToByte ("0XFF", 16));
|
||||
|
||||
AssertEquals ("0x0", Byte.MinValue, Convert.ToByte ("0x0", 16));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (FormatException))]
|
||||
public void ToByte_BadHexPrefix ()
|
||||
{
|
||||
Convert.ToByte ("0x", 16);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -3097,6 +3106,100 @@ namespace MonoTests.System {
|
||||
Convert.ToUInt64 ("-0", null);
|
||||
}
|
||||
|
||||
// min/max unsigned
|
||||
|
||||
[Test]
|
||||
public void ToByte_MaxValue ()
|
||||
{
|
||||
AssertEquals ("ff,16", Byte.MaxValue, Convert.ToByte ("ff", 16));
|
||||
AssertEquals ("255,10", Byte.MaxValue, Convert.ToByte ("255", 10));
|
||||
AssertEquals ("377,8", Byte.MaxValue, Convert.ToByte ("377", 8));
|
||||
AssertEquals ("11111111,2", Byte.MaxValue, Convert.ToByte ("11111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToByte_MinValue ()
|
||||
{
|
||||
AssertEquals ("0,16", Byte.MinValue, Convert.ToByte ("0", 16));
|
||||
AssertEquals ("0,10", Byte.MinValue, Convert.ToByte ("0", 10));
|
||||
AssertEquals ("0,8", Byte.MinValue, Convert.ToByte ("0", 8));
|
||||
AssertEquals ("0,2", Byte.MinValue, Convert.ToByte ("0", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUInt16_MaxValue ()
|
||||
{
|
||||
AssertEquals ("ffff,16", UInt16.MaxValue, Convert.ToUInt16 ("ffff", 16));
|
||||
AssertEquals ("65535,10", UInt16.MaxValue, Convert.ToUInt16 ("65535", 10));
|
||||
AssertEquals ("177777,8", UInt16.MaxValue, Convert.ToUInt16 ("177777", 8));
|
||||
AssertEquals ("1111111111111111,2", UInt16.MaxValue, Convert.ToUInt16 ("1111111111111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUInt16_MinValue ()
|
||||
{
|
||||
AssertEquals ("0,16", UInt16.MinValue, Convert.ToUInt16 ("0", 16));
|
||||
AssertEquals ("0,10", UInt16.MinValue, Convert.ToUInt16 ("0", 10));
|
||||
AssertEquals ("0,8", UInt16.MinValue, Convert.ToUInt16 ("0", 8));
|
||||
AssertEquals ("0,2", UInt16.MinValue, Convert.ToUInt16 ("0", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUInt32_MaxValue ()
|
||||
{
|
||||
AssertEquals ("ffffffff,16", UInt32.MaxValue, Convert.ToUInt32 ("ffffffff", 16));
|
||||
AssertEquals ("4294967295,10", UInt32.MaxValue, Convert.ToUInt32 ("4294967295", 10));
|
||||
AssertEquals ("37777777777,8", UInt32.MaxValue, Convert.ToUInt32 ("37777777777", 8));
|
||||
AssertEquals ("11111111111111111111111111111111,2", UInt32.MaxValue, Convert.ToUInt32 ("11111111111111111111111111111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUInt32_MinValue ()
|
||||
{
|
||||
AssertEquals ("0,16", UInt32.MinValue, Convert.ToUInt32 ("0", 16));
|
||||
AssertEquals ("0,10", UInt32.MinValue, Convert.ToUInt32 ("0", 10));
|
||||
AssertEquals ("0,8", UInt32.MinValue, Convert.ToUInt32 ("0", 8));
|
||||
AssertEquals ("0,2", UInt32.MinValue, Convert.ToUInt32 ("0", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUInt64_MaxValue ()
|
||||
{
|
||||
AssertEquals ("ffffffffffffffff,16", UInt64.MaxValue, Convert.ToUInt64 ("ffffffffffffffff", 16));
|
||||
AssertEquals ("18446744073709551615,10", UInt64.MaxValue, Convert.ToUInt64 ("18446744073709551615", 10));
|
||||
AssertEquals ("1777777777777777777777,8", UInt64.MaxValue, Convert.ToUInt64 ("1777777777777777777777", 8));
|
||||
AssertEquals ("1111111111111111111111111111111111111111111111111111111111111111,2", UInt64.MaxValue, Convert.ToUInt64 ("1111111111111111111111111111111111111111111111111111111111111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUInt64_MinValue ()
|
||||
{
|
||||
AssertEquals ("0,16", UInt64.MinValue, Convert.ToUInt64 ("0", 16));
|
||||
AssertEquals ("0,10", UInt64.MinValue, Convert.ToUInt64 ("0", 10));
|
||||
AssertEquals ("0,8", UInt64.MinValue, Convert.ToUInt64 ("0", 8));
|
||||
AssertEquals ("0,2", UInt64.MinValue, Convert.ToUInt64 ("0", 2));
|
||||
}
|
||||
|
||||
// min/max signed
|
||||
|
||||
[Test]
|
||||
public void ToSByte_MaxValue ()
|
||||
{
|
||||
AssertEquals ("7F,16", SByte.MaxValue, Convert.ToSByte ("7f", 16));
|
||||
AssertEquals ("127,10", SByte.MaxValue, Convert.ToSByte ("127", 10));
|
||||
AssertEquals ("177,8", SByte.MaxValue, Convert.ToSByte ("177", 8));
|
||||
AssertEquals ("1111111,2", SByte.MaxValue, Convert.ToSByte ("1111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToSByte_MinValue ()
|
||||
{
|
||||
AssertEquals ("80,16", SByte.MinValue, Convert.ToSByte ("80", 16));
|
||||
AssertEquals ("-128,10", SByte.MinValue, Convert.ToSByte ("-128", 10));
|
||||
AssertEquals ("200,8", SByte.MinValue, Convert.ToSByte ("200", 8));
|
||||
AssertEquals ("10000000,2", SByte.MinValue, Convert.ToSByte ("10000000", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToInt16_MaxValue ()
|
||||
{
|
||||
@@ -3115,6 +3218,42 @@ namespace MonoTests.System {
|
||||
AssertEquals ("1000000000000000,2", Int16.MinValue, Convert.ToInt16 ("1000000000000000", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToInt32_MaxValue ()
|
||||
{
|
||||
AssertEquals ("7fffffff,16", Int32.MaxValue, Convert.ToInt32 ("7fffffff", 16));
|
||||
AssertEquals ("2147483647,10", Int32.MaxValue, Convert.ToInt32 ("2147483647", 10));
|
||||
AssertEquals ("17777777777,8", Int32.MaxValue, Convert.ToInt32 ("17777777777", 8));
|
||||
AssertEquals ("1111111111111111111111111111111,2", Int32.MaxValue, Convert.ToInt32 ("1111111111111111111111111111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToInt32_MinValue ()
|
||||
{
|
||||
AssertEquals ("80000000,16", Int32.MinValue, Convert.ToInt32 ("80000000", 16));
|
||||
AssertEquals ("-2147483648,10", Int32.MinValue, Convert.ToInt32 ("-2147483648", 10));
|
||||
AssertEquals ("20000000000,8", Int32.MinValue, Convert.ToInt32 ("20000000000", 8));
|
||||
AssertEquals ("10000000000000000000000000000000,2", Int32.MinValue, Convert.ToInt32 ("10000000000000000000000000000000", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToInt64_MaxValue ()
|
||||
{
|
||||
AssertEquals ("7fffffffffffffff,16", Int64.MaxValue, Convert.ToInt64 ("7fffffffffffffff", 16));
|
||||
AssertEquals ("9223372036854775807,10", Int64.MaxValue, Convert.ToInt64 ("9223372036854775807", 10));
|
||||
AssertEquals ("777777777777777777777,8", Int64.MaxValue, Convert.ToInt64 ("777777777777777777777", 8));
|
||||
AssertEquals ("111111111111111111111111111111111111111111111111111111111111111,2", Int64.MaxValue, Convert.ToInt64 ("111111111111111111111111111111111111111111111111111111111111111", 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToInt64_MinValue ()
|
||||
{
|
||||
AssertEquals ("8000000000000000,16", Int64.MinValue, Convert.ToInt64 ("8000000000000000", 16));
|
||||
AssertEquals ("-9223372036854775808,10", Int64.MinValue, Convert.ToInt64 ("-9223372036854775808", 10));
|
||||
AssertEquals ("1000000000000000000000,8", Int64.MinValue, Convert.ToInt64 ("1000000000000000000000", 8));
|
||||
AssertEquals ("1000000000000000000000000000000000000000000000000000000000000000,2", Int64.MinValue, Convert.ToInt64 ("1000000000000000000000000000000000000000000000000000000000000000", 2));
|
||||
}
|
||||
|
||||
// signed types
|
||||
|
||||
[Test]
|
||||
@@ -3246,5 +3385,29 @@ namespace MonoTests.System {
|
||||
string min_minus1 = "-1";
|
||||
Convert.ToUInt64 (min_minus1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void To_NullString ()
|
||||
{
|
||||
string s = null;
|
||||
// signed
|
||||
AssertEquals ("ToSByte", 0, Convert.ToSByte (s));
|
||||
AssertEquals ("ToSByte+base", 0, Convert.ToSByte (s, 10));
|
||||
AssertEquals ("ToInt16", 0, Convert.ToInt16 (s));
|
||||
AssertEquals ("ToInt16+base", 0, Convert.ToInt16 (s, 10));
|
||||
AssertEquals ("ToInt32", 0, Convert.ToInt32 (s));
|
||||
AssertEquals ("ToInt32+base", 0, Convert.ToInt32 (s, 10));
|
||||
AssertEquals ("ToInt64", 0, Convert.ToInt64 (s));
|
||||
AssertEquals ("ToInt64+base", 0, Convert.ToInt64 (s, 10));
|
||||
// unsigned
|
||||
AssertEquals ("ToByte", 0, Convert.ToByte (s));
|
||||
AssertEquals ("ToByte+base", 0, Convert.ToByte (s, 10));
|
||||
AssertEquals ("ToUInt16", 0, Convert.ToUInt16 (s));
|
||||
AssertEquals ("ToUInt16+base", 0, Convert.ToUInt16 (s, 10));
|
||||
AssertEquals ("ToUInt32", 0, Convert.ToUInt32 (s));
|
||||
AssertEquals ("ToUInt32+base", 0, Convert.ToUInt32 (s, 10));
|
||||
AssertEquals ("ToUInt64", 0, Convert.ToUInt64 (s));
|
||||
AssertEquals ("ToUInt64+base", 0, Convert.ToUInt64 (s, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
2004-05-28 Cesar Lopez Nataren <[email protected]>
|
||||
|
||||
* switch.js: added clause after default
|
||||
|
||||
2004-05-24 Cesar Lopez Nataren <[email protected]>
|
||||
* Added switch.js
|
||||
|
||||
|
||||
@@ -13,4 +13,6 @@ case 1:
|
||||
default:
|
||||
print ("blah this is default");
|
||||
print ("this is default too ;-)");
|
||||
case "afterDefault":
|
||||
print ("matched after default");
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
[assembly: AssemblyCompany("Motus Technologies, Novell")]
|
||||
[assembly: AssemblyProduct("Mono Security Tools")]
|
||||
[assembly: AssemblyCopyright("Copyright 2002, 2003 Motus Technologies. Copyright 2004 Novell. BSD licensed.")]
|
||||
[assembly: AssemblyVersion("0.91.99")]
|
||||
[assembly: AssemblyVersion("0.93.0.0")]
|
||||
//[assembly: AssemblyConfiguration("")]
|
||||
//[assembly: AssemblyTrademark("")]
|
||||
//[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2004-05-28 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* AssemblyInfo.cs: Update version number for beta 2.
|
||||
|
||||
2004-04-27 Jackson Harper <[email protected]>
|
||||
|
||||
* sn.cs: Attempt to load the strongnames.config file from the GAC
|
||||
|
||||
@@ -1,3 +1,70 @@
|
||||
2004-05-28 Jackson Harper <[email protected]>
|
||||
|
||||
* reflection.c: The modified type encoding was causing build
|
||||
problems. Reverted for now.
|
||||
|
||||
2004-05-28 Jackson Harper <[email protected]>
|
||||
|
||||
* reflection.c/h: Take an assembly ref so that we dont create
|
||||
fully qualified names when encoding types in the same assembly as
|
||||
the custom attribute being emitted.
|
||||
* appdomain.c: Increment version number.
|
||||
|
||||
2004-05-26 Duncan Mak <[email protected]>
|
||||
|
||||
* icall.c
|
||||
(ves_icall_System_Reflection_Assembly_GetReferencedAssemblies):
|
||||
Set the full version number (major, minor, build, revision).
|
||||
|
||||
2004-05-28 Vladimir Vukicevic <[email protected]>
|
||||
|
||||
* marshal.c (emit_struct_conv): increment src/dst after blit
|
||||
(mono_marshal_get_managed_wrapper,
|
||||
mono_marshal_get_native_wrapper): make sure we have marshalling
|
||||
info before marshalling params (info computation affects
|
||||
blittable)
|
||||
|
||||
* class.c (class_compute_field_layout): correctly deal with
|
||||
blittable
|
||||
(mono_class_layout_fields): Don't do gc_aware_layout for AUTO
|
||||
value types (as per what windows dows by default)
|
||||
(mono_class_setup_mono_type): System.ValueType is blittable
|
||||
(mono_ptr_class_get, mono_fnptr_class_get): Pointer classes are
|
||||
blittable
|
||||
|
||||
* marshal.c (mono_marshal_load_type_info): flag types as
|
||||
non-blittable if the native layout doesn't match the managed
|
||||
layout
|
||||
|
||||
2004-05-28 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* appdomain.c: don't add stuff in the private search path that is
|
||||
above the application base. If application base is not set, there's
|
||||
no private search path.
|
||||
|
||||
2004-05-28 Zoltan Varga <[email protected]>
|
||||
|
||||
* marshal.c (mono_marshal_get_managed_wrapper): Add proper support for
|
||||
byref struct arguments in native->managed marshalling.
|
||||
|
||||
2004-05-28 Patrik Torstensson <[email protected]>
|
||||
|
||||
* marshal.c (mono_marshal_get_runtime_invoke): correctly
|
||||
cache methods using signature (special case for methods
|
||||
that are value type or string class)
|
||||
|
||||
* image.c (mono_image_close): clean up allocated GSList's
|
||||
in runtime_invoke_cache.
|
||||
|
||||
2004-05-28 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* mono-config.c: set the correct path for mono_cfg_dir on windows when
|
||||
there's no MONO_CFG_DIR environment variable defined.
|
||||
|
||||
2004-05-28 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* threads.c: windows version must be >= 0x0500 to include OpenThread.
|
||||
|
||||
2004-05-28 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* threadpool.c: Really wait for 500ms after the async call, even if the wait
|
||||
|
||||
+89
-35
@@ -26,7 +26,7 @@
|
||||
#include <mono/metadata/marshal.h>
|
||||
#include <mono/utils/mono-uri.h>
|
||||
|
||||
#define MONO_CORLIB_VERSION 20
|
||||
#define MONO_CORLIB_VERSION 21
|
||||
|
||||
CRITICAL_SECTION mono_delegate_section;
|
||||
|
||||
@@ -516,6 +516,48 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
|
||||
mono_runtime_invoke (method, domain->domain, params, NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
reduce_path (const gchar *dirname)
|
||||
{
|
||||
gchar **parts;
|
||||
gchar *part;
|
||||
GList *list, *tmp;
|
||||
GString *result;
|
||||
gchar *res;
|
||||
gint i;
|
||||
|
||||
parts = g_strsplit (dirname, G_DIR_SEPARATOR_S, 0);
|
||||
list = NULL;
|
||||
for (i = 0; (part = parts [i]) != NULL; i++) {
|
||||
if (!strcmp (part, "."))
|
||||
continue;
|
||||
|
||||
if (!strcmp (part, "..")) {
|
||||
if (list && list->next) /* Don't remove root */
|
||||
list = g_list_delete_link (list, list);
|
||||
} else {
|
||||
list = g_list_prepend (list, part);
|
||||
}
|
||||
}
|
||||
|
||||
result = g_string_new ("");
|
||||
list = g_list_reverse (list);
|
||||
|
||||
for (tmp = list; tmp; tmp = tmp->next) {
|
||||
gchar *data = (gchar *) tmp->data;
|
||||
|
||||
if (data && *data)
|
||||
g_string_append_printf (result, "%c%s", G_DIR_SEPARATOR,
|
||||
(char *) tmp->data);
|
||||
}
|
||||
|
||||
res = result->str;
|
||||
g_string_free (result, FALSE);
|
||||
g_list_free (list);
|
||||
g_strfreev (parts);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
set_domain_search_path (MonoDomain *domain)
|
||||
{
|
||||
@@ -526,14 +568,16 @@ set_domain_search_path (MonoDomain *domain)
|
||||
gint npaths = 0;
|
||||
gchar **pvt_split = NULL;
|
||||
GError *error = NULL;
|
||||
gint appbaselen = -1;
|
||||
|
||||
if ((domain->search_path != NULL) && !domain->setup->path_changed)
|
||||
return;
|
||||
|
||||
setup = domain->setup;
|
||||
if (setup->application_base)
|
||||
npaths++;
|
||||
if (!setup->application_base)
|
||||
return; /* Must set application base to get private path working */
|
||||
|
||||
npaths++;
|
||||
if (setup->private_bin_path) {
|
||||
utf8 = mono_string_to_utf8 (setup->private_bin_path);
|
||||
pvt_split = g_strsplit (utf8, G_SEARCHPATH_SEPARATOR_S, 1000);
|
||||
@@ -559,49 +603,59 @@ set_domain_search_path (MonoDomain *domain)
|
||||
|
||||
domain->search_path = tmp = g_malloc ((npaths + 1) * sizeof (gchar *));
|
||||
tmp [npaths] = NULL;
|
||||
if (setup->application_base) {
|
||||
*tmp = mono_string_to_utf8 (setup->application_base);
|
||||
|
||||
/* FIXME: is this needed? */
|
||||
if (strncmp (*tmp, "file://", 7) == 0) {
|
||||
gchar *file = *tmp;
|
||||
gchar *uri = *tmp;
|
||||
gchar *tmpuri;
|
||||
*tmp = mono_string_to_utf8 (setup->application_base);
|
||||
|
||||
if (uri [7] != '/')
|
||||
uri = g_strdup_printf ("file:///%s", uri + 7);
|
||||
/* FIXME: is this needed? */
|
||||
if (strncmp (*tmp, "file://", 7) == 0) {
|
||||
gchar *file = *tmp;
|
||||
gchar *uri = *tmp;
|
||||
gchar *tmpuri;
|
||||
|
||||
tmpuri = uri;
|
||||
uri = mono_escape_uri_string (tmpuri);
|
||||
*tmp = g_filename_from_uri (uri, NULL, &error);
|
||||
g_free (uri);
|
||||
if (uri [7] != '/')
|
||||
uri = g_strdup_printf ("file:///%s", uri + 7);
|
||||
|
||||
if (tmpuri != file)
|
||||
g_free (tmpuri);
|
||||
tmpuri = uri;
|
||||
uri = mono_escape_uri_string (tmpuri);
|
||||
*tmp = g_filename_from_uri (uri, NULL, &error);
|
||||
g_free (uri);
|
||||
|
||||
if (error != NULL) {
|
||||
g_warning ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
*tmp = file;
|
||||
} else {
|
||||
g_free (file);
|
||||
}
|
||||
if (tmpuri != file)
|
||||
g_free (tmpuri);
|
||||
|
||||
if (error != NULL) {
|
||||
g_warning ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
*tmp = file;
|
||||
} else {
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
} else {
|
||||
*tmp = g_strdup ("");
|
||||
}
|
||||
|
||||
for (i = 1; pvt_split && i < npaths; i++) {
|
||||
if (*tmp [0] == '\0' || g_path_is_absolute (pvt_split [i - 1])) {
|
||||
tmp [i] = g_strdup (pvt_split [i - 1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp [i] = g_build_filename (tmp [0], pvt_split [i - 1], NULL);
|
||||
if (strchr (tmp [i], '.')) {
|
||||
gchar *reduced;
|
||||
gchar *freeme;
|
||||
|
||||
reduced = reduce_path (tmp [i]);
|
||||
if (appbaselen == -1)
|
||||
appbaselen = strlen (tmp [0]);
|
||||
|
||||
if (strncmp (tmp [0], reduced, appbaselen)) {
|
||||
g_free (reduced);
|
||||
g_free (tmp [i]);
|
||||
tmp [i] = g_strdup ("");
|
||||
continue;
|
||||
}
|
||||
|
||||
freeme = tmp [i];
|
||||
tmp [i] = reduced;
|
||||
g_free (freeme);
|
||||
}
|
||||
}
|
||||
|
||||
if (setup->private_bin_path_probe != NULL && setup->application_base) {
|
||||
if (setup->private_bin_path_probe != NULL) {
|
||||
g_free (tmp [0]);
|
||||
tmp [0] = g_strdup ("");
|
||||
}
|
||||
@@ -695,7 +749,7 @@ mono_domain_assembly_preload (MonoAssemblyName *aname,
|
||||
if (result == NULL && assemblies_path && assemblies_path [0] != NULL) {
|
||||
result = real_load (assemblies_path, aname->culture, aname->name);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+12
-3
@@ -441,7 +441,7 @@ class_compute_field_layout (MonoClass *class)
|
||||
class_compute_field_layout (class->parent);
|
||||
class->instance_size += class->parent->instance_size;
|
||||
class->min_align = class->parent->min_align;
|
||||
blittable = class->blittable;
|
||||
blittable = class->parent->blittable;
|
||||
} else {
|
||||
class->instance_size = sizeof (MonoObject);
|
||||
class->min_align = 1;
|
||||
@@ -494,7 +494,8 @@ class_compute_field_layout (MonoClass *class)
|
||||
|
||||
field->parent = class;
|
||||
|
||||
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
|
||||
/* Only do these checks if we still think this type is blittable */
|
||||
if (blittable && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
|
||||
if (field->type->byref) {
|
||||
blittable = FALSE;
|
||||
} else {
|
||||
@@ -503,6 +504,7 @@ class_compute_field_layout (MonoClass *class)
|
||||
blittable = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) {
|
||||
mono_metadata_field_info (m, idx, &field->offset, NULL, NULL);
|
||||
if (field->offset == (guint32)-1 && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
|
||||
@@ -560,10 +562,13 @@ mono_class_layout_fields (MonoClass *class)
|
||||
* performance.
|
||||
* Requires that all classes whose layout is known to native code be annotated
|
||||
* with [StructLayout (LayoutKind.Sequential)]
|
||||
* Value types have gc_aware_layout disabled by default, as per
|
||||
* what the default is for other runtimes.
|
||||
*/
|
||||
/* corlib is missing [StructLayout] directives in many places */
|
||||
if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
|
||||
if (class->image != mono_defaults.corlib)
|
||||
if (class->image != mono_defaults.corlib &&
|
||||
class->byval_arg.type != MONO_TYPE_VALUETYPE)
|
||||
gc_aware_layout = TRUE;
|
||||
}
|
||||
|
||||
@@ -1536,6 +1541,7 @@ mono_class_setup_mono_type (MonoClass *class)
|
||||
* do not set the valuetype bit for System.ValueType.
|
||||
* class->valuetype = 1;
|
||||
*/
|
||||
class->blittable = TRUE;
|
||||
} else if (!strcmp (name, "Enum")) {
|
||||
/*
|
||||
* do not set the valuetype bit for System.Enum.
|
||||
@@ -1969,6 +1975,7 @@ mono_ptr_class_get (MonoType *type)
|
||||
result->instance_size = sizeof (gpointer);
|
||||
result->cast_class = result->element_class = el_class;
|
||||
result->enum_basetype = &result->element_class->byval_arg;
|
||||
result->blittable = TRUE;
|
||||
|
||||
result->this_arg.type = result->byval_arg.type = MONO_TYPE_PTR;
|
||||
result->this_arg.data.type = result->byval_arg.data.type = result->enum_basetype;
|
||||
@@ -2009,11 +2016,13 @@ mono_fnptr_class_get (MonoMethodSignature *sig)
|
||||
/* Can pointers get boxed? */
|
||||
result->instance_size = sizeof (gpointer);
|
||||
result->cast_class = result->element_class = result;
|
||||
result->blittable = TRUE;
|
||||
|
||||
result->this_arg.type = result->byval_arg.type = MONO_TYPE_FNPTR;
|
||||
result->this_arg.data.method = result->byval_arg.data.method = sig;
|
||||
result->this_arg.byref = TRUE;
|
||||
result->enum_basetype = &result->element_class->byval_arg;
|
||||
result->blittable = TRUE;
|
||||
|
||||
mono_class_setup_supertypes (result);
|
||||
|
||||
|
||||
@@ -3159,7 +3159,11 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
|
||||
domain, System_Reflection_AssemblyName);
|
||||
|
||||
aname->name = mono_string_new (domain, assem->aname.name);
|
||||
|
||||
aname->major = assem->aname.major;
|
||||
aname->minor = assem->aname.minor;
|
||||
aname->build = assem->aname.build;
|
||||
aname->revision = assem->aname.revision;
|
||||
|
||||
absolute = g_build_filename (assem->basedir, assem->image->module_name, NULL);
|
||||
codebase = g_filename_to_uri (absolute, NULL, NULL);
|
||||
|
||||
@@ -907,6 +907,12 @@ free_hash_table (gpointer key, gpointer val, gpointer user_data)
|
||||
g_hash_table_destroy ((GHashTable*)val);
|
||||
}
|
||||
|
||||
static void
|
||||
free_gs_list (gpointer key, gpointer val, gpointer user_data)
|
||||
{
|
||||
g_slist_free ((GSList*)val);
|
||||
}
|
||||
|
||||
/**
|
||||
* mono_image_close:
|
||||
* @image: The image file we wish to add a reference to
|
||||
@@ -970,6 +976,7 @@ mono_image_close (MonoImage *image)
|
||||
g_hash_table_destroy (image->delegate_end_invoke_cache);
|
||||
g_hash_table_destroy (image->delegate_invoke_cache);
|
||||
g_hash_table_destroy (image->remoting_invoke_cache);
|
||||
g_hash_table_foreach (image->runtime_invoke_cache, free_gs_list, NULL);
|
||||
g_hash_table_destroy (image->runtime_invoke_cache);
|
||||
g_hash_table_destroy (image->typespec_cache);
|
||||
g_hash_table_destroy (image->generic_inst_cache);
|
||||
|
||||
+132
-11
@@ -44,6 +44,9 @@ struct _MonoMethodBuilder {
|
||||
static void
|
||||
emit_struct_conv (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_object);
|
||||
|
||||
gint
|
||||
mono_marshal_runtime_glist_find_klass (gconstpointer a, gconstpointer b);
|
||||
|
||||
static MonoMethod *
|
||||
mono_find_method_by_name (MonoClass *klass, const char *name, int param_count)
|
||||
{
|
||||
@@ -951,11 +954,16 @@ emit_struct_conv (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_object)
|
||||
return;
|
||||
|
||||
if (klass->blittable) {
|
||||
int msize = mono_class_value_size (klass, NULL);
|
||||
g_assert (msize == info->native_size);
|
||||
mono_mb_emit_byte (mb, CEE_LDLOC_1);
|
||||
mono_mb_emit_byte (mb, CEE_LDLOC_0);
|
||||
mono_mb_emit_icon (mb, mono_class_value_size (klass, NULL));
|
||||
mono_mb_emit_icon (mb, msize);
|
||||
mono_mb_emit_byte (mb, CEE_PREFIX1);
|
||||
mono_mb_emit_byte (mb, CEE_CPBLK);
|
||||
|
||||
mono_mb_emit_add_to_local (mb, 0, msize);
|
||||
mono_mb_emit_add_to_local (mb, 1, msize);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1849,6 +1857,11 @@ mono_marshal_get_delegate_invoke (MonoMethod *method)
|
||||
return res;
|
||||
}
|
||||
|
||||
gint mono_marshal_runtime_glist_find_klass (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return !(((MonoMethod *)a)->klass == ((MonoMethod *)b)->klass);
|
||||
}
|
||||
|
||||
/*
|
||||
* generates IL code for the runtime invoke function
|
||||
* MonoObject *runtime_invoke (MonoObject *this, void **params, MonoObject **exc, void* method)
|
||||
@@ -1862,13 +1875,19 @@ mono_marshal_get_runtime_invoke (MonoMethod *method)
|
||||
MonoExceptionClause *clause;
|
||||
MonoMethodHeader *header;
|
||||
MonoMethodBuilder *mb;
|
||||
MonoMethod *res;
|
||||
GHashTable *cache;
|
||||
GHashTable *cache = NULL;
|
||||
MonoClass *target_klass;
|
||||
MonoMethod *res = NULL;
|
||||
GSList *list = NULL;
|
||||
GSList *item;
|
||||
static MonoString *string_dummy = NULL;
|
||||
int i, pos;
|
||||
char *name;
|
||||
gboolean list_lookup = FALSE;
|
||||
|
||||
g_assert (method);
|
||||
|
||||
target_klass = method->klass;
|
||||
|
||||
if (method->string_ctor) {
|
||||
static MonoMethodSignature *strsig = NULL;
|
||||
@@ -1878,12 +1897,33 @@ mono_marshal_get_runtime_invoke (MonoMethod *method)
|
||||
}
|
||||
|
||||
callsig = strsig;
|
||||
list_lookup = TRUE;
|
||||
} else
|
||||
callsig = method->signature;
|
||||
|
||||
if (method->signature->hasthis && method->klass->valuetype)
|
||||
list_lookup = TRUE;
|
||||
|
||||
cache = method->klass->image->runtime_invoke_cache;
|
||||
if ((res = mono_marshal_find_in_cache (cache, callsig)))
|
||||
return res;
|
||||
|
||||
/* from mono_marshal_find_in_cache */
|
||||
EnterCriticalSection (&marshal_mutex);
|
||||
list = g_hash_table_lookup (cache, callsig);
|
||||
LeaveCriticalSection (&marshal_mutex);
|
||||
|
||||
if (list) {
|
||||
if (!list_lookup)
|
||||
return (MonoMethod *)list->data;
|
||||
|
||||
/* lookup the wrapper for our class */
|
||||
item = g_slist_find_custom (list, method->klass, mono_marshal_runtime_glist_find_klass);
|
||||
if (item)
|
||||
return (MonoMethod *)item->data;
|
||||
}
|
||||
|
||||
if (!list_lookup)
|
||||
/* place runtime_invoke method in object class instead of random class */
|
||||
target_klass = mono_defaults.object_class;
|
||||
|
||||
/* to make it work with our special string constructors */
|
||||
if (!string_dummy)
|
||||
@@ -1900,7 +1940,7 @@ mono_marshal_get_runtime_invoke (MonoMethod *method)
|
||||
csig->params [3] = &mono_defaults.int_class->byval_arg;
|
||||
|
||||
name = mono_signature_to_name (callsig, "runtime_invoke");
|
||||
mb = mono_mb_new (method->klass, name, MONO_WRAPPER_RUNTIME_INVOKE);
|
||||
mb = mono_mb_new (target_klass, name, MONO_WRAPPER_RUNTIME_INVOKE);
|
||||
g_free (name);
|
||||
|
||||
/* allocate local 0 (object) tmp */
|
||||
@@ -2090,8 +2130,37 @@ handle_enum:
|
||||
mono_mb_patch_addr (mb, pos, mb->pos - (pos + 4));
|
||||
mono_mb_emit_ldloc (mb, 0);
|
||||
mono_mb_emit_byte (mb, CEE_RET);
|
||||
|
||||
res = mono_mb_create_and_cache (cache, callsig, mb, csig, sig->param_count + 16);
|
||||
|
||||
/* taken from mono_mb_create_and_cache */
|
||||
EnterCriticalSection (&marshal_mutex);
|
||||
|
||||
list = g_hash_table_lookup (cache, callsig);
|
||||
if (list) {
|
||||
/* Somebody may have created it before us */
|
||||
/* we use the list_lookup flag to be a bit smarter */
|
||||
if (list_lookup) {
|
||||
/* check if someone has created our wrapper, or just one with the same signature */
|
||||
item = g_slist_find_custom (list, method->klass, mono_marshal_runtime_glist_find_klass);
|
||||
if (item)
|
||||
res = (MonoMethod *) item->data;
|
||||
else /* we didn't find our wrapper */
|
||||
res = NULL;
|
||||
} else
|
||||
res = (MonoMethod *) list->data;
|
||||
}
|
||||
|
||||
if (!list || (list_lookup && list && !res)) {
|
||||
res = mono_mb_create_method (mb, csig, sig->param_count + 16);
|
||||
|
||||
/* we add the wrapper to a slist and put that into value */
|
||||
list = g_slist_append (list, res);
|
||||
g_hash_table_insert (cache, callsig, list);
|
||||
mono_g_hash_table_insert (wrapper_hash, res, callsig);
|
||||
}
|
||||
|
||||
LeaveCriticalSection (&marshal_mutex);
|
||||
/* end mono_mb_create_and_cache */
|
||||
|
||||
mono_mb_free (mb);
|
||||
|
||||
header = ((MonoMethodNormal *)res)->header;
|
||||
@@ -2191,6 +2260,9 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
|
||||
tmp_locals [i] = 0;
|
||||
|
||||
/* Ensure that we have marshalling info for this param */
|
||||
mono_marshal_load_type_info (mono_class_from_mono_type (t));
|
||||
|
||||
if (spec && spec->native == MONO_NATIVE_CUSTOM) {
|
||||
MonoType *mtype;
|
||||
MonoClass *mklass;
|
||||
@@ -2320,6 +2392,9 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
|
||||
tmp_locals [i] = mono_mb_add_local (mb, &klass->byval_arg);
|
||||
|
||||
if (t->attrs & PARAM_ATTRIBUTE_OUT)
|
||||
break;
|
||||
|
||||
if (t->byref)
|
||||
mono_mb_emit_ldarg (mb, i);
|
||||
else
|
||||
@@ -2336,7 +2411,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
mono_mb_emit_ldloc_addr (mb, tmp_locals [i]);
|
||||
mono_mb_emit_byte (mb, CEE_STLOC_1);
|
||||
|
||||
/* emit valuetype convnversion code code */
|
||||
/* emit valuetype conversion code */
|
||||
emit_struct_conv (mb, klass, TRUE);
|
||||
|
||||
if (t->byref)
|
||||
@@ -2455,6 +2530,9 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
emit_thread_interrupt_checkpoint (mb);
|
||||
mono_mb_emit_managed_call (mb, method, NULL);
|
||||
|
||||
/* Ensure that we have marshalling info for the return */
|
||||
mono_marshal_load_type_info (mono_class_from_mono_type (sig->ret));
|
||||
|
||||
if (!sig->ret->byref) {
|
||||
switch (sig->ret->type) {
|
||||
case MONO_TYPE_VOID:
|
||||
@@ -2562,7 +2640,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
MonoType *t = sig->params [i];
|
||||
|
||||
if (!t->byref)
|
||||
break;
|
||||
continue;
|
||||
|
||||
switch (t->type) {
|
||||
case MONO_TYPE_CLASS: {
|
||||
@@ -2577,7 +2655,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
mono_mb_emit_byte (mb, CEE_LDC_I4_0);
|
||||
mono_mb_emit_byte (mb, CEE_STIND_I);
|
||||
pos2 = mono_mb_emit_branch (mb, CEE_BR);
|
||||
|
||||
|
||||
mono_mb_patch_addr (mb, pos, mb->pos - (pos + 4));
|
||||
|
||||
/* Set src */
|
||||
@@ -2604,6 +2682,34 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoObject *this, MonoMars
|
||||
mono_mb_patch_addr (mb, pos2, mb->pos - (pos2 + 4));
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_VALUETYPE: {
|
||||
int pos2;
|
||||
|
||||
klass = t->data.klass;
|
||||
|
||||
if (((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) ||
|
||||
klass->blittable || klass->enumtype) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for null */
|
||||
mono_mb_emit_ldarg (mb, i);
|
||||
pos2 = mono_mb_emit_branch (mb, CEE_BRFALSE);
|
||||
|
||||
/* Set src */
|
||||
mono_mb_emit_ldloc_addr (mb, tmp_locals [i]);
|
||||
mono_mb_emit_byte (mb, CEE_STLOC_0);
|
||||
|
||||
/* Set dest */
|
||||
mono_mb_emit_ldarg (mb, i);
|
||||
mono_mb_emit_byte (mb, CEE_STLOC_1);
|
||||
|
||||
/* emit valuetype conversion code */
|
||||
emit_struct_conv (mb, klass, FALSE);
|
||||
|
||||
mono_mb_patch_addr (mb, pos2, mb->pos - (pos2 + 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3117,6 +3223,9 @@ mono_marshal_get_native_wrapper (MonoMethod *method)
|
||||
argnum = i + sig->hasthis;
|
||||
tmp_locals [i] = 0;
|
||||
|
||||
/* Ensure that we have marshalling info for this param */
|
||||
mono_marshal_load_type_info (mono_class_from_mono_type (t));
|
||||
|
||||
if (spec && spec->native == MONO_NATIVE_CUSTOM) {
|
||||
MonoType *mtype;
|
||||
MonoClass *mklass;
|
||||
@@ -3614,6 +3723,9 @@ mono_marshal_get_native_wrapper (MonoMethod *method)
|
||||
mono_mb_emit_native_call (mb, lasterr_sig, mono_marshal_set_last_error);
|
||||
}
|
||||
|
||||
/* Ensure that we have marshalling info for the return */
|
||||
mono_marshal_load_type_info (mono_class_from_mono_type (sig->ret));
|
||||
|
||||
/* convert the result */
|
||||
if (!sig->ret->byref) {
|
||||
MonoMarshalSpec *spec = mspecs [0];
|
||||
@@ -5307,6 +5419,15 @@ mono_marshal_load_type_info (MonoClass* klass)
|
||||
info->native_size &= ~(min_align - 1);
|
||||
}
|
||||
|
||||
/* Update the class's blittable info, if the layouts don't match */
|
||||
if (info->native_size != mono_class_value_size (klass, NULL))
|
||||
klass->blittable = FALSE;
|
||||
|
||||
/* If this is an array type, ensure that we have element info */
|
||||
if (klass->element_class) {
|
||||
mono_marshal_load_type_info (klass->element_class);
|
||||
}
|
||||
|
||||
return klass->marshal_info;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ static void
|
||||
mono_install_get_config_dir (void)
|
||||
{
|
||||
#ifdef PLATFORM_WIN32
|
||||
int i;
|
||||
gchar *prefix;
|
||||
#endif
|
||||
|
||||
mono_cfg_dir = g_getenv ("MONO_CFG_DIR");
|
||||
@@ -344,11 +344,9 @@ mono_install_get_config_dir (void)
|
||||
#ifndef PLATFORM_WIN32
|
||||
mono_cfg_dir = MONO_CFG_DIR;
|
||||
#else
|
||||
mono_cfg_dir = g_build_path (mono_assembly_getrootdir (), "etc", NULL);
|
||||
for (i = strlen (mono_cfg_dir) - 1; i >= 0; i--) {
|
||||
if (mono_cfg_dir [i] == '/')
|
||||
((char*) mono_cfg_dir) [i] = '\\';
|
||||
}
|
||||
prefix = g_path_get_dirname (mono_assembly_getrootdir ());
|
||||
mono_cfg_dir = g_build_filename (prefix, "etc", NULL);
|
||||
g_free (prefix);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6296,7 +6296,7 @@ get_field_name_and_type (MonoObject *field, char **name, MonoType **type)
|
||||
}
|
||||
|
||||
static void
|
||||
encode_cattr_value (char *buffer, char *p, char **retbuffer, char **retp, guint32 *buflen, MonoType *type, MonoObject *arg)
|
||||
encode_cattr_value (MonoAssembly *assembly, char *buffer, char *p, char **retbuffer, char **retp, guint32 *buflen, MonoType *type, MonoObject *arg)
|
||||
{
|
||||
char *argval;
|
||||
MonoTypeEnum simple_type;
|
||||
@@ -6412,7 +6412,7 @@ handle_type:
|
||||
*retbuffer = buffer;
|
||||
eclass = type->data.klass;
|
||||
for (i = 0; i < len; ++i) {
|
||||
encode_cattr_value (buffer, p, &buffer, &p, buflen, &eclass->byval_arg, mono_array_get ((MonoArray*)arg, MonoObject*, i));
|
||||
encode_cattr_value (assembly, buffer, p, &buffer, &p, buflen, &eclass->byval_arg, mono_array_get ((MonoArray*)arg, MonoObject*, i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -6475,7 +6475,7 @@ handle_type:
|
||||
* Returns: a Byte array representing the blob of data.
|
||||
*/
|
||||
MonoArray*
|
||||
mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues)
|
||||
mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues)
|
||||
{
|
||||
MonoArray *result;
|
||||
MonoMethodSignature *sig;
|
||||
@@ -6498,7 +6498,7 @@ mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, Mo
|
||||
*p++ = 0;
|
||||
for (i = 0; i < sig->param_count; ++i) {
|
||||
arg = mono_array_get (ctorArgs, MonoObject*, i);
|
||||
encode_cattr_value (buffer, p, &buffer, &p, &buflen, sig->params [i], arg);
|
||||
encode_cattr_value (assembly->assembly, buffer, p, &buffer, &p, &buflen, sig->params [i], arg);
|
||||
}
|
||||
i = 0;
|
||||
if (properties)
|
||||
@@ -6559,7 +6559,7 @@ mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, Mo
|
||||
mono_metadata_encode_value (len, p, &p);
|
||||
memcpy (p, pname, len);
|
||||
p += len;
|
||||
encode_cattr_value (buffer, p, &buffer, &p, &buflen, ptype, (MonoObject*)mono_array_get (propValues, gpointer, i));
|
||||
encode_cattr_value (assembly->assembly, buffer, p, &buffer, &p, &buflen, ptype, (MonoObject*)mono_array_get (propValues, gpointer, i));
|
||||
g_free (pname);
|
||||
}
|
||||
}
|
||||
@@ -6601,7 +6601,7 @@ mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, Mo
|
||||
mono_metadata_encode_value (len, p, &p);
|
||||
memcpy (p, fname, len);
|
||||
p += len;
|
||||
encode_cattr_value (buffer, p, &buffer, &p, &buflen, ftype, (MonoObject*)mono_array_get (fieldValues, gpointer, i));
|
||||
encode_cattr_value (assembly->assembly, buffer, p, &buffer, &p, &buflen, ftype, (MonoObject*)mono_array_get (fieldValues, gpointer, i));
|
||||
g_free (fname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass
|
||||
MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
|
||||
|
||||
MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
|
||||
MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
|
||||
MonoArray* mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
|
||||
|
||||
MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
|
||||
MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#ifdef PLATFORM_WIN32
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
|
||||
Sat May 29 10:45:58 CEST 2004 Paolo Molaro <[email protected]>
|
||||
|
||||
* mini.c: emit castclass/isinst in their own trees (bug #54209/59057).
|
||||
|
||||
2004-05-28 Zoltan Varga <[email protected]>
|
||||
|
||||
* mini-sparc.h (MONO_ARCH_NEED_DIV_CHECK): Define this.
|
||||
|
||||
* cpu-sparc.md mini-sparc.c: Add overflow detection to div opcodes.
|
||||
|
||||
2004-05-28 Patrik Torstensson <[email protected]>
|
||||
|
||||
* mini.c (mono_jit_runtime_invoke): Init class in this
|
||||
method instead of trusting mono_jit_compile_method to
|
||||
do the work (because wrappers can be in object class)
|
||||
|
||||
2004-05-27 Zoltan Varga <[email protected]>
|
||||
|
||||
* mini-sparc.c (mono_arch_output_basic_block): Fix sub.imm.
|
||||
|
||||
+4
-25
@@ -141,9 +141,9 @@ stind.r8: src1:b src2:f
|
||||
add: dest:i src1:i src2:i len:4
|
||||
sub: dest:i src1:i src2:i len:4
|
||||
mul: dest:i src1:i src2:i len:4
|
||||
div: dest:i src1:i src2:i len:12
|
||||
div: dest:i src1:i src2:i len:20
|
||||
div.un: dest:i src1:i src2:i len:8
|
||||
rem: dest:d src1:i src2:i len:20
|
||||
rem: dest:d src1:i src2:i len:28
|
||||
rem.un: dest:d src1:i src2:i len:16
|
||||
and: dest:i src1:i src2:i len:4
|
||||
or: dest:i src1:i src2:i len:4
|
||||
@@ -358,9 +358,9 @@ move: dest:i src1:i len:4
|
||||
add_imm: dest:i src1:i len:12
|
||||
sub_imm: dest:i src1:i len:12
|
||||
mul_imm: dest:i src1:i len:12
|
||||
div_imm: dest:a src1:i src2:i len:20
|
||||
div_imm: dest:a src1:i src2:i len:28
|
||||
div_un_imm: dest:a src1:i src2:i len:12
|
||||
rem_imm: dest:d src1:i src2:i len:28
|
||||
rem_imm: dest:d src1:i src2:i len:36
|
||||
rem_un_imm: dest:d src1:i src2:i len:16
|
||||
and_imm: dest:i src1:i len:12
|
||||
or_imm: dest:i src1:i len:12
|
||||
@@ -521,25 +521,6 @@ float_conv_to_u: dest:i src1:f len:36
|
||||
call_handler: len:12
|
||||
op_endfilter: src1:i len:12
|
||||
aot_const: dest:i len:8
|
||||
x86_test_null: src1:i len:4
|
||||
x86_compare_membase_reg: src1:b src2:i len:8
|
||||
x86_compare_membase_imm: src1:b len:8
|
||||
x86_compare_reg_membase: src1:i src2:b len:8
|
||||
x86_inc_reg: dest:i src1:i clob:1 len:1
|
||||
x86_inc_membase: src1:b len:6
|
||||
x86_dec_reg: dest:i src1:i clob:1 len:1
|
||||
x86_dec_membase: src1:b len:6
|
||||
x86_add_membase_imm: src1:b len:8
|
||||
x86_sub_membase_imm: src1:b len:8
|
||||
x86_push: src1:i len:1
|
||||
x86_push_imm: len:5
|
||||
x86_push_membase: src1:b len:6
|
||||
x86_push_obj: src1:b len:30
|
||||
x86_lea: dest:i src1:i src2:i len:7
|
||||
x86_xchg: src1:i src2:i clob:x len:1
|
||||
x86_fpop: src1:f len:2
|
||||
x86_fp_load_i8: dest:f src1:b len:7
|
||||
x86_fp_load_i4: dest:f src1:b len:7
|
||||
adc: dest:i src1:i src2:i len:4
|
||||
addcc: dest:i src1:i src2:i len:4
|
||||
subcc: dest:i src1:i src2:i len:4
|
||||
@@ -547,8 +528,6 @@ adc_imm: dest:i src1:i len:12
|
||||
sbb: dest:i src1:i src2:i len:4
|
||||
sbb_imm: dest:i src1:i len:12
|
||||
br_reg: src1:i len:8
|
||||
ppc_subfic: dest:i src1:i len:4
|
||||
ppc_subfze: dest:i src1:i len:4
|
||||
op_bigmul: len:2 dest:l src1:a src2:i
|
||||
op_bigmul_un: len:2 dest:l src1:a src2:i
|
||||
fmove: dest:f src1:f len:8
|
||||
|
||||
+10
-5
@@ -2689,7 +2689,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
|
||||
/* Sign extend sreg1 into %y */
|
||||
sparc_sra_imm (code, ins->sreg1, 31, sparc_o7);
|
||||
sparc_wry (code, sparc_o7, sparc_g0);
|
||||
sparc_sdiv (code, FALSE, ins->sreg1, ins->sreg2, ins->dreg);
|
||||
sparc_sdiv (code, TRUE, ins->sreg1, ins->sreg2, ins->dreg);
|
||||
EMIT_COND_SYSTEM_EXCEPTION (code, sparc_boverflow, "ArithmeticException");
|
||||
break;
|
||||
case CEE_DIV_UN:
|
||||
sparc_wry (code, sparc_g0, sparc_g0);
|
||||
@@ -2723,7 +2724,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
|
||||
/* Sign extend sreg1 into %y */
|
||||
sparc_sra_imm (code, ins->sreg1, 31, sparc_o7);
|
||||
sparc_wry (code, sparc_o7, sparc_g0);
|
||||
EMIT_ALU_IMM (ins, sdiv, FALSE);
|
||||
EMIT_ALU_IMM (ins, sdiv, TRUE);
|
||||
EMIT_COND_SYSTEM_EXCEPTION (code, sparc_boverflow, "ArithmeticException");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2731,7 +2733,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
|
||||
/* Sign extend sreg1 into %y */
|
||||
sparc_sra_imm (code, ins->sreg1, 31, sparc_o7);
|
||||
sparc_wry (code, sparc_o7, sparc_g0);
|
||||
sparc_sdiv (code, FALSE, ins->sreg1, ins->sreg2, sparc_o7);
|
||||
sparc_sdiv (code, TRUE, ins->sreg1, ins->sreg2, sparc_o7);
|
||||
EMIT_COND_SYSTEM_EXCEPTION (code, sparc_boverflow, "ArithmeticException");
|
||||
sparc_smul (code, FALSE, ins->sreg2, sparc_o7, sparc_o7);
|
||||
sparc_sub (code, FALSE, ins->sreg1, sparc_o7, ins->dreg);
|
||||
break;
|
||||
@@ -2747,11 +2750,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
|
||||
sparc_wry (code, sparc_o7, sparc_g0);
|
||||
if (!sparc_is_imm13 (ins->inst_imm)) {
|
||||
sparc_set (code, ins->inst_imm, sparc_g1);
|
||||
sparc_sdiv (code, FALSE, ins->sreg1, sparc_g1, sparc_o7);
|
||||
sparc_sdiv (code, TRUE, ins->sreg1, sparc_g1, sparc_o7);
|
||||
EMIT_COND_SYSTEM_EXCEPTION (code, sparc_boverflow, "ArithmeticException");
|
||||
sparc_smul (code, FALSE, sparc_o7, sparc_g1, sparc_o7);
|
||||
}
|
||||
else {
|
||||
sparc_sdiv_imm (code, FALSE, ins->sreg1, ins->inst_imm, sparc_o7);
|
||||
sparc_sdiv_imm (code, TRUE, ins->sreg1, ins->inst_imm, sparc_o7);
|
||||
EMIT_COND_SYSTEM_EXCEPTION (code, sparc_boverflow, "ArithmeticException");
|
||||
sparc_smul_imm (code, FALSE, sparc_o7, ins->inst_imm, sparc_o7);
|
||||
}
|
||||
sparc_sub (code, FALSE, ins->sreg1, sparc_o7, ins->dreg);
|
||||
|
||||
@@ -45,12 +45,15 @@ typedef struct MonoCompileArch {
|
||||
|
||||
#define MONO_ARCH_USE_SIGACTION 1
|
||||
|
||||
//#define MONO_ARCH_SIGSEGV_ON_ALTSTACK
|
||||
|
||||
#define MONO_ARCH_EMULATE_FCONV_TO_I8 1
|
||||
#define MONO_ARCH_EMULATE_LCONV_TO_R8 1
|
||||
#define MONO_ARCH_EMULATE_LCONV_TO_R4 1
|
||||
#define MONO_ARCH_EMULATE_CONV_R8_UN 1
|
||||
#define MONO_ARCH_EMULATE_LCONV_TO_R8_UN 1
|
||||
#define MONO_ARCH_EMULATE_FREM 1
|
||||
#define MONO_ARCH_NEED_DIV_CHECK 1
|
||||
|
||||
#ifndef __GNUC__
|
||||
/* assume Sun compiler if not GCC */
|
||||
|
||||
+26
-38
@@ -2575,6 +2575,19 @@ unverified:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static MonoInst*
|
||||
emit_tree (MonoCompile *cfg, MonoBasicBlock *bblock, MonoInst *ins)
|
||||
{
|
||||
MonoInst *store, *temp, *load;
|
||||
temp = mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
|
||||
NEW_TEMPSTORE (cfg, store, temp->inst_c0, ins);
|
||||
store->cil_code = ins->cil_code;
|
||||
MONO_ADD_INS (bblock, store);
|
||||
NEW_TEMPLOAD (cfg, load, temp->inst_c0);
|
||||
load->cil_code = ins->cil_code;
|
||||
return load;
|
||||
}
|
||||
|
||||
/*
|
||||
* mono_method_to_ir: translates IL into basic blocks containing trees
|
||||
*/
|
||||
@@ -3639,16 +3652,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
break;
|
||||
}
|
||||
if (mono_find_jit_opcode_emulation (ins->opcode)) {
|
||||
MonoInst *store, *temp, *load;
|
||||
--sp;
|
||||
temp = mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
|
||||
NEW_TEMPSTORE (cfg, store, temp->inst_c0, ins);
|
||||
store->cil_code = ins->cil_code;
|
||||
MONO_ADD_INS (bblock, store);
|
||||
NEW_TEMPLOAD (cfg, load, temp->inst_c0);
|
||||
load->cil_code = ins->cil_code;
|
||||
*sp++ = load;
|
||||
/*g_print ("found emulation for %d\n", ins->opcode);*/
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
}
|
||||
ip++;
|
||||
break;
|
||||
@@ -3668,16 +3673,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
CHECK_STACK (1);
|
||||
ADD_UNOP (*ip);
|
||||
if (mono_find_jit_opcode_emulation (ins->opcode)) {
|
||||
MonoInst *store, *temp, *load;
|
||||
--sp;
|
||||
temp = mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
|
||||
NEW_TEMPSTORE (cfg, store, temp->inst_c0, ins);
|
||||
store->cil_code = ins->cil_code;
|
||||
MONO_ADD_INS (bblock, store);
|
||||
NEW_TEMPLOAD (cfg, load, temp->inst_c0);
|
||||
load->cil_code = ins->cil_code;
|
||||
*sp++ = load;
|
||||
/*g_print ("found emulation for %d\n", ins->opcode);*/
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
}
|
||||
ip++;
|
||||
break;
|
||||
@@ -4009,7 +4006,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
ins->inst_left = *sp;
|
||||
ins->inst_newa_class = klass;
|
||||
ins->cil_code = ip;
|
||||
*sp++ = ins;
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
ip += 5;
|
||||
}
|
||||
break;
|
||||
@@ -4183,7 +4180,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
ins->klass = klass;
|
||||
ins->inst_newa_class = klass;
|
||||
ins->cil_code = ip;
|
||||
*sp++ = ins;
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
ip += 5;
|
||||
}
|
||||
break;
|
||||
@@ -4914,16 +4911,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
CHECK_STACK (2);
|
||||
ADD_BINOP (*ip);
|
||||
if (mono_find_jit_opcode_emulation (ins->opcode)) {
|
||||
MonoInst *store, *temp, *load;
|
||||
--sp;
|
||||
temp = mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
|
||||
NEW_TEMPSTORE (cfg, store, temp->inst_c0, ins);
|
||||
store->cil_code = ins->cil_code;
|
||||
MONO_ADD_INS (bblock, store);
|
||||
NEW_TEMPLOAD (cfg, load, temp->inst_c0);
|
||||
load->cil_code = ins->cil_code;
|
||||
*sp++ = load;
|
||||
/*g_print ("found emulation for %d\n", ins->opcode);*/
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
}
|
||||
ip++;
|
||||
break;
|
||||
@@ -5286,7 +5275,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
ins->inst_left = *sp;
|
||||
ins->inst_newa_class = klass;
|
||||
ins->cil_code = ip;
|
||||
*sp++ = ins;
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
ip += 6;
|
||||
break;
|
||||
}
|
||||
@@ -5359,15 +5348,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
|
||||
* and workaround bug 54209
|
||||
*/
|
||||
if (cmp->inst_left->type == STACK_I8) {
|
||||
MonoInst *store, *temp, *load;
|
||||
--sp;
|
||||
temp = mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
|
||||
NEW_TEMPSTORE (cfg, store, temp->inst_c0, ins);
|
||||
store->cil_code = ins->cil_code;
|
||||
MONO_ADD_INS (bblock, store);
|
||||
NEW_TEMPLOAD (cfg, load, temp->inst_c0);
|
||||
load->cil_code = ins->cil_code;
|
||||
*sp++ = load;
|
||||
*sp++ = emit_tree (cfg, bblock, ins);
|
||||
}
|
||||
ip += 2;
|
||||
break;
|
||||
@@ -8068,6 +8050,12 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
|
||||
|
||||
invoke = mono_marshal_get_runtime_invoke (method);
|
||||
runtime_invoke = mono_jit_compile_method (invoke);
|
||||
|
||||
/* We need this here becuase mono_marshal_get_runtime_invoke can be place
|
||||
* the helper method in System.Object and not the target class
|
||||
*/
|
||||
mono_runtime_class_init (mono_class_vtable (mono_domain_get (), method->klass));
|
||||
|
||||
compiled_method = mono_jit_compile_method (method);
|
||||
return runtime_invoke (obj, params, exc, compiled_method);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
2004-05-28 Zoltan Varga <[email protected]>
|
||||
|
||||
* pinvoke3.cs libtest.c: New tests for byref struct marshalling.
|
||||
|
||||
* static-constructor.cs: Add new regression test for bug #59193.
|
||||
|
||||
* setenv.cs: Fix this after marshalling changes.
|
||||
|
||||
@@ -310,6 +310,24 @@ mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef int (*OutVTypeDelegate) (int a, simplestruct *ss, int b);
|
||||
|
||||
int
|
||||
mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
|
||||
{
|
||||
int res;
|
||||
|
||||
/* Check that the input pointer is ignored */
|
||||
ss->d = (gpointer)0x12345678;
|
||||
|
||||
func (a, ss, b);
|
||||
|
||||
if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int (*func) (int);
|
||||
@@ -601,6 +619,23 @@ mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
|
||||
return delegate (return_self);
|
||||
}
|
||||
|
||||
typedef int (*PrimitiveByrefDelegate) (int *i);
|
||||
|
||||
int
|
||||
mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
int res = delegate (&i);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
if (i != 2)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mono_test_marshal_stringbuilder (char *s, int n)
|
||||
{
|
||||
|
||||
+51
-3
@@ -39,12 +39,27 @@ public class Tests {
|
||||
|
||||
public static int delegate_test_struct_byref (int a, ref SimpleStruct ss, int b)
|
||||
{
|
||||
if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2")
|
||||
if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2") {
|
||||
ss.a = true;
|
||||
ss.b = true;
|
||||
ss.c = true;
|
||||
ss.d = "TEST3";
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int delegate_test_struct_out (int a, out SimpleStruct ss, int b)
|
||||
{
|
||||
ss.a = true;
|
||||
ss.b = true;
|
||||
ss.c = true;
|
||||
ss.d = "TEST3";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static SimpleClass delegate_test_class (SimpleClass ss)
|
||||
{
|
||||
if (ss == null)
|
||||
@@ -86,6 +101,15 @@ public class Tests {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int delegate_test_primitive_byref (ref int i)
|
||||
{
|
||||
if (i != 1)
|
||||
return 1;
|
||||
|
||||
i = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int delegate_test_string_marshalling (string s)
|
||||
{
|
||||
return s == "ABC" ? 0 : 1;
|
||||
@@ -93,6 +117,11 @@ public class Tests {
|
||||
|
||||
[DllImport ("libtest", EntryPoint="mono_test_ref_vtype")]
|
||||
public static extern int mono_test_ref_vtype (int a, ref SimpleStruct ss, int b, TestDelegate d);
|
||||
|
||||
public delegate int OutStructDelegate (int a, out SimpleStruct ss, int b);
|
||||
|
||||
[DllImport ("libtest", EntryPoint="mono_test_marshal_out_struct")]
|
||||
public static extern int mono_test_marshal_out_struct (int a, out SimpleStruct ss, int b, OutStructDelegate d);
|
||||
|
||||
[DllImport ("libtest", EntryPoint="mono_test_marshal_delegate2")]
|
||||
public static extern int mono_test_marshal_delegate2 (SimpleDelegate2 d);
|
||||
@@ -118,6 +147,9 @@ public class Tests {
|
||||
[DllImport ("libtest", EntryPoint="mono_test_marshal_delegate10")]
|
||||
public static extern int mono_test_marshal_delegate10 (SimpleDelegate9 d);
|
||||
|
||||
[DllImport ("libtest", EntryPoint="mono_test_marshal_primitive_byref_delegate")]
|
||||
public static extern int mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate d);
|
||||
|
||||
public delegate int TestDelegate (int a, ref SimpleStruct ss, int b);
|
||||
|
||||
public delegate SimpleStruct SimpleDelegate2 (SimpleStruct ss);
|
||||
@@ -134,6 +166,8 @@ public class Tests {
|
||||
|
||||
public delegate int SimpleDelegate9 (return_int_delegate del);
|
||||
|
||||
public delegate int PrimitiveByrefDelegate (ref int i);
|
||||
|
||||
public static int Main () {
|
||||
return TestDriver.RunTests (typeof (Tests));
|
||||
}
|
||||
@@ -155,13 +189,21 @@ public class Tests {
|
||||
|
||||
if (mono_test_ref_vtype (1, ref ss, 2, d) != 0)
|
||||
return 1;
|
||||
|
||||
if (! (ss.a && !ss.b && ss.c && ss.d == "TEST2"))
|
||||
|
||||
if (! (ss.a && ss.b && ss.c && ss.d == "TEST3"))
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Test structures as out arguments of delegates */
|
||||
static int test_0_marshal_out_struct_delegate () {
|
||||
SimpleStruct ss = new SimpleStruct ();
|
||||
OutStructDelegate d = new OutStructDelegate (delegate_test_struct_out);
|
||||
|
||||
return mono_test_marshal_out_struct (1, out ss, 2, d);
|
||||
}
|
||||
|
||||
/* Test classes as arguments and return values of delegates */
|
||||
static int test_0_marshal_class_delegate () {
|
||||
SimpleDelegate4 d = new SimpleDelegate4 (delegate_test_class);
|
||||
@@ -230,4 +272,10 @@ public class Tests {
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int test_0_marshal_primitive_byref_delegate () {
|
||||
PrimitiveByrefDelegate d = new PrimitiveByrefDelegate (delegate_test_primitive_byref);
|
||||
|
||||
return mono_test_marshal_primitive_byref_delegate (d);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ monobins_DATA = \
|
||||
chktrust.exe \
|
||||
soapsuds.exe \
|
||||
monop.exe \
|
||||
mono-find-provides.exe \
|
||||
mono-find-requires.exe \
|
||||
setreg.exe \
|
||||
cert2spc.exe \
|
||||
certmgr.exe \
|
||||
@@ -86,6 +88,8 @@ $(monobins_DATA):
|
||||
setreg.exe) d=tools/security ;; \
|
||||
sn.exe) d=tools/security ;; \
|
||||
monop.exe) d=tools/monop ;; \
|
||||
mono-find-provides.exe) d=tools/mono-rpm-helpers ;; \
|
||||
mono-find-requires.exe) d=tools/mono-rpm-helpers ;; \
|
||||
browsercaps-updater.exe) d=tools/browsercaps-updater ;; \
|
||||
gacutil.exe) d=tools/gacutil ;; \
|
||||
gmcs.exe) d=gmcs ;; \
|
||||
|
||||
@@ -24,3 +24,5 @@ gmcs
|
||||
monop
|
||||
resgen
|
||||
gacutil
|
||||
mono-find-provides
|
||||
mono-find-requires
|
||||
+11
-3
@@ -1,8 +1,8 @@
|
||||
EXTRA_DIST = mcs.in mbas.in ilasm.in cilc.in monoresgen.in resgen.in secutil.in sqlsharp.in xsd.in wsdl.in genxs.in soapsuds.in chktrust.in signcode.in disco.in sn.in al.in cert2spc.in setreg.in makecert.in certmgr.in monop.in gacutil.in gmcs.in
|
||||
EXTRA_DIST = mcs.in mbas.in ilasm.in cilc.in monoresgen.in resgen.in secutil.in sqlsharp.in xsd.in wsdl.in genxs.in soapsuds.in chktrust.in signcode.in disco.in sn.in al.in cert2spc.in setreg.in makecert.in certmgr.in monop.in gacutil.in gmcs.in mono-find-provides.in mono-find-requires.in
|
||||
|
||||
bin_SCRIPTS = mcs mbas ilasm cilc monoresgen resgen secutil sqlsharp xsd wsdl al genxs soapsuds chktrust signcode disco sn cert2spc setreg makecert certmgr monop gacutil gmcs
|
||||
bin_SCRIPTS = mcs mbas ilasm cilc monoresgen resgen secutil sqlsharp xsd wsdl al genxs soapsuds chktrust signcode disco sn cert2spc setreg makecert certmgr monop gacutil gmcs mono-find-requires mono-find-provides
|
||||
|
||||
CLEANFILES = mcs mbas ilasm cilc monoresgen resgen secutil sqlsharp xsd wsdl al genxs soapsuds chktrust signcode disco sn cert2spc setreg makecert certmgr monop gacutil gmcs
|
||||
CLEANFILES = mcs mbas ilasm cilc monoresgen resgen secutil sqlsharp xsd wsdl al genxs soapsuds chktrust signcode disco sn cert2spc setreg makecert certmgr monop gacutil gmcs mono-find-requires mono-find-provides
|
||||
|
||||
if USE_JIT
|
||||
MONO_INTERP = mono
|
||||
@@ -115,3 +115,11 @@ monop: monop.in
|
||||
gacutil: gacutil.in
|
||||
sed -e 's^\@bindir\@^$(bindir)^g' -e 's^\@mono_interp\@^$(MONO_INTERP)^g' -e's^\@plat_bindir\@^$(plat_bindir)^g' < $(srcdir)/gacutil.in > gacutil.tmp \
|
||||
&& mv gacutil.tmp gacutil
|
||||
|
||||
mono-find-provides: mono-find-provides.in
|
||||
sed -e 's^\@bindir\@^$(bindir)^g' -e 's^\@mono_interp\@^$(MONO_INTERP)^g' -e's^\@plat_bindir\@^$(plat_bindir)^g' < $(srcdir)/mono-find-provides.in > mono-find-provides.tmp \
|
||||
&& mv mono-find-provides.tmp mono-find-provides
|
||||
|
||||
mono-find-requires: mono-find-requires.in
|
||||
sed -e 's^\@bindir\@^$(bindir)^g' -e 's^\@mono_interp\@^$(MONO_INTERP)^g' -e's^\@plat_bindir\@^$(plat_bindir)^g' < $(srcdir)/mono-find-requires.in > mono-find-requires.tmp \
|
||||
&& mv mono-find-requires.tmp mono-find-requires
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec @bindir@/@mono_interp@ @plat_bindir@/mono-find-provides.exe "$@"
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec @bindir@/@mono_interp@ @plat_bindir@/mono-find-requires.exe "$@"
|
||||
+39
-70
@@ -7,31 +7,35 @@
|
||||
* Web Services (the SOAP-based rpc system).
|
||||
</ul>
|
||||
|
||||
Both are functional at this point, and applications like
|
||||
"IBuySpy" run with Mono.
|
||||
|
||||
ASP.NET works either embedded into
|
||||
our XSP server test server or the mod_mono Apache module.
|
||||
|
||||
We are now working on bug fixing and adding missing features
|
||||
after making the whole pipeline compatible with MS.
|
||||
|
||||
Tim started work on the Web Services. After that, Lluis is in
|
||||
charge and has been working hard on them as part of our
|
||||
<a href="http://www.ximian.com/about_us/press_center/press_releases/index.html?pr=sourcegear">SourceGear</a> contract.
|
||||
Both are fully functional at this point.
|
||||
|
||||
Web services are now supported and there are some samples in the
|
||||
XSP set of tests.
|
||||
Publicly available applications such as <a
|
||||
href="http://www.asp.net/Default.aspx?tabindex=5&tabid=42">
|
||||
IBuySpy</a>, <a href="http://www.ngallery.org/">nGallery</a> and
|
||||
many others are known to work.
|
||||
|
||||
** Hosting
|
||||
Web Services stack is being used for commercial applications
|
||||
such as <a
|
||||
href="http://www.ximian.com/about_us/press_center/press_releases/index.html?pr=sourcegear">
|
||||
SourceGear</a>'s <a
|
||||
href="http://www.sourcegear.com/vault/index.asp">Vault</a>. They
|
||||
even funded the development of our Web Services classes back in
|
||||
2002.
|
||||
|
||||
ASP.NET provides a hosting interface. Today we ship support
|
||||
for two different hosting mechanisms:
|
||||
* Hosting ASP.NET
|
||||
|
||||
Using ASP.NET System.Web.Hosting namespace classes you can make
|
||||
your own ASP.NET enabled server.
|
||||
|
||||
However, if you want to take the easy path, we provide two
|
||||
different mechanisms for hosting ASP.NET applications:
|
||||
<ul>
|
||||
* <a href="#xsp">XSP</a>: A light-weight C# web server.
|
||||
* <a href="#xsp">XSP</a>: A light-weight web server
|
||||
written in C#.
|
||||
|
||||
* <a href="#mod_mono">mod_mono</a>: An apache module
|
||||
that can host the Mono runtime and the ASP.NET runtime
|
||||
* <a href="#mod_mono">mod_mono</a>: An <a
|
||||
href="http://httpd.apache.org">Apache</a> module that
|
||||
works with both 1.3 and 2.0 versions.
|
||||
</ul>
|
||||
|
||||
<a name="xsp">
|
||||
@@ -41,67 +45,32 @@
|
||||
run your ASP.NET applications. The code is available from our
|
||||
<a href="download.html">download page</a> or from the <a
|
||||
href="anoncvs.html">Anonymous CVS</a> repository (module name:
|
||||
xsp)/.
|
||||
xsp).
|
||||
|
||||
This is where initial development of the .aspx/.ascx/.asax
|
||||
compiler to C# took place. That compiler is now integrated in
|
||||
System.Web classes mostly under System.Web.Compilation
|
||||
namespace. We added a new web server that works with mono and
|
||||
MS runtime and is being used to debug our classes. It resides
|
||||
in xsp/server.
|
||||
|
||||
A couple of classes of this new server can be reused/extended
|
||||
to make an apache module/cgi using mono (MonoWorkerRequest and
|
||||
MonoApplicationHost). This server also uses a couple of
|
||||
plugins distributed with Mono to support gzip HTTP transfers.
|
||||
|
||||
There is also a set of .aspx pages to test the server along with
|
||||
a few user controls under xsp/test.
|
||||
|
||||
You can check it out from CVS and run 'make install' to test it.
|
||||
There is also a set of pages, controls and web services that you
|
||||
can use to test the server and see how ASP.NET looks like.
|
||||
|
||||
As XSP is written in C# and uses System.Web classes to perform
|
||||
its job, it also works under MS runtime.
|
||||
|
||||
<a name="mod_mono">
|
||||
* mod_mono
|
||||
** mod_mono
|
||||
|
||||
This Apache module is available from our <a
|
||||
href="download.html">download page</a>. The <a href="anoncvs.html">
|
||||
cvs</a> module name is mod_mono. It works with both 1.3 and 2.0
|
||||
versions of the <a href="http://httpd.apache.org">apache server</a>.
|
||||
cvs</a> module name is mod_mono.
|
||||
|
||||
It allows apache to serve ASP.NET pages.
|
||||
It allows apache to serve ASP.NET pages by proxying the requests
|
||||
to a slightly modified version of our XSP called mod-mono-server
|
||||
that is installed along with XSP.
|
||||
|
||||
Work is underway to improve it.
|
||||
|
||||
** Controls
|
||||
|
||||
A lot of work has been put in the various classes that
|
||||
implement the controls (UI.HtmlControls and UI.WebControls).
|
||||
They have been coded mostly in the dark, and without being
|
||||
able to test them in real life: Gaurav and Leen worked very
|
||||
hard on this namespace. After that, we keep fixing bugs on
|
||||
them.
|
||||
|
||||
We can now render all HtmlControls and all WebControls.
|
||||
|
||||
Help in making the controls better is appreciated.
|
||||
|
||||
** ASP.NET and free controls.
|
||||
|
||||
We want to encourage developers to create open source controls
|
||||
that can be used both on Mono's ASP.NET and Microsoft's ASP.NET.
|
||||
|
||||
** How to Help
|
||||
|
||||
Testing and fixing HtmlControls, WebControls and validators is an
|
||||
easy way to help.
|
||||
|
||||
In the CVS module XSP you can find a small web server used for
|
||||
testing and a directory containing sample aspx pages.
|
||||
|
||||
You have some documentation under doc directory and in the README
|
||||
file of each directory. They explain how to test our System.Web.
|
||||
Testing is really easy!
|
||||
|
||||
As the server also works with MS runtime, you can use it to check
|
||||
what the expected results are.
|
||||
It does not work on Windows.
|
||||
|
||||
<div align="bottom">
|
||||
<small>Last updated: Sat, 29 May 2004 02:53:44 GMT</small>
|
||||
</div>
|
||||
@@ -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 +0,0 @@
|
||||
*.xml
|
||||
@@ -1,96 +0,0 @@
|
||||
# Note that you will need Microsoft.NET to generate those masterinfos
|
||||
|
||||
# Customize to indicate your own installation dir.
|
||||
DLL_PATH=c:/WINDOWS/Microsoft.NET/Framework/v1.1.4322
|
||||
# DLL_PATH=c:/WINDOWS/Microsoft.NET/Framework/v1.2.30703
|
||||
|
||||
all: \
|
||||
mscorlib.xml \
|
||||
System.xml \
|
||||
System.Xml.xml \
|
||||
System.Configuration.Install.xml \
|
||||
System.Data.xml \
|
||||
System.Data.OracleClient.xml \
|
||||
System.Design.xml \
|
||||
System.Management.xml \
|
||||
System.Messaging.xml \
|
||||
System.Web.xml \
|
||||
System.Web.Services.xml \
|
||||
System.Runtime.Serialization.Formatters.Soap.xml \
|
||||
System.Drawing.xml \
|
||||
System.Drawing.Design.xml \
|
||||
System.Security.xml \
|
||||
System.DirectoryServices.xml \
|
||||
System.EnterpriseServices.xml \
|
||||
System.Runtime.Remoting.xml \
|
||||
System.Windows.Forms.xml \
|
||||
Microsoft.VisualBasic.xml \
|
||||
Cscompmgd.xml
|
||||
|
||||
mscorlib.xml :
|
||||
mono-api-info $(DLL_PATH)/mscorlib.dll > mscorlib.xml
|
||||
|
||||
System.xml :
|
||||
mono-api-info $(DLL_PATH)/System.dll > System.xml
|
||||
|
||||
System.Xml.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Xml.dll > System.Xml.xml
|
||||
|
||||
System.Configuration.Install.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Configuration.Install.dll > System.Configuration.Install.xml
|
||||
|
||||
System.Data.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Data.dll > System.Data.xml
|
||||
|
||||
System.Data.OracleClient.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Data.OracleClient.dll > System.Data.OracleClient.xml
|
||||
|
||||
System.Design.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Design.dll > System.Design.xml
|
||||
|
||||
System.Management.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Management.dll > System.Management.xml
|
||||
|
||||
System.Messaging.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Messaging.dll > System.Messaging.xml
|
||||
|
||||
System.Web.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Web.dll > System.Web.xml
|
||||
|
||||
System.Web.Services.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Web.Services.dll > System.Web.Services.xml
|
||||
|
||||
System.Runtime.Remoting.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Runtime.Remoting.dll > System.Runtime.Remoting.xml
|
||||
|
||||
System.Runtime.Serialization.Formatters.Soap.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Runtime.Serialization.Formatters.Soap.dll > System.Runtime.Serialization.Formatters.Soap.xml
|
||||
|
||||
System.Drawing.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Drawing.dll > System.Drawing.xml
|
||||
|
||||
System.Drawing.Design.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Drawing.Design.dll > System.Drawing.Design.xml
|
||||
|
||||
System.Security.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Security.dll > System.Security.xml
|
||||
|
||||
System.DirectoryServices.xml :
|
||||
mono-api-info $(DLL_PATH)/System.DirectoryServices.dll > System.DirectoryServices.xml
|
||||
|
||||
System.EnterpriseServices.xml :
|
||||
mono-api-info $(DLL_PATH)/System.EnterpriseServices.dll > System.EnterpriseServices.xml
|
||||
|
||||
System.Windows.Forms.xml :
|
||||
mono-api-info $(DLL_PATH)/System.Windows.Forms.dll > System.Windows.Forms.xml
|
||||
|
||||
Cscompmgd.xml :
|
||||
mono-api-info $(DLL_PATH)/Cscompmgd.dll > Cscompmgd.xml
|
||||
|
||||
Microsoft.VisualBasic.xml :
|
||||
mono-api-info $(DLL_PATH)/Microsoft.VisualBasic.dll > Microsoft.VisualBasic.xml
|
||||
|
||||
clean:
|
||||
rm mscorlib.xml System.xml System.Xml.xml System.Configuration.Install.xml System.Data.xml System.Data.OracleClient.xml System.Management.xml System.Messaging.xml System.Web.xml System.Web.Services.xml System.Runtime.Serialization.Formatters.Soap.xml System.Drawing.xml System.Security.xml System.DirectoryServices.xml System.EnterpriseServices.xml System.Runtime.Remoting.xml System.Windows.Forms.xml Cscompmgd.xml Microsoft.VisualBasic.xml
|
||||
|
||||
|
||||
Reference in new issue
Block a user