PowerBuilder
PowerBuilder
Find a ZIP Entry by Exact Path Using EntryOf
See more Zip Examples
This example demonstrates how to use the EntryOf method to find a ZIP entry whose stored path exactly matches a specified path.
Unlike EntryMatching, which performs wildcard matching, EntryOf performs an exact path lookup.
This method is useful when:
- The exact ZIP path is already known
- Retrieving a specific file or directory entry
- Verifying whether a particular entry exists in the ZIP archive
Suppose the ZIP archive contains:
docs/
docs/readme.txt
docs/manual.pdf
images/logo.png
data/config/settings.json ZIP archives may optionally contain explicit directory entries such as docs/. These directory entries can also be retrieved using EntryOf.
The example:
- Finds an exact file entry
- Finds an exact directory entry
- Demonstrates the difference between file and directory entries
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Zip
oleobject loo_Entry
li_Success = 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
li_Success = 0
// Open an existing ZIP archive.
loo_Zip = create oleobject
li_rc = loo_Zip.ConnectToNewObject("Chilkat.Zip")
if li_rc < 0 then
destroy loo_Zip
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Zip.OpenZip("example.zip")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
loo_Entry = create oleobject
li_rc = loo_Entry.ConnectToNewObject("Chilkat.ZipEntry")
// ------------------------------------------------------------
// Find a specific file entry by its exact ZIP path.
li_Success = loo_Zip.EntryOf("docs/readme.txt",loo_Entry)
if li_Success = 1 then
Write-Debug "Found file entry:"
Write-Debug " FileName = " + loo_Entry.FileName
Write-Debug " IsDirectory = " + string(loo_Entry.IsDirectory)
Write-Debug ""
end if
// ------------------------------------------------------------
// Find a directory entry.
//
// ZIP archives may optionally contain explicit directory entries.
// In this example, "docs/" is a separate directory entry.
li_Success = loo_Zip.EntryOf("docs/",loo_Entry)
if li_Success = 1 then
Write-Debug "Found directory entry:"
Write-Debug " FileName = " + loo_Entry.FileName
Write-Debug " IsDirectory = " + string(loo_Entry.IsDirectory)
Write-Debug ""
end if
// ------------------------------------------------------------
// Attempt to find a non-existent entry.
li_Success = loo_Zip.EntryOf("images/missing.png",loo_Entry)
if li_Success = 0 then
Write-Debug "The entry images/missing.png was not found."
end if
loo_Zip.CloseZip()
Write-Debug "Done."
destroy loo_Zip
destroy loo_Entry