User Tools

Site Tools


Zip List Entries

Summary

Below is an example demonstrating how you can list the contents of a zlib compressed (*.zip) file.

API Areas of Interest

Example

File_Zip_List_Entries.dsa
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	// Define the source directory path
	var sSourcePath = "c:/temp";
 
	// Create a directory object
	var oDir = new DzDir( sSourcePath );
	// Get whether or not the directory exists
	var bExists = oDir.exists();
 
	// If the directory doesn't exist
	if( !bExists ){
		// Provide feedback
		print( sSourcePath, "does not exist!" );
		// We're done...
		return;
	}
 
	// Create a zip file object
	var oZipFile = new DzZipFile( String("%1/DS_Layouts_Backup.zip").arg( sSourcePath ) );
	// If the file doesn't exist
	if( !oZipFile.exists() ){
		// Provide feedback
		print( oZipFile.filePath(), "does not exist!" );
		// We're done...
		return;
	}
 
	// Open the zip file for reading
	oZipFile.open( DzZipFile.ReadOnly );
 
	// Retrieve the names of entries in the zip
	var aNames = oZipFile.getFileNames();
 
	// Close the zip file
	oZipFile.close();
 
	// Provide feedback
	print( aNames.join("\n") );
 
// Finalize the function and invoke
})();