Inkrementelles Backup mit PureZip ?!

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Ghosty1967
Beiträge: 205
Registriert: 29.08.2005 13:56
Computerausstattung: Intel i7, 128GB Ram, Win10 Ultimate, PB6.00 Alpha 3
Wohnort: Köln

Beitrag von Ghosty1967 »

ok, thats the code to check, if a file already exists inside the archive... i understand how to handle - but...
at the moment, i use this code to pack all files inside a directory to an archive:

Code: Alles auswählen

SOURCE.s      =C:\pstand\calstand\Kalibrieraufbau\KABS-Absolutdruck\*.*
DESTINATION.s =O:\Sales and Aftersales\WorkshopE\4-KABS.zip

PureZIP_AddFiles(DESTINATION, SOURCE, #PureZIP_StorePathRelative, #PureZIP_Recursive)
and it works fine. But i think, i have to use
PureZIP_AddFiles()
PureZIP_Archive_Create()
PureZIP_Archive_Compress()
to create the archive and add files to it. I dont know how to use it. :? If possible, please give me an example!
Benutzeravatar
Thorsten1867
Beiträge: 1360
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

Beitrag von Thorsten1867 »

Code: Alles auswählen

SetCurrentDirectory(BackupSource$)
PureZIP_SetCompressionCallback(@PureZIP_CallbackC())
If PureZIP_Archive_Create(Packfile$, #APPEND_STATUS_CREATE)
  ForEach SrcFiles()
    If SrcFiles()\update
      PureZIP_Archive_Compress(SrcFiles()\Name, #True)
    EndIf
  Next
  PureZIP_Archive_Close()
EndIf
SetCurrentDirectory(ProgDir$)
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Benutzeravatar
Thorsten1867
Beiträge: 1360
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

Beitrag von Thorsten1867 »

Das wirst du wahrscheinlich auch brauchen:

Code: Alles auswählen

Procedure.s GetFileNamePart(thFile.s) ; Filename without extension
  Protected ext.s = GetExtensionPart(thFile)
  thFile = GetFilePart(thFile)
  If ext And thFile
    ProcedureReturn Left(thFile, Len(thFile)-Len(ext)-1)
  Else
    ProcedureReturn thFile
  EndIf
EndProcedure

Procedure.s ValidDir(thPath.s) ; Make sure '\' is at the end 
  If thPath And Right(thPath, 1) <> "\" 
    thPath + "\" 
  EndIf
  ProcedureReturn thPath
EndProcedure


Procedure.s GetZipPartName(TargetDir.s, Packfile.s)
  FileName.s = GetFileNamePart(Packfile)
  TargetDir = ValidDir(TargetDir)
  ext.s = GetExtensionPart(Packfile)
  While FileExist(TargetDir+FileName+"."+ext)
    If ext = "zip"
      ext = "z01"
    Else
      ext = "z"+RSet(Str(Val(Right(ext, 2)) + 1), 2, "0")
    EndIf
    If ext = "z00" : Break : EndIf
  Wend
  ProcedureReturn TargetDir+FileName+"."+ext
EndProcedure
Damit kannst du die Dateinamen für die Archive (z.B. *.z01) mit den geänderten Dateien ermitteln.
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Antworten