Page 40 of 40

Re: PureZIP library : ZIP / UNZIP files

Posted: Wed Feb 29, 2012 5:13 pm
by Michael Vogel
I tried to change one single file in a sub directory of a large zip file and failed so far...

...the first problem have been Memory Errors when executing PureZIP_DeleteFile when the archive is not in a proper format (no problems have been seen with all other commands) - workaround extracting and compacting all files to create a compatible archive.

...but now I am still not able to remove the file in the sub directory and so I get multiple files with the same name in the archive. Is there a simple method to overwrite an existing file?

Code: Select all

Archiv.s="Test.zip"
Datei.s="subdir\file.txtl"
						
Global Buffer.s
Global Ok.i

If PureZIP_Archive_Read(Archiv)
	myfileinfo.PureZIP_FileInfo
	If PureZIP_Archive_Locate(Datei)=#UNZ_OK
		Buffer=Space(myFileinfo\unCompressedSize)
		If PureZIP_Archive_ExtractMem(@Buffer,Len(Buffer))>0
			Buffer=Left(Buffer,123)+"***"+Mid(Buffer,123)
			Ok=1
		EndIf
	EndIf
	PureZIP_Archive_Close()
EndIf

If Ok
	Debug PureZIP_DeleteFile(Archiv,Datei)
	If PureZIP_Archive_Create(Archiv,#APPEND_STATUS_ADDINZIP)
		Debug PureZIP_Archive_CompressMem(Datei,@Buffer,Len(Buffer)-1)
		PureZIP_Archive_Close()
	EndIf
EndIf

Re: PureZIP library : ZIP / UNZIP files

Posted: Thu Mar 01, 2012 3:10 pm
by gnozal
Michael Vogel wrote:...the first problem have been Memory Errors when executing PureZIP_DeleteFile when the archive is not in a proper format (no problems have been seen with all other commands) - workaround extracting and compacting all files to create a compatible archive.
PureZIP_DeleteFile() uses some low level ZLIB functions, so a corrupt archive may be a problem. I fixed a memory allocation issue, so maybe this is fixed.
Michael Vogel wrote:...but now I am still not able to remove the file in the sub directory and so I get multiple files with the same name in the archive. Is there a simple method to overwrite an existing file?
I have uploaded a new version, it should work now with your code. You need to add a PureZIP_Archive_FileInfo() call before using myFileinfo\unCompressedSize though.

Re: PureZIP library : ZIP / UNZIP files

Posted: Fri Mar 02, 2012 6:47 pm
by Michael Vogel
gnozal wrote:I fixed a memory allocation issue, so maybe this is fixed.
Haven't changed anything here, I was trying to delete a file within MS office files (dotx, xlam, ppam) which seem to have been packed without any compression.
gnozal wrote:I have uploaded a new version, it should work now with your code. You need to add a PureZIP_Archive_FileInfo() call before using myFileinfo\unCompressedSize though.
Oh, must have deleted the PureZIP_Archive_FileInfo() line in my last code example. :oops:

Your new version do show the same effects than before, I fear I must do something wrong. I use this small zip file for the following code:

Code: Select all

Archiv.s="Zip.zip"
Datei.s="Dir1\Text1.txt"

Global Buffer.s="Hallo"
Global Ok

#Banner="***Yippieh***"

If PureZIP_Archive_Read(Archiv)
	myfileinfo.PureZIP_FileInfo
	If PureZIP_Archive_Locate(Datei)=#UNZ_OK
		PureZIP_Archive_FileInfo(@myFileinfo)
		Buffer=Space(myFileinfo\unCompressedSize)
		If PureZIP_Archive_ExtractMem(@Buffer,Len(Buffer))>0
			f=FindString(Buffer,"Change")
			If f
				f=FindString(Buffer,"[",f)
				e=FindString(Buffer,"]",f+1)
				Debug "Old Text: "+Mid(Buffer,f+1,e-f-1)
				If e
					Debug "New Text: "+#Banner
					Buffer=Left(Buffer,f)+#Banner+Mid(Buffer,e)
					Ok=#True
				EndIf
			EndIf
		EndIf
	EndIf
	PureZIP_Archive_Close()
EndIf

If Ok
	PureZIP_Archive_Close()
	Debug PureZIP_DeleteFile(Archiv,Datei)
	If PureZIP_Archive_Create(Archiv,#APPEND_STATUS_ADDINZIP)
		Debug PureZIP_Archive_CompressMem(Datei,@Buffer,Len(Buffer)-1)
		PureZIP_Archive_Close()
	EndIf
EndIf

Re: PureZIP library : ZIP / UNZIP files

Posted: Sat Mar 03, 2012 9:25 am
by gnozal
Michael Vogel wrote:Haven't changed anything here, I was trying to delete a file within MS office files (dotx, xlam, ppam) which seem to have been packed without any compression.
I tried PureZIP_DeleteFile() on an archive with no compression (store) : no problem.
It seems to be something else.
Michael Vogel wrote:Your new version do show the same effects than before, I fear I must do something wrong. I use this small zip file for the following code...
ZIP archives store the '\' in unix style '/'.
I have updated PureZIP_DeleteFile() in the library to handle the '\' correctly.

I hope it works as expected now : version 2.33 (MAR 9th 2012).

Re: PureZIP library : ZIP / UNZIP files

Posted: Fri Nov 23, 2012 9:34 pm
by User_Russian
How can I open several files at once?
Function PureZIP_Archive_Read() only works with a single archive.

Re: PureZIP library : ZIP / UNZIP files

Posted: Sat Nov 24, 2012 10:22 am
by gnozal
User_Russian wrote:Function PureZIP_Archive_Read() only works with a single archive.
Correct.
User_Russian wrote:How can I open several files at once?
Currently, you can't.
If you need this feature, have a look at MiniZip

Re: PureZIP library : ZIP / UNZIP files

Posted: Sun Dec 23, 2012 3:14 am
by Nituvious
Following code crashes, using PB5 and the dll version.

Code: Select all

Procedure openzip(filename.s)
	Define myFileinfo.PureZIP_FileInfo
	Define ReturnValue.l
If PureZIPDLL_Archive_Read(filename)
   ReturnValue.l = PureZIPDLL_Archive_FindFirst()
   While ReturnValue = #UNZ_OK 
      Debug PureZIPDLL_Archive_FileInfo(@myFileinfo)
      Debug "Filename: " + myFileinfo\FileName
      Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
      Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
      ReturnValue = PureZIPDLL_Archive_FindNext()
   Wend
   PureZIPDLL_Archive_Close()
 EndIf 
 EndProcedure
Should add that I receive an IMA at EndProcedure.

Re: PureZIP library : ZIP / UNZIP files

Posted: Mon Dec 24, 2012 2:50 am
by Nituvious
Sorry for the double post but it seems the DLL version is extremely unstable. PureZIPDLL_AddMemory("D:\test.zip", "folder/test.txt", @"Hello world", len("Hello world")) doesn't write contents to the file entirely, or the contents become something like, "4050 64".

Even the examples do this. Any idea whats going on here?


[edit] disregard this post. I think this may actually be an error with my system itself.

Re: PureZIP library : ZIP / UNZIP files

Posted: Sat Aug 10, 2013 12:46 am
by zeehteam
Is it possible to upgrade PureZip DLL to make it possible to do file deletion in archive, file renaming in archive, and read archive from memory? Thank you.

Re: PureZIP library : ZIP / UNZIP files

Posted: Tue Aug 27, 2013 4:44 am
by Opcode
zeehteam wrote:Is it possible to upgrade PureZip DLL to make it possible to do file deletion in archive, file renaming in archive, and read archive from memory? Thank you.
PureBasic supports archives since 5.10 I think, might wanna give them a look. It can do a couple of things you're looking to do.

http://www.purebasic.com/documentation/ ... index.html

Re: PureZIP library : ZIP / UNZIP files

Posted: Sat Aug 31, 2013 6:44 pm
by IdeasVacuum
ruslanx wrote:Thanks Gnozal for quick answer ... I will use 7z.exe ... 7z a archive.7z -p123 -mhe *.txt

but I need a 'ProgressionCallback' .... I find a key for 7z -so (write data to stdout)
how I can read info from stdout .. can you give a peace of code or example ..thx.
Another way:

Code: Select all

 *Buffer = AllocateMemory(1024 * SizeOf(character))

   i7zip = RunProgram("C:\7zip\7za.exe", " a -t7z my_archive.7z C:\MyTemp", "C:\", #PB_Program_Open | #PB_Program_Hide | #PB_Program_Read)
If i7zip

          While ProgramRunning(i7zip)

                    If AvailableProgramOutput(i7zip)

                           ReadProgramData(i7zip,*Buffer,1024)
                                 Debug PeekS(*Buffer, 1024, #PB_UTF8)
                    EndIf
          Wend

          CloseProgram(i7zip)
EndIf
Unfortunately, it seems that PB receives the 7zip output when the whole task is complete, so you can't use the output to show progress. Did you find a better way with 7zip's -so flag? I can't get that option to work.

Re: PureZIP library : ZIP / UNZIP files

Posted: Thu Dec 19, 2013 9:36 am
by graves
Hi
Compiling with PB 5.21 LTS, the compiler says:
PB library missing Misc

PB has been removed it.
What is the solution?

Re: PureZIP library : ZIP / UNZIP files

Posted: Thu Dec 19, 2013 1:22 pm
by Bisonte
Gnozal's libraries are only for this PB Version, their compiled for. Latest Update of his libs is to fit to PB5.0x (Tailbite).

If you want to use gnozal's libs with a newer version of PB, you have to wait for gnozal's update....

By the way... Where is Gnozal ? Normally his libs are converted to the newest PB version at real-time ;)

Re: PureZIP library : ZIP / UNZIP files

Posted: Thu Dec 19, 2013 1:52 pm
by PB
> PureBasic supports archives since 5.10 I think

But not with passwords, so I still need Gnozal's lib for now.

Re: PureZIP library : ZIP / UNZIP files

Posted: Thu Dec 19, 2013 11:31 pm
by Bisonte
PB wrote:> PureBasic supports archives since 5.10 I think

But not with passwords, so I still need Gnozal's lib for now.
Give a try to HeX0r's or TS-Soft's includes here in the forum ....