Sfoglia il codice sorgente

Extract7ZipFile: output/log memory requirements.

Martijn Laan 9 mesi fa
parent
commit
d78d5dd35a

+ 25 - 0
Components/Lzma2/Util/7z/7zMain.c

@@ -6,6 +6,7 @@
    -Change main to mainW to support Unicode archive names
    -Add specific error text for SZ_ERROR_ARCHIVE and SZ_ERROR_NO_ARCHIVE
    -Return res on errors instead of always returning 1
+   -Add optional output of SzArEx_Extract's output buffer sizes
    Otherwise unchanged */
 
 #include "Precomp.h"
@@ -531,6 +532,19 @@ static void PrintError_WRes(const char *message, WRes wres)
   PrintLF();
 }
 
+#ifdef REPORT_OUTBUFFERSIZE
+static void PrintInt(const char *message, UInt64 value)
+{
+  Print(message);
+  {
+    char s[32];
+    UInt64ToStr(value, s, 1);
+    Print(s);
+  }
+  PrintLF();
+}
+#endif
+
 static void GetAttribString(UInt32 wa, BoolInt isDir, char *s)
 {
   #ifdef USE_WINDOWS_FILE
@@ -655,6 +669,9 @@ int Z7_CDECL mainW(int numargs, WCHAR *args[])
       UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
       Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
       size_t outBufferSize = 0;  /* it can have any value before first call (if outBuffer = 0) */
+      #ifdef REPORT_OUTBUFFERSIZE
+      size_t prevOutBufferSize = -1; /* it must be -1 before first call for each new archive. */
+      #endif
 
       for (i = 0; i < db.NumFiles; i++)
       {
@@ -741,6 +758,14 @@ int Z7_CDECL mainW(int numargs, WCHAR *args[])
               &allocImp, &allocTempImp);
           if (res != SZ_OK)
             break;
+          #ifdef REPORT_OUTBUFFERSIZE
+          if (prevOutBufferSize == -1 || outBufferSize != prevOutBufferSize)
+          {
+            PrintLF();
+            PrintInt("Used new buffer size ", outBufferSize);
+            prevOutBufferSize = outBufferSize;
+          }
+          #endif
         }
         
         if (!testCommand)

+ 1 - 1
ISHelp/isxfunc.xml

@@ -1845,7 +1845,7 @@ end;</pre>
         <prototype>function Extract7ZipFile(const FileName, DestDir: String; const FullPaths: Boolean): Integer;</prototype>
         <description><p>Extracts the specified 7-Zip archive to the specified directory, with or without using path names. Returns zero if successful, nonzero otherwise</p>
 <p>The archive must not be encrypted.</p></description>
-        <remarks><p>Uses an embedded version of the &quot;7z ANSI-C Decoder&quot; from the LZMA SDK by Igor Pavlov, as-is, except that Unicode support was improved.</p>
+        <remarks><p>Uses an embedded version of the &quot;7z ANSI-C Decoder&quot; from the LZMA SDK by Igor Pavlov, as-is, except that Unicode support and error messages were improved and that it outputs memory requirements.</p>
 <p>All output of the decoder is logged if logging is enabled, including error messages but excluding empty lines.</p>
 <p>The decoder has the following limitations, as written by Igor Pavlov in the LZMA SDK:<br /><br />
 -It reads only &quot;FileName&quot;, &quot;Size&quot;, &quot;LastWriteTime&quot; and &quot;CRC&quot; information for each file in archive.<br />

+ 2 - 0
Projects/Src/Compression.SevenZipDecoder/7zDecode/IS7zDec.c

@@ -86,6 +86,8 @@ int _fputs(char const* str, FILE* stream);
 /* Include all needed SDK code. None of these require changes for the helper function to
    work but 7zMain.c was changed for better Unicode support */
 
+#define REPORT_OUTBUFFERSIZE
+
 #include "../../../../Components/Lzma2/Util/7z/7zMain.c"
 
 #ifndef USE_WINDOWS_FILE

BIN
Projects/Src/Compression.SevenZipDecoder/7zDecode/IS7zDec.obj