Versions Compared

Key

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

...

When working with the SRP Zip Utility, you must first get a handle to a zip file. SRP_Zip_Open gets a handle to an existing file, or creates it if it doesn't exist. SRP_Zip_Create gets a handle to a new empty zip file. The handles are then used by the other SRP Zip Utility functions for manipulation.

You must always be sure to close a file handle using SRP_Zip_Close. This ensures that the resources are released. Forgetting to perform this step can result in resource leaks and, eventually, application hang ups. Additionally, you must always close the handle to one zip file before creating or opening another one.

...

Eventually you will access a file within a zip file, and you will need an index to refer to it. The SRP Zip Utility comes with two methods for determining file indexes. SRP_Zip_GetFileList returns an ordered list of all files within the zip file. The positions of the files within the returned list are the same as the positions within the zip file. So, you can use the position of the file as an accurate index. If you already know the file name and just need its index, then use SRP_Zip_FindFile. This method returns the index of the file if found. Once the index is obtained, you're ready to access it.

File Processing

SRP_Zip_ExtractFile is the method you will use to extract files out of a zip file. The file's contents are returned directly into a variable. To remove a file from a zip file, simply pass the file index to SRP_Zip_RemoveFileSRP_Zip_AddFile adds files to a zip file. Similar to file extraction, the new file's contents are provided via a BASIC+ variable. All three methods can be used with confidence in security.

...

A second level of security comes in the form of a Password parameter. The optional Password parameter is available in SRP_Zip_ExtractFileSRP_Zip_RemoveFile, and SRP_Zip_AddFile. Zip files store an individual password for each file it contains, although the same password is usually used for all files. If you plan to extract or remove a protected file, you must provide the password. When adding files, you may optionally provide a password to secure it.

...

Files within a zip file may include directory information, which we refer to as subdirectory associations. It is important to note that, when referencing a file by name, you must always include it's subdirectory information. Essentially, subdirectory associations allow two files of the same name to exist within the same zip file, as seen in the following image.

If you call SRP_Zip_GetFileList for the above file, you will get the following list:

...

Zip files can store a subdirectory with no file attached to it. For instance, "\Images\" may appear in the file list. This is not a bug with the SRP Zip Utility. This is just a feature of zip files in general. In fact, you can add a subdirectory with no data associated with it using SRP_Zip_AddFile, though there is usually no reason to do so. Most often, you will encounter stand alone directories in zip files generated by third party utilities or command line driven zip programs.

Any attempt to extract a subdirectory using SRP_Zip_ExtractFile results in an empty variable.

...

All routines in the SRP Zip Utility return a value. Sometimes, the value will indicate directly that an error has occurred. Usually, a zero is returned. In other cases, an empty value is return (""), which means an error returns or there was no data to retrieve. Refer to the reference documentation for any particular function's mode of operation. In all cases, use SRP_Zip_GetLastError to get a readable error message that can be displayed to the user.

...