Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Syntax

Code Block
Result = SRP_Zip_AddFile(ZipHandle, FileName, Data, Password, Compression)

Returns

1 if successful, 0 if not.

Parameters

ZipHandle Handle to an opened zip file.

...

Compression The compression level. Optional.

Remarks

Call this routine to add a file to the zip file. This method requires that you pass the contents of the file. The Filename parameter is only used to name to file within the zip file. For instance, if you want to store OSFile.dat into the ZIP file as MyZipFile.dat, you must first load OSFile.dat into a variable using OSRead and call AddFile passing "MyZipFile.dat" as the FileName and passing the actual file contents via the Data parameter. You may optionally use the Password parameter to protect the added file.

...

To include subdirectory information, just prefix it to the filename. For example, pass "Images\MyImage.BMP" instead of just "MyImage.BMP". Subdirectory information will distinguish similar file names. Using the same example, you can add both "Images\MyImage.BMP" and "MyImage.BMP" to a zip file, and they will both be included as separate entities.

Examples

Code Block
// load an OS file into a variable and add it to a new zip file
hZip = SRP_Zip_Create("C:\MyFile.zip")
If hZip EQ 0 then
   Call Msg(@Window, SRP_Zip_GetLastError())
end else
  
   // notice how we can add the same data as 3 files with different subdirectories
   OSRead Data from "C:\sample.bmp" then
       rv = SRP_Zip_AddFile(hZip, "Test\Images\MyImage.BMP", Data)
       rv = SRP_Zip_AddFile(hZip, "Images\MyImage.BMP", Data)
       rv = SRP_Zip_AddFile(hZip, "MyImage.BMP", Data)
   end
  
   SRP_Zip_Close(hZip)
end

...