Negative value for lBytesTotalLow
-
01-08-2008, 11:46 AM |
-
Rich
-
-
-
Joined on 08-10-2007
-
-
Posts 4
-
-
|
Negative value for lBytesTotalLow
After using the GetZipFileInformation64 method, I'm handling the ProcessCompleted64 event (using .NET 2.0/VB). The value for lBytesTotalLow is -2603399. lBytesTotalHigh is zero.
What's this number supposed to mean when using GetZipFileInformation64? When I try to convert it to an unsigned long it gives me an overflow error.
The zip file being examined is a split file, split into 8 parts of 512 MB each (.zip, .z02, ... .z08).
|
|
-
01-08-2008, 4:34 PM |
-
CharlesB
-
-
-
Joined on 05-29-2007
-
Canada
-
Posts 456
-
-
|
Re: Negative value for lBytesTotalLow
I tried to replicate this and I was not able to. I used approximatively 4 Gb of data (creating 8 split zip file. The lBytesTotalLow I got was positive number.
<code> private static void NegativeParameterValueForum11049() { zip = new XceedZipLib.XceedZipClass(); zip.License( "ZIP61-CZTTK-PTZCP-NNAA" );
zip.ZipFilename = @"D:\Forum11049\archive.zip"; zip.FilesToProcess = @"D:\BigFileToProcess\*"; zip.PreservePaths = false; zip.Use64BitEvents = true; zip.SplitSize64 = 1024 * 1024 * 512;
zip.ProcessCompleted64 += new _IXceedZipEvents_ProcessCompleted64EventHandler( zip_ProcessCompleted64_2 );
xcdError message = zip.Zip(); Console.WriteLine( "Error Zip " + message.ToString() + " (" + ( ( int )message ).ToString() + "):" ); Console.WriteLine( zip.GetErrorDescription( xcdValueType.xvtError, ( int )message ) );
object vaNbFiles = new object(); object vaCompressedSize = new object(); object vaCompressedSizeHigh = new object(); object vaUncompressedSize = new object(); object vaUncompressedSizeHigh = new object(); object vaCompressionRatio = new object(); object vaSpanned = new object();
message = zip.GetZipFileInformation64( ref vaNbFiles, ref vaCompressedSize, ref vaCompressedSizeHigh, ref vaUncompressedSize, ref vaUncompressedSizeHigh, ref vaCompressionRatio, ref vaSpanned ); Console.WriteLine( "Error Zip " + message.ToString() + " (" + ( ( int )message ).ToString() + "):" ); Console.WriteLine( zip.GetErrorDescription( xcdValueType.xvtError, ( int )message ) ); }
static void zip_ProcessCompleted64_2( int lFilesTotal, int lFilesProcessed, int lFilesSkipped, int lBytesTotalLow, int lBytesTotalHigh, int lBytesProcessedLow, int lBytesProcessedHigh, int lBytesSkippedLow, int lBytesSkippedHigh, int lBytesOutputLow, int lBytesOutputHigh, short nCompressionRatio, xcdError xResult ) { Console.WriteLine( "lBytesTotalLow is {0} and lBytesTotalHigh is {1}", lBytesTotalLow, lBytesTotalHigh ); } </code>
Charles Bérubé-Rémillard Technical Support Xceed Software Inc.
|
|
-
01-09-2008, 12:08 PM |
-
Rich
-
-
-
Joined on 08-10-2007
-
-
Posts 4
-
-
|
Re: Negative value for lBytesTotalLow
The routine works fine so far on a couple hundred machines, it's just this one machine with this one set of zip files (created by the same component) that has run into this.
xResult is xerSuccess, so it looks like the routine is completing successfully.
The numbers I get are
lBytesTotal: (low = -2603399 (high = 0) lBytesProcessed: (low = 0) (high = 0) lBytesOutput: (low = 29235200) (high = 1) lBytesSkipped: (low = 0) (high = 0)
I think lBytesTotalLow is negative because it's being handled as a signed integer, even though it's intended as unsigned. If treated as unsigned then lBytesTotalLow would be 4,292,363,897. That's a valid unsigned integer (barely), but there seems to be some kind of problem converting negative Integers this large to unsigned integers (UInteger or ULong) -- even though it should be a valid conversion, CUInt and CULng both give me an overflow error. Apparently VB.NET converts the number internally to unsigned BEFORE it allocates the extra bits.
Do you by any chance know of a way I can convert -2603399 to an unsigned Long without getting an overflow error? I'm not the world's best with bit shifting.
|
|
-
01-09-2008, 1:07 PM |
-
Rich
-
-
-
Joined on 08-10-2007
-
-
Posts 4
-
-
|
Re: Negative value for lBytesTotalLow
This seems to get around the problem in preliminary tests. I'm not sure how it will fare over the long term, but it might be okay. I'm having to use the Int_to_ULong function because the built-in CULng() function fails with high negative numbers.
<pre> Public Function Combine64BitParts(ByVal low32Bits As Integer, ByVal high32Bits As Integer) As ULong If high32Bits = 0 Then Return Int_to_ULong(low32Bits) Return (Int_to_ULong(high32Bits) << 32) + Int_to_ULong(low32Bits) End Function
Public Function Int_to_ULong(ByVal i As Integer) As ULong
Static Dim HighBit As UInteger = 2147483648 ' = 10000000000000000000000000000000 Static Dim LowBits As Integer = 2147483647 ' = 01111111111111111111111111111111
Dim u As ULong
If i >= 0 Then u = CULng(i) Else i = i And LowBits 'Strip the high bit. u = CULng(i) u = u + HighBit 'Replace the high bit. End If
Return u
End Function </pre>
|
|
-
01-10-2008, 2:36 PM |
-
Rich
-
-
-
Joined on 08-10-2007
-
-
Posts 4
-
-
|
Re: Negative value for lBytesTotalLow
I finally found the difference. Your code is in C#, which by default does not check for overflows in stuff like this. I'm using VB where overflow checking is always on and can't be turned off for specific sections of code (only for the entire project). So when you cast a negative int as unsigned, you won't have a problem, but for me it chokes.
You won't get a negative value for lBytesTotalLow anyway unless the value is somewhere between 2147483648 and 4294967295. The highest bit is 1 only within that range.
Since I have to start with signed integers and treat them as unsigned, I'm stuck with using the bit-mask method I mentioned earlier.
|
|
-
01-16-2008, 4:46 PM |
-
CharlesB
-
-
-
Joined on 05-29-2007
-
Canada
-
Posts 456
-
-
|
Re: Negative value for lBytesTotalLow
I tried it with VB6 and I was still not able to reproduce. Here is the code I used:
<code> Public Sub Command1_Click()
Call zip.License("ZIP61-CZTTK-PTZCP-NNAA")
zip.ZipFilename = "D:\Forum11049\archive.zip" zip.FilesToProcess = "D:\Temp\*" zip.PreservePaths = False zip.Use64BitEvents = True Dim myNumber As Long myNumber = 536870912 zip.SplitSize = myNumber zip.TempFolder = "D:\Tmp\"
Dim message As xcdError message = zip.zip
Text1.Text = message
Dim vaNbFiles As Variant Dim vaCompressedSize As Variant Dim vaCompressedSizeHigh As Variant Dim vaUncompressedSize As Variant Dim vaUncompressedSizeHigh As Variant Dim vaCompressionRatio As Variant Dim vaSpanned As Variant
message = zip.GetZipFileInformation64(vaNbFiles, vaCompressedSize, _ vaCompressedSizeHigh, vaUncompressedSize, vaUncompressedSizeHigh, _ vaCompressionRatio, vaSpanned) Text2.Text = message
End Sub
Private Sub zip_ProcessCompleted64(ByVal lFilesTotal As Long, ByVal lFilesProcessed As Long,_ ByVal lFilesSkipped As Long, ByVal lBytesTotalLow As Long, ByVal lBytesTotalHigh As Long,_ ByVal lBytesProcessedLow As Long, ByVal lBytesProcessedHigh As Long,_ ByVal lBytesSkippedLow As Long, ByVal lBytesSkippedHigh As Long, ByVal lBytesOutputLow As Long,_ ByVal lBytesOutputHigh As Long, ByVal nCompressionRatio As Integer, ByVal xResult As XceedZipLib.xcdError) MsgBox lBytesTotalLow End Sub </code>
Charles Bérubé-Rémillard Technical Support Xceed Software Inc.
|
|
|
|
|
|