Posted: Wed Oct 24, 2007 4:57 pm
				
				this is possible. Unfortunately, I also can say nothing to it.gnozal wrote:So it seems to be a ZLIB issue ?
I have no more ideas how you can fix it.
http://www.purebasic.com
https://www.purebasic.fr/english/
this is possible. Unfortunately, I also can say nothing to it.gnozal wrote:So it seems to be a ZLIB issue ?
Code: Select all
MyZIP.s = "C:\Test.zip"
MyZIPFile1.s = "C:\Compressor Xpert.exe"
MyZIPFile2.s = "C:\French.lng"
MyZIPFile3.s = "C:\English.lng"
MyZIPOutPut.s = "C:\TempZip"
If PureZIP_Archive_Create(MyZIP.s, #APPEND_STATUS_CREATE)
   PureZIP_SetArchivePassword("azerty")
   PureZIP_Archive_Compress(MyZIPFile1.s, #False)
   PureZIP_Archive_Compress(MyZIPFile2.s, #False)
   PureZIP_Archive_Compress(MyZIPFile3.s, #False)
   PureZIP_Archive_Close()
EndIf
MessageRequester("Info","Success",0)
; i need to check if the password is correct before unzip files
; but i can't make it work !
Input.s = InputRequester("Zip is crypted", "Password:", "")
If PureZIP_Archive_Read(MyZIP.s)
  If Input
     If PureZIP_SetArchivePassword(Input)
         ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
        While ReturnValue = #UNZ_OK
         PureZIP_Archive_Extract(MyZIPOutPut.s, #True)
         ReturnValue = PureZIP_Archive_FindNext()
        Wend:MessageRequester("Info","Files are extracted !",0)
       Else: MessageRequester("Info","Error !",0):EndIf
    Else:MessageRequester("Info","please input password !",0):EndIf
 PureZIP_Archive_Close()
EndIfYou can't.Micko wrote:hi gnozal
i would like to check if the user password is correct before extract zip files
Exactly.DoubleDutch wrote:For security reasons I don't think that zip files store that kind of information, I think you only know that a password is incorrect when you get errors during the uncompression.
Code: Select all
SourceDir .s = "Test.Zip" ;protected with password
Chemin.s = "C:\Temp"
While Valeur_Retour = #UNZ_OK
              myFileinfo.PureZIP_FileInfo
              ExtractValue = PureZIP_ExtractFiles(SourceDir, "*.*", Chemin, #True)
               If ExtractValue  = #Null : Goto MessageError
               Else
              Valeur_Retour = PureZIP_Archive_FindNext() 
              EndIf
 Wend
MessageError :       
              MessageRequester("Error","Incorrect password, can't process files !",#MB_ICONWARNING)Code: Select all
If PureZIP_Archive_Read("c:\test.zip")
  IsOk = PureZIP_Archive_FindFirst()
  While IsOk = #Z_OK
    If IsOk = PureZIP_Archive_Extract("c:\", #False)
      Debug "Ok"
    Else
      Debug "Extraction problem"
      PureZIP_Archive_FileInfo(@FileInfo.PureZIP_FileInfo)
      If FileSize("c:\" + FileInfo\FileName) = 0
        Debug "Zero length = deleting"
        DeleteFile("c:\" + FileInfo\FileName)
      EndIf
    EndIf
    IsOk = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf?!Micko wrote:gnozal i'm working with your last code but it seems to work when the total files in zip not Exceed 10 else i get this message "Extraction problem", but couldn't delete files.
Code: Select all
If PureZIP_Archive_Read("c:\test.zip") 
  IsOk = PureZIP_Archive_FindFirst() 
  While IsOk = #Z_OK 
    If IsOk = PureZIP_Archive_Extract("c:", #False) 
      Debug "Ok" 
    Else 
      PureZIP_Archive_FileInfo(@FileInfo.PureZIP_FileInfo) 
      Debug "Extraction problem for " + FileInfo\FileName
      If FileSize("c:" + FileInfo\FileName) = 0 
        Debug "Zero length = deleting " + FileInfo\FileName
        DeleteFile("c:" + FileInfo\FileName)
        Debug "And exiting .."
        Break
      EndIf 
    EndIf 
    IsOk = PureZIP_Archive_FindNext() 
  Wend 
  PureZIP_Archive_Close() 
EndIfoh yes ! i forgotgnozal wrote:Just a thought : if you have read-only files, of course it won't work : you have to reset the read-only attribute before deleting.
Code: Select all
If FileSize("c:\" + FileInfo\FileName) = 0 Code: Select all
If PureZIP_Archive_Create(MyZIP.s, #APPEND_STATUS_CREATE)
Size.q = FileInfo\unCompressedSize & $FFFFFFFF
Size.q = filesize(MyZIPFile1.s)
 PureZIP_Archive_Compress(MyZIPFile1.s, #FALSE)
  PureZIP_Archive_Close()
EndIf