Extract ZIP to RAM?

Get help with using AutoHotkey and its commands and hotkeys
malcev
Posts: 610
Joined: 12 Aug 2014, 12:37

Re: Extract ZIP to RAM?

08 Mar 2020, 03:28

Yes, but it is convenient to use for custom data manipulation.
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Extract ZIP to RAM?

16 Apr 2020, 04:32

malcev wrote:
07 Mar 2020, 12:56
Just try to use this API and the resulting zip archive does not open by WinZip or WinRar.
https://docs.microsoft.com/en-us/windows/win32/cmpapi/-compression-portal
Spoiler
[...]
Well, the created zip-archive won't even open within W10 itself. :crazy:

Error msg (translated from German)

ZIP-compressed folder - Error
The folder can't be opened.
The zip-compressed folder <your path here> is invalid.

Interestingly, the decompression of that 'invalid' file/folder with your code will deliver a valid uncompressed file?? Any thoughts?

PS. I've merged your code to deal with zipping/unzipping files using a single function. But I've ended up with a 0 Kb decompressed output. After multiple sessions of trial and error, it showed up that the DllCall()-command is case-sensitive!! :wtf: With changing the function string from "DeCompressor" to "Decompressor" a valid (3MB) output file has been created. If that's an already known fact, this is just for the records :)

PPS. This script used a static file naming approach. Well, if I'm doing automated unzipping of a zip-archive (with x number of files) that won't work. How to identify & extract the original file format ext of the compressed file(s) to correctly name its decompressed output??

8-)
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
malcev
Posts: 610
Joined: 12 Aug 2014, 12:37

Re: Extract ZIP to RAM?

16 Apr 2020, 08:11

My code just creates compressed data without creating zip header.
If You want to use this API to create zip that Windows understands, then You have to read and understand how to create and fill zip header.
But if You want just compress your file with saving name and extension, then You can do it like this::

Code: Select all

inputFile := "1.mp4"
Compressed := "1.mp4.compressed"
Uncompressed := substr(compressed....)
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Extract ZIP to RAM?

16 Apr 2020, 08:13

Thx 4 your fast response :thumbup:
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
User avatar
hasantr
Posts: 497
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Extract ZIP to RAM?

29 Apr 2020, 10:37

Code: Select all

if !A_Args[1] {
	Run, % """" . A_ScriptFullPath . """ 1"
	ExitApp
}
Loop,7
{
	pathInsideZip := "content.xml"
	7ZipDLL := "7-zip" . A_PtrSize*8 . ".dll"
	zipFile := A_ScriptDir . "\test" A_Index ".udf"
	7zip := new 7zipToBuff(7ZipDLL, zipFile, pathInsideZip)
	7zip.UnzipToBuff(buff)
	output := 7zip.output
	7zip := ""
	MsgBox, %  StrGet(&buff, "UTF-8")
}
It works only once in the loop. Crash occurs while reading the second file.

[quote]---------------------------
Error: LoadLibrary failed

Line#
021: }
026: {
029: if !FileExist(7ZipDLL)
030: Throw,7ZipDLL . " not found"
031: if !FileExist(zipFile)
032: Throw,"The file """ . zipFile . """ not found"
033: if !this.hModule := DllCall("LoadLibrary", "Str", 7ZipDLL, "Ptr")
---> 034: Throw,"LoadLibrary failed"
036: this.7ZipDLL := 7ZipDLL
037: this.zipFile := zipFile
038: this.pathInsideZip := pathInsideZip
040: this.savedStdOut := DllCall("GetStdHandle", "UInt", STD_OUTPUT_HANDLE, "Ptr")
041: buffSize := this.GetBuffSize()
042: if (buffSize = -1)
043: Throw,"The file """ . pathInsideZip . """ not found in archive"

The current thread will exit.
---------------------------[/quote]
teadrinker
Posts: 1639
Joined: 29 Mar 2015, 09:41
Contact:

Re: Extract ZIP to RAM?

29 Apr 2020, 11:35

hasantr wrote: Crash occurs while reading the second file.
Can't reproduce this error. For me this code works without issues.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, Google [Bot], goreliu and 256 guests