// Unzips a ZIP archive and recreates the folders and file structure within it locally
Unzips a ZIP archive and recreates the folders and file structure within it locally
// Unzips a ZIP archive and recreates the folders and file structure within it locally
func unzip(sourceFileLocation, targetLocation string, pathMap map[string]bool, fileCreator FileCreator, directoryCreator DirectoryCreator, existingFileReader FileReader)	 error {
	reader, err := zip.OpenReader(sourceFileLocation)
	if err != nil {
		return err
	}
	if targetLocation != "" {
		if err := directoryCreator(targetLocation, 0755); err != nil {
			return err
		}
	}
	for _, file := range reader.File {
		path := filepath.Join(targetLocation, filepath.FromSlash(file.Name))
		_, fileAlreadyWritten := pathMap[path]
		if !fileAlreadyWritten {
			pathMap[path] = true
		}
		readFileFromZipAndWriteToFilesystem(file, path, fileAlreadyWritten, fileCreator, directoryCreator, existingFileReader)
	}
	return nil
}
func unzip ( sourceFileLocation , targetLocation string , pathMap map [ string ] bool , fileCreator FileCreator , directoryCreator DirectoryCreator , existingFileReader FileReader ) error { reader , err := zip . OpenReader ( sourceFileLocation ) if err != nil { return err } if targetLocation != " " { if err := directoryCreator ( targetLocation , 0755 ) ; err != nil { return err } } for _ , file := range reader . File { path := filepath . Join ( targetLocation , filepath . FromSlash ( file . Name ) ) _ , fileAlreadyWritten := pathMap [ path ] if ! fileAlreadyWritten { pathMap [ path ] = true } readFileFromZipAndWriteToFilesystem ( file , path , fileAlreadyWritten , fileCreator , directoryCreator , existingFileReader ) } return nil }
Unzips a ZIP archive and recreates the folders and file structure within it locally
Unzips a ZIP archive and recreates the folders and file structure within it locally
// If we have a non-empty target directory, ensure it exists // Check to see if we've already written to this file in this retrieve