Code please ...Micko wrote:when i compress folder include application, setup and text files everything is ok but when extracting these files the exe seems corrupt.
PureZIP library : ZIP / UNZIP files
Moderator: gnozal
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
this one
Code: Select all
;Auteur: Micko
;version: Démo
;{- Enumerations
;{ Windows
Enumeration
#Window_0
EndEnumeration
;}
;{ Menu bars
Enumeration
#Menu_Window_0
EndEnumeration
;{ Menu items
Enumeration
#Menu_Window_0_0_ExtraireUneArchive
#Menu_Window_0_0_OuvrirUneArchive
#Menu_Window_0_1_TesterUneArchive
#Menu_Window_0_2_MotDePasse
#Menu_Window_0_3_Configuration
#Menu_Window_0_4_Quitter
#Menu_Window_0_5_Compresser
#Menu_Window_0_6_CompresserAvecPassword
#Menu_Window_0_7_Decompresser
#Menu_Window_0_8_SupprimerPassword
#Menu_Window_0_9_TutorialPCDEVZIP
#Menu_Window_0_10_Enregistrement
#Menu_Window_0_11_APropos
EndEnumeration
;}
;{ Status bars
Enumeration
#StatusBar_Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#ExplorerComboGadget
#ExplorerList_1
#StatusBar
#compress
#decompress
EndEnumeration
Global Disk$
Disk$ = "C:\"
Global Window_0, ProgressBar_Compression, Text_FileProcessed, Text_1, ProgressBar_Progression
Global nom_archive.s,Chemin$,Rep$,pwd.s, repfichier$,Chemin1$,Chemin2$
;}
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 170, 90, 652, 470, "PC&DEV Compressor", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Window_0))
If CreateMenu(#Menu_Window_0, WindowID(#Window_0))
MenuTitle("Menu")
MenuItem(#Menu_Window_0_0_OuvrirUneArchive,"Ouvrir Archive")
MenuItem(#Menu_Window_0_0_ExtraireUneArchive, "Extraire Archive")
MenuItem(#Menu_Window_0_1_TesterUneArchive, "Tester Archive")
MenuItem(#Menu_Window_0_3_Configuration, "Configuration")
MenuBar()
MenuItem(#Menu_Window_0_4_Quitter, "Quitter")
MenuTitle("Commandes")
;MenuItem(#Menu_Window_0_12_Compresser, "Compresser")
MenuItem(#Menu_Window_0_5_Compresser, "Compresser")
MenuItem(#Menu_Window_0_6_CompresserAvecPassword, "Compresser avec Password")
MenuBar()
MenuItem(#Menu_Window_0_7_Decompresser, "Décompresser")
MenuItem(#Menu_Window_0_8_SupprimerPassword, "Supprimer Password")
MenuTitle("Aide")
MenuItem(#Menu_Window_0_9_TutorialPCDEVZIP, "Tutorial(PC-DEV ZIP)")
MenuItem(#Menu_Window_0_10_Enregistrement, "Enregistrement")
MenuItem(#Menu_Window_0_11_APropos, "A Propos")
ExplorerComboGadget(#ExplorerComboGadget, 1, 02, 650, 200, Disk$, #PB_Explorer_Editable)
ExplorerListGadget(#ExplorerList_1, 0, 25, 651, 405, Disk$, #PB_Explorer_MultiSelect|#PB_Explorer_AutoSort|#PB_Explorer_AlwaysShowSelection|#PB_Explorer_FullRowSelect)
SetGadgetItemAttribute(#ExplorerList_1, 0,#PB_Explorer_ColumnWidth, 347)
; Gadget Resizing
PureRESIZE_SetGadgetResize(#ExplorerList_1, 1, 1, 1, 1)
PureRESIZE_SetGadgetResize(#ExplorerComboGadget, 1, 1, 1, 1)
EndIf
EndIf
EndProcedure
Procedure CompresserArchive()
If GetGadgetState(#ExplorerList_1) > -1
Rep$ = "Archive"
CreateDirectory(GetTemporaryDirectory()+Rep$)
Chemin$ = GetPathPart(GetTemporaryDirectory())+ Rep$ + "\"
nom_archive.s = InputRequester("Nom de l'archive","Saisissez le nom de l'archive","Archive.zip")
If Chemin$ ; And nom_archive$ And destination$
For i = 0 To CountGadgetItems(#ExplorerList_1) - 1
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Selected ;un élément est sélectionné et c'est ...
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_File ; ... un fichier
CopyFile(GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), Chemin$ + GetGadgetItemText(#ExplorerList_1, i, 0))
ElseIf GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Directory ; ... un répertoire
CopyDirectory(GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), Chemin$ + GetGadgetItemText(#ExplorerList_1, i, 0) , "*.*" ,#PB_FileSystem_Recursive)
EndIf:EndIf
Next
PureZIP_AddFiles(GetTemporaryDirectory()+"\"+ nom_archive, Chemin$ + "*.*", #PureZIP_StorePathRelative ,#PureZIP_RecursiveZeroDirs)
;PureZIP_SetCompressionAlgorithm(#Z_NO_COMPRESSION)
PureZIP_Archive_Close()
Else
MessageRequester("Compressor","Véririfier le nom et la destination de l'archive !",#MB_ICONERROR)
EndIf
DeleteDirectory(Chemin$,"*.*",#PB_FileSystem_Recursive)
;DeleteFile(GetTemporaryDirectory()+ nom_archive$)
Else
MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR)
EndIf
EndProcedure
Procedure statusbar1()
Protected Nombre_Elements
Nombre_Elements = CountGadgetItems(#ExplorerList_1)
If CreateStatusBar(#StatusBar_Window_0, WindowID(#Window_0))
AddStatusBarField(175)
AddStatusBarField(480)
StatusBarText(#StatusBar_Window_0, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised)
AddStatusBarField(679)
EndIf
StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " "+"élément(s)")
EndProcedure
OpenWindow_Window_0()
statusbar1()
Repeat
Select WaitWindowEvent()
; ///////////////////
Case #PB_Event_Menu
Select EventMenu()
Case #Menu_Window_0_5_Compresser: CompresserArchive()
Case #Menu_Window_0_7_Decompresser
Case #Menu_Window_0_0_ExtraireUneArchive:
Case #Menu_Window_0_0_OuvrirUneArchive
Case #Menu_Window_0_1_TesterUneArchive
Case #Menu_Window_0_2_MotDePasse:
Case #Menu_Window_0_3_Configuration:
Case #Menu_Window_0_4_Quitter:Break
EndSelect
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
Select EventGadget()
Case #ExplorerComboGadget
SetGadgetText(#ExplorerList_1, GetGadgetText(#ExplorerComboGadget))
If EventType() = #PB_EventType_Change
Nombre_Elements = CountGadgetItems(#ExplorerList_1)
StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " élément(s)") :EndIf
Case #ExplorerList_1
If EventType() = #PB_EventType_LeftDoubleClick
SetGadgetText(#ExplorerComboGadget,GetGadgetText(#ExplorerList_1)): EndIf
EndSelect
; //////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
Break
EndIf
EndSelect
ForEver
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
1. Once again, there is the same error in the code. Please study the PureZIP help file and examples.Micko wrote:this oneCode: Select all
...
Code: Select all
PureZIP_AddFiles(GetTemporaryDirectory()+""+ nom_archive, Chemin$ + "*.*", #PureZIP_StorePathRelative ,#PureZIP_RecursiveZeroDirs)
;PureZIP_SetCompressionAlgorithm(#Z_NO_COMPRESSION)
PureZIP_Archive_Close()
PureZIP_Archive_Create() and PureZIP_Archive_Close() are used to open / close an archive together with the PureZIP_Archive_* functions.
PureZIP_AddFiles() is standalone, you don't have to open / close the archive.
2. I don't understand the meaning of this part of the code (looks like a copy / paste from a post in the french forum) :
Code: Select all
For i = 0 To CountGadgetItems(#ExplorerList_1) - 1
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Selected ;un élément est sélectionné et c'est ...
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_File ; ... un fichier
CopyFile(GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), Chemin$ + GetGadgetItemText(#ExplorerList_1, i, 0))
ElseIf GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Directory ; ... un répertoire
CopyDirectory(GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), Chemin$ + GetGadgetItemText(#ExplorerList_1, i, 0) , "*.*" ,#PB_FileSystem_Recursive)
EndIf:EndIf
Next
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
i w'll do it.Please study the PureZIP help file and examples.
now i undertandPureZIP_AddFiles() is standalone, you don't have to open / close the archive.
yes i use thid part to copy the files before compressionI don't understand the meaning of this part of the code (looks like a copy / paste from a post in the french forum)
thanks boss now i'ts clear but i will check the help

hi gnozal
i have some trouble when this part of the code is enable but i need that
SetGadgetText(Text_FileProcessed, GetFilePart(File))
SetGadgetState(ProgressBar_Compression, PerCent.f)
can't compress all selected files and folder
i don' know what goes wrong.
i have some trouble when this part of the code is enable but i need that
SetGadgetText(Text_FileProcessed, GetFilePart(File))
SetGadgetState(ProgressBar_Compression, PerCent.f)
can't compress all selected files and folder
i don' know what goes wrong.
Code: Select all
;Auteur: Micko
;version: Démo
;{- Enumerations
;{ Windows
Enumeration
#Window_0
#Window_2
#Progression
EndEnumeration
;}
;{ Menu bars
Enumeration
#Menu_Window_0
EndEnumeration
;{ Menu items
Enumeration
#Menu_Window_0_0_ExtraireUneArchive
#Menu_Window_0_0_OuvrirUneArchive
#Menu_Window_0_1_TesterUneArchive
#Menu_Window_0_2_MotDePasse
#Menu_Window_0_3_Configuration
#Menu_Window_0_4_Quitter
#Menu_Window_0_5_Compresser
#Menu_Window_0_6_CompresserAvecPassword
#Menu_Window_0_7_Decompresser
#Menu_Window_0_8_SupprimerPassword
#Menu_Window_0_9_TutorialPCDEVZIP
#Menu_Window_0_10_Enregistrement
#Menu_Window_0_11_APropos
EndEnumeration
;}
;{ Status bars
Enumeration
#StatusBar_Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#ExplorerComboGadget
#ExplorerList_1
#StatusBar
#compress
#decompress
#Text_10
#String_9
#Text_18
#String_17
#Button_12
#Frame3D_16
#Text_12
#ComboBox_13
#Text_14
#ComboBox_15
#Frame3DGadget_245
#TextGadget_244
#StringGadget_246
#TextGadget_243
#StringGadget_247
#CheckBoxGadget_242
#CheckBoxGadget_241
#ButtonGadget_240
#ButtonGadget_239
#Button_4
#Txt1
#Txt2
EndEnumeration
Global Disk$
Disk$ = "C:\"
Global Window_0, ProgressBar_Compression, Text_FileProcessed, Text_1, ProgressBar_Progression
Global nom_archive.s,Chemin$,Rep$,pwd.s, repfichier$,Chemin1$,Chemin2$
;}
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 170, 90, 652, 470, "PC&DEV Compressor", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Window_0))
If CreateMenu(#Menu_Window_0, WindowID(#Window_0))
MenuTitle("Menu")
MenuItem(#Menu_Window_0_0_OuvrirUneArchive,"Ouvrir Archive")
MenuItem(#Menu_Window_0_0_ExtraireUneArchive, "Extraire Archive")
MenuItem(#Menu_Window_0_1_TesterUneArchive, "Tester Archive")
MenuItem(#Menu_Window_0_3_Configuration, "Configuration")
MenuBar()
MenuItem(#Menu_Window_0_4_Quitter, "Quitter")
MenuTitle("Commandes")
;MenuItem(#Menu_Window_0_12_Compresser, "Compresser")
MenuItem(#Menu_Window_0_5_Compresser, "Compresser")
MenuItem(#Menu_Window_0_6_CompresserAvecPassword, "Compresser avec Password")
MenuBar()
MenuItem(#Menu_Window_0_7_Decompresser, "Décompresser")
MenuItem(#Menu_Window_0_8_SupprimerPassword, "Supprimer Password")
MenuTitle("Aide")
MenuItem(#Menu_Window_0_9_TutorialPCDEVZIP, "Tutorial(PC-DEV ZIP)")
MenuItem(#Menu_Window_0_10_Enregistrement, "Enregistrement")
MenuItem(#Menu_Window_0_11_APropos, "A Propos")
ExplorerComboGadget(#ExplorerComboGadget, 1, 02, 650, 200, Disk$, #PB_Explorer_Editable)
ExplorerListGadget(#ExplorerList_1, 0, 25, 651, 405, Disk$, #PB_Explorer_MultiSelect|#PB_Explorer_AutoSort|#PB_Explorer_AlwaysShowSelection|#PB_Explorer_FullRowSelect)
SetGadgetItemAttribute(#ExplorerList_1, 0,#PB_Explorer_ColumnWidth, 347)
; Gadget Resizing
PureRESIZE_SetGadgetResize(#ExplorerList_1, 1, 1, 1, 1)
PureRESIZE_SetGadgetResize(#ExplorerComboGadget, 1, 1, 1, 1)
EndIf
EndIf
EndProcedure
Procedure OpenWindow_Archive()
If OpenWindow(#Window_2, 587, 257, 353, 350, "Ajouter Archive", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
SmartWindowRefresh(#Window_2, 1)
StickyWindow(#Window_2, 1)
If CreateGadgetList(WindowID(#Window_2))
TextGadget(#Text_10, 7, 21, 80, 15, "Nom de l'archive")
StringGadget(#String_9, 92, 16, 221, 20, "")
TextGadget(#Text_18, 8, 55, 65, 15, "Emplacement")
StringGadget(#String_17, 92, 50, 220, 20, "")
ButtonGadget(#Button_12, 318, 51, 25, 20, "...")
Frame3DGadget(#Frame3D_16, 10, 85, 330, 85, "Option de Compression")
TextGadget(#Text_12, 25, 105, 90, 15, "Format de l'archive")
ComboBoxGadget(#ComboBox_13, 220, 100, 105, 100):DisableGadget(#ComboBox_13,1)
AddGadgetItem(#ComboBox_13, 0, "Zip")
AddGadgetItem(#ComboBox_13, 1, "Arj")
AddGadgetItem(#ComboBox_13, 2, "Ace")
SetGadgetState(#ComboBox_13, 0)
;DisableGadget(#ComboBox_13,1)
TextGadget(#Text_14, 25, 135, 110, 15, "Type de compresssion")
ComboBoxGadget(#ComboBox_15, 220, 135, 105, 100):DisableGadget(#ComboBox_15,1)
AddGadgetItem(#ComboBox_15, 0, "Normal")
AddGadgetItem(#ComboBox_15, 1, "Deflate")
SetGadgetState(#ComboBox_15, 0)
;DisableGadget(#ComboBox_15,1)
Frame3DGadget(#Frame3DGadget_245, 10, 182, 330, 135, "Mot de Passe")
TextGadget(#TextGadget_244, 20, 200, 118, 15, "Entrer le mot de passe")
StringGadget(#StringGadget_246, 165, 235, 160, 20, "", #PB_String_Password)
TextGadget(#TextGadget_243, 20, 240, 128, 15, "Confirmer le mot de passe")
StringGadget(#StringGadget_247, 165, 199, 160, 20, "", #PB_String_Password)
CheckBoxGadget(#CheckBoxGadget_242, 20, 269, 140, 15, "Afficher le mot de Passe")
CheckBoxGadget(#CheckBoxGadget_241, 20, 294, 180, 15, "Crypter le nom des fichiers"):DisableGadget(#CheckBoxGadget_241,1)
ButtonGadget(#ButtonGadget_240, 218, 324, 60, 20, "OK")
ButtonGadget(#ButtonGadget_239, 288, 325, 54, 19, "Annuler")
;DisableGadget(#CheckBoxGadget_241,1)
EndIf
EndIf
EndProcedure
Procedure Open_Window()
Window_0 = OpenWindow(#Progression, 382, 285, 315, 128, "Compressor",#PB_Window_TitleBar | #PB_Window_ScreenCentered)
If Window_0 : StickyWindow(#Progression, 1)
If CreateGadgetList(WindowID(#Progression))
ProgressBar_Compression = ProgressBarGadget(#PB_Any, 5, 25, 305, 20, 0, 100)
Text_FileProcessed = TextGadget(#Txt1, 74, 4, 150, 15, "Extraction des fichiers...", #PB_Text_Center)
Text_1 = TextGadget(#Txt2, 100, 58, 100, 15, "Progression...", #PB_Text_Center)
ProgressBar_Progression = ProgressBarGadget(#PB_Any, 5, 77, 305, 20, 0, 100)
ButtonGadget(#Button_4, 240, 106, 70, 18, "Annuler")
EndIf
EndIf
EndProcedure
Procedure Close_Window()
CloseWindow(Window_0)
EndProcedure
Procedure PureZIP_CallbackC(File.s, PerCent.f)
SetGadgetText(Text_FileProcessed, GetFilePart(File))
SetGadgetState(ProgressBar_Compression, PerCent.f)
While WindowEvent() : Wend
EndProcedure
Procedure PureZIP_CallbackP(File.s, PerCent.f)
SetGadgetState(ProgressBar_Progression, PerCent.f)
While WindowEvent() : Wend
EndProcedure
;
myFileinfo.PureZIP_FileInfo
PureZIP_SetProgressionCallback(@PureZIP_CallbackP())
PureZIP_SetCompressionCallback(@PureZIP_CallbackC())
Procedure CompresserArchive()
If GetGadgetState(#ExplorerList_1) > -1
Rep$ = "Archive"
nom_archive$ = GetGadgetText(#String_9)
destination$ = GetGadgetText(#String_17)
If nom_archive$ And destination$ :CloseWindow(#Window_2)
For i = 0 To CountGadgetItems(#ExplorerList_1) - 1
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Selected ;un élément est sélectionné et c'est ...
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Directory ; ... un répertoire
Debug GetGadgetItemText(#ExplorerList_1, i, 0) + " est sélectionné et c'est un dossier"
PureZIP_AddFiles(destination$ + nom_archive$,GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0)+"\" + "*.*", #PureZIP_StorePathRelative ,#PureZIP_NotRecursive)
ElseIf GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_File ; ... un fichier
Debug GetGadgetItemText(#ExplorerList_1, i, 0) + " est sélectionné et c'est un fichier"
PureZIP_AddFiles(destination$ + nom_archive$,GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), #PureZIP_StorePathRelative ,#PureZIP_Recursive)
EndIf: EndIf
Next
Else
MessageRequester("Compressor","Véririfier le nom et la destination de l'archive !",#MB_ICONERROR)
EndIf
Else
MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR)
EndIf
EndProcedure
Procedure statusbar1()
Protected Nombre_Elements
Nombre_Elements = CountGadgetItems(#ExplorerList_1)
If CreateStatusBar(#StatusBar_Window_0, WindowID(#Window_0))
AddStatusBarField(175)
AddStatusBarField(480)
StatusBarText(#StatusBar_Window_0, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised)
AddStatusBarField(679)
EndIf
StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " "+"élément(s)")
EndProcedure
OpenWindow_Window_0()
statusbar1()
Repeat
Select WaitWindowEvent()
; ///////////////////
Case #PB_Event_Menu
Select EventMenu()
Case #Menu_Window_0_5_Compresser
If GetGadgetState(#ExplorerList_1) > -1
OpenWindow_Archive() : SetGadgetText(#String_9,"Archive.zip")
Else:MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR)
EndIf
Case #Menu_Window_0_7_Decompresser
Case #Menu_Window_0_0_ExtraireUneArchive:
Case #Menu_Window_0_0_OuvrirUneArchive
Case #Menu_Window_0_1_TesterUneArchive
Case #Menu_Window_0_2_MotDePasse:
Case #Menu_Window_0_3_Configuration:
Case #Menu_Window_0_4_Quitter:Break
EndSelect
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
Select EventGadget()
Case #ExplorerComboGadget
SetGadgetText(#ExplorerList_1, GetGadgetText(#ExplorerComboGadget))
If EventType() = #PB_EventType_Change
Nombre_Elements = CountGadgetItems(#ExplorerList_1)
StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " élément(s)") :EndIf
Case #ButtonGadget_239
CloseWindow(#Window_2)
Case #ButtonGadget_240
nom_archive$ = GetGadgetText(#String_9)
destination$ = GetGadgetText(#String_17)
pwd$ = GetGadgetText(#StringGadget_246)
pwd2$ = GetGadgetText(#StringGadget_246)
If nom_archive$ <> "" And destination$ <> "" And pwd$ = pwd2$ And pwd$ = "" And pwd2$ = ""
SetWindowState(#Window_0,#PB_Window_Minimize)
Open_Window()
CompresserArchive():Close_Window():SetWindowState(#Window_0,#PB_Window_Normal)
ElseIf nom_archive$ <> "" And destination$ <> "" And pwd$ <> "" And pwd2$ <> "" And pwd$ = pwd2$
SetWindowState(#Window_0,#PB_Window_Minimize)
Open_Window()
;CompresserArchive_Pwd() :Close_Window():SetWindowState(#Window_0,#PB_Window_Normal)
Else
MessageRequester("Compressor","Véririfier nom, destination ou mot de passe SVP !",#MB_ICONERROR)
SetGadgetText(#StringGadget_246,""):SetGadgetText(#StringGadget_247,""):SetGadgetState(#StringGadget_246,1)
EndIf
Case #ExplorerList_1
; If EventType() = #PB_EventType_LeftDoubleClick
; SetGadgetText(#ExplorerComboGadget,GetGadgetText(#ExplorerList_1)): EndIf
EndSelect
; //////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
Break
ElseIf EventWindow = #Window_2
CloseWindow(#Window_2)
EndIf
EndSelect
ForEver
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
This problem is not really PureZIP related ...Micko wrote:hi gnozal
i have some trouble when this part of the code is enable but i need that
SetGadgetText(Text_FileProcessed, GetFilePart(File))
SetGadgetState(ProgressBar_Compression, PerCent.f)
can't compress all selected files and folder
i don' know what goes wrong.
Try this :
Code: Select all
Procedure Open_Window()
Window_0 = OpenWindow(#PB_Any, 382, 285, 315, 128, "Compressor",#PB_Window_TitleBar | #PB_Window_ScreenCentered)
If Window_0 : StickyWindow(Window_0, 1)
If CreateGadgetList(WindowID(Window_0))
ProgressBar_Compression = ProgressBarGadget(#PB_Any, 5, 25, 305, 20, 0, 100)
Text_FileProcessed = TextGadget(#PB_Any, 74, 4, 150, 15, "Extraction des fichiers...", #PB_Text_Center)
Text_1 = TextGadget(#PB_Any, 100, 58, 100, 15, "Progression...", #PB_Text_Center)
ProgressBar_Progression = ProgressBarGadget(#PB_Any, 5, 77, 305, 20, 0, 100)
ButtonGadget(#Button_4, 240, 106, 70, 18, "Annuler")
EndIf
EndIf
EndProcedure
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
What does not work ?Micko wrote: > try this
yes i tried but not work
If I replace your procedure with mine the progression is displayed correctly while compression.
I did not debug the rest of your code.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
I just tried, it works.Inf0Byt3 wrote:@Gnozal, your DLL link seems to be broken. Can you please fix it?
Sometimes freenet.de seems broken, just try again.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Please gnozal try this
can't compress all selected files and folders but the progression is displayed correctly while compression
can't compress all selected files and folders but the progression is displayed correctly while compression
Code: Select all
;Auteur: Micko
;version: Démo
;{- Enumerations
;{ Windows
Enumeration
#Window_0
#Window_2
#Progression
EndEnumeration
;}
;{ Menu bars
Enumeration
#Menu_Window_0
EndEnumeration
;{ Menu items
Enumeration
#Menu_Window_0_0_ExtraireUneArchive
#Menu_Window_0_0_OuvrirUneArchive
#Menu_Window_0_1_TesterUneArchive
#Menu_Window_0_2_MotDePasse
#Menu_Window_0_3_Configuration
#Menu_Window_0_4_Quitter
#Menu_Window_0_5_Compresser
#Menu_Window_0_6_CompresserAvecPassword
#Menu_Window_0_7_Decompresser
#Menu_Window_0_8_SupprimerPassword
#Menu_Window_0_9_TutorialPCDEVZIP
#Menu_Window_0_10_Enregistrement
#Menu_Window_0_11_APropos
EndEnumeration
;}
;{ Status bars
Enumeration
#StatusBar_Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#ExplorerComboGadget
#ExplorerList_1
#StatusBar
#compress
#decompress
#Text_10
#String_9
#Text_18
#String_17
#Button_12
#Frame3D_16
#Text_12
#ComboBox_13
#Text_14
#ComboBox_15
#Frame3DGadget_245
#TextGadget_244
#StringGadget_246
#TextGadget_243
#StringGadget_247
#CheckBoxGadget_242
#CheckBoxGadget_241
#ButtonGadget_240
#ButtonGadget_239
#Button_4
EndEnumeration
Global Disk$
Disk$ = "C:\"
Global Window_0, ProgressBar_Compression, Text_FileProcessed, Text_1, ProgressBar_Progression
Global nom_archive.s,destination$,pwd$,pwd2$, repfichier$
;}
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 170, 90, 652, 470, "PC&DEV Compressor", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SmartWindowRefresh(#Window_0, 1)
CreateGadgetList(WindowID(#Window_0))
If CreateMenu(#Menu_Window_0, WindowID(#Window_0))
MenuTitle("Menu")
MenuItem(#Menu_Window_0_0_OuvrirUneArchive,"Ouvrir Archive")
MenuItem(#Menu_Window_0_0_ExtraireUneArchive, "Extraire Archive")
MenuItem(#Menu_Window_0_1_TesterUneArchive, "Tester Archive")
MenuItem(#Menu_Window_0_3_Configuration, "Configuration")
MenuBar()
MenuItem(#Menu_Window_0_4_Quitter, "Quitter")
MenuTitle("Commandes")
;MenuItem(#Menu_Window_0_12_Compresser, "Compresser")
MenuItem(#Menu_Window_0_5_Compresser, "Compresser")
MenuItem(#Menu_Window_0_6_CompresserAvecPassword, "Compresser avec Password")
MenuBar()
MenuItem(#Menu_Window_0_7_Decompresser, "Décompresser")
MenuItem(#Menu_Window_0_8_SupprimerPassword, "Supprimer Password")
MenuTitle("Aide")
MenuItem(#Menu_Window_0_9_TutorialPCDEVZIP, "Tutorial(PC-DEV ZIP)")
MenuItem(#Menu_Window_0_10_Enregistrement, "Enregistrement")
MenuItem(#Menu_Window_0_11_APropos, "A Propos")
ExplorerComboGadget(#ExplorerComboGadget, 1, 02, 650, 200, Disk$, #PB_Explorer_Editable)
ExplorerListGadget(#ExplorerList_1, 0, 25, 651, 405, Disk$, #PB_Explorer_MultiSelect|#PB_Explorer_AutoSort|#PB_Explorer_AlwaysShowSelection|#PB_Explorer_FullRowSelect)
SetGadgetItemAttribute(#ExplorerList_1, 0,#PB_Explorer_ColumnWidth, 347)
; Gadget Resizing
PureRESIZE_SetGadgetResize(#ExplorerList_1, 1, 1, 1, 1)
PureRESIZE_SetGadgetResize(#ExplorerComboGadget, 1, 1, 1, 1)
EndIf
EndIf
EndProcedure
Procedure OpenWindow_Archive()
If OpenWindow(#Window_2, 587, 257, 353, 350, "Ajouter Archive", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
SmartWindowRefresh(#Window_2, 1)
StickyWindow(#Window_2, 1)
If CreateGadgetList(WindowID(#Window_2))
TextGadget(#Text_10, 7, 21, 80, 15, "Nom de l'archive")
StringGadget(#String_9, 92, 16, 221, 20, "")
TextGadget(#Text_18, 8, 55, 65, 15, "Emplacement")
StringGadget(#String_17, 92, 50, 220, 20, "")
ButtonGadget(#Button_12, 318, 51, 25, 20, "...")
Frame3DGadget(#Frame3D_16, 10, 85, 330, 85, "Option de Compression")
TextGadget(#Text_12, 25, 105, 90, 15, "Format de l'archive")
ComboBoxGadget(#ComboBox_13, 220, 100, 105, 100):DisableGadget(#ComboBox_13,1)
AddGadgetItem(#ComboBox_13, 0, "Zip")
AddGadgetItem(#ComboBox_13, 1, "Arj")
AddGadgetItem(#ComboBox_13, 2, "Ace")
SetGadgetState(#ComboBox_13, 0)
TextGadget(#Text_14, 25, 135, 110, 15, "Type de compresssion")
ComboBoxGadget(#ComboBox_15, 220, 135, 105, 100):DisableGadget(#ComboBox_15,1)
AddGadgetItem(#ComboBox_15, 0, "Normal")
AddGadgetItem(#ComboBox_15, 1, "Deflate")
SetGadgetState(#ComboBox_15, 0)
Frame3DGadget(#Frame3DGadget_245, 10, 182, 330, 135, "Mot de Passe")
TextGadget(#TextGadget_244, 20, 200, 118, 15, "Entrer le mot de passe")
StringGadget(#StringGadget_246, 165, 235, 160, 20, "", #PB_String_Password)
TextGadget(#TextGadget_243, 20, 240, 128, 15, "Confirmer le mot de passe")
StringGadget(#StringGadget_247, 165, 199, 160, 20, "", #PB_String_Password)
CheckBoxGadget(#CheckBoxGadget_242, 20, 269, 140, 15, "Afficher le mot de Passe")
CheckBoxGadget(#CheckBoxGadget_241, 20, 294, 180, 15, "Crypter le nom des fichiers"):DisableGadget(#CheckBoxGadget_241,1)
ButtonGadget(#ButtonGadget_240, 218, 324, 60, 20, "OK")
ButtonGadget(#ButtonGadget_239, 288, 325, 54, 19, "Annuler")
EndIf
EndIf
EndProcedure
Procedure Open_Window()
Window_0 = OpenWindow(#PB_Any, 382, 285, 315, 128, "Compressor",#PB_Window_TitleBar | #PB_Window_ScreenCentered)
If Window_0 : StickyWindow(Window_0, 1)
If CreateGadgetList(WindowID(Window_0))
ProgressBar_Compression = ProgressBarGadget(#PB_Any, 5, 25, 305, 20, 0, 100)
Text_FileProcessed = TextGadget(#PB_Any, 74, 4, 150, 15, "Extraction des fichiers...", #PB_Text_Center)
Text_1 = TextGadget(#PB_Any, 100, 58, 100, 15, "Progression...", #PB_Text_Center)
ProgressBar_Progression = ProgressBarGadget(#PB_Any, 5, 77, 305, 20, 0, 100)
ButtonGadget(#Button_4, 240, 106, 70, 18, "Annuler")
EndIf
EndIf
EndProcedure
Procedure Close_Window()
CloseWindow(Window_0)
EndProcedure
Procedure PureZIP_CallbackC(File.s, PerCent.f)
SetGadgetText(Text_FileProcessed, GetFilePart(File))
SetGadgetState(ProgressBar_Compression, PerCent.f)
While WindowEvent() : Wend
EndProcedure
Procedure PureZIP_CallbackP(File.s, PerCent.f)
SetGadgetState(ProgressBar_Progression, PerCent.f)
While WindowEvent() : Wend
EndProcedure
;
myFileinfo.PureZIP_FileInfo
PureZIP_SetProgressionCallback(@PureZIP_CallbackP())
PureZIP_SetCompressionCallback(@PureZIP_CallbackC())
Procedure CompresserArchive()
If GetGadgetState(#ExplorerList_1) > -1
nom_archive$ = GetGadgetText(#String_9)
destination$ = GetGadgetText(#String_17)
If nom_archive$ And destination$ :CloseWindow(#Window_2)
For i = 0 To CountGadgetItems(#ExplorerList_1) - 1
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Selected ;un élément est sélectionné et c'est ...
If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_File ; ... un fichier
Debug GetGadgetItemText(#ExplorerList_1, i, 0) + " est sélectionné et c'est un fichier"
PureZIP_AddFiles(destination$+nom_archive$,GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), #PureZIP_StorePathRelative ,#PureZIP_NotRecursive)
ElseIf GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Directory ; ... un répertoire
Debug GetGadgetItemText(#ExplorerList_1, i, 0) + " est sélectionné et c'est un dossier"
PureZIP_AddFiles(destination$+nom_archive$,GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0)+"\" + "*.*", #PureZIP_StorePathRelative ,#PureZIP_Recursive)
EndIf: EndIf
Next
Else
MessageRequester("Compressor","Véririfier le nom et la destination de l'archive !",#MB_ICONERROR)
EndIf
Else
MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR)
EndIf
EndProcedure
Procedure statusbar1()
Protected Nombre_Elements
Nombre_Elements = CountGadgetItems(#ExplorerList_1)
If CreateStatusBar(#StatusBar_Window_0, WindowID(#Window_0))
AddStatusBarField(175)
AddStatusBarField(480)
StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " "+"élément(s)")
EndIf
EndProcedure
OpenWindow_Window_0()
statusbar1()
Repeat
Select WaitWindowEvent()
; ///////////////////
Case #PB_Event_Menu
Select EventMenu()
Case #Menu_Window_0_5_Compresser
If GetGadgetState(#ExplorerList_1) > -1
OpenWindow_Archive() : SetGadgetText(#String_9,"Archive.zip")
Else:MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR)
EndIf
Case #Menu_Window_0_7_Decompresser
Case #Menu_Window_0_0_ExtraireUneArchive
Case #Menu_Window_0_0_OuvrirUneArchive
Case #Menu_Window_0_1_TesterUneArchive
Case #Menu_Window_0_2_MotDePasse:
Case #Menu_Window_0_3_Configuration
Case #Menu_Window_0_4_Quitter:Break
EndSelect
; //////////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
Select EventGadget()
Case #ExplorerComboGadget
SetGadgetText(#ExplorerList_1, GetGadgetText(#ExplorerComboGadget))
If EventType() = #PB_EventType_Change
Nombre_Elements = CountGadgetItems(#ExplorerList_1)
StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " élément(s)") :EndIf
Case #ButtonGadget_239
CloseWindow(#Window_2)
Case #ButtonGadget_240
nom_archive$ = GetGadgetText(#String_9)
destination$ = GetGadgetText(#String_17)
pwd$ = GetGadgetText(#StringGadget_246)
pwd2$ = GetGadgetText(#StringGadget_246)
If nom_archive$ <> "" And destination$ <> "" And pwd$ = pwd2$ And pwd$ = "" And pwd2$ = ""
SetWindowState(#Window_0,#PB_Window_Minimize)
Open_Window()
CompresserArchive():Close_Window():SetWindowState(#Window_0,#PB_Window_Normal)
;ElseIf nom_archive$ <> "" And destination$ <> "" And pwd$ <> "" And pwd2$ <> "" And pwd$ = pwd2$
; SetWindowState(#Window_0,#PB_Window_Minimize)
;Open_Window()
;CompresserArchive_Pwd() :Close_Window():SetWindowState(#Window_0,#PB_Window_Normal)
;Else
; MessageRequester("Compressor","Véririfier nom, destination ou mot de passe SVP !",#MB_ICONERROR)
; SetGadgetText(#StringGadget_246,""):SetGadgetText(#StringGadget_247,""):SetGadgetState(#StringGadget_246,1)
EndIf
Case #ExplorerList_1
; If EventType() = #PB_EventType_LeftDoubleClick
; SetGadgetText(#ExplorerComboGadget,GetGadgetText(#ExplorerList_1)): EndIf
EndSelect
; //////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
Break
ElseIf EventWindow = #Window_2
CloseWindow(#Window_2)
EndIf
EndSelect
ForEver
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
I would do it like this :Micko wrote:Please gnozal try this
can't compress all selected files and folders but the progression is displayed correctly while compression
1. Create new archive [PureZIP_Archive_Create()]
2. For each selected file [use recursive file search if directory selected], add file to archive [PureZIP_Archive_Compress()]
3. Close archive [PureZIP_Archive_Close()]
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).