Files
openpipeline_spatial/src/utils/unzip_archived_folder.R
CI 1581a62139 Build branch openpipeline_spatial/v0.2 with version v0.2.0 to openpipeline_spatial on branch v0.2 (327d793)
Build pipeline: openpipelines-bio.openpipeline-spatial.v0.2.0-bgdj2

Source commit: 327d79399b

Source message: Merge remote-tracking branch 'origin/main' into v0.2
2026-01-26 14:02:22 +00:00

23 lines
641 B
R

extract_selected_files <- function(zip_path, members) {
# Create a temporary directory for extraction
temp_dir <- tempfile("unzip_dir_")
dir.create(temp_dir)
# List all files in the archive
all_files <- utils::unzip(zip_path, list = TRUE)$Name
# Find files matching any of the glob patterns in 'members'
selected <- unique(unlist(
lapply(members, function(pattern) {
regex <- glob2rx(pattern)
grep(regex, all_files, value = TRUE)
})
))
# Extract only the selected files
utils::unzip(zip_path, files = selected, exdir = temp_dir)
# Return the path to the extracted folder
file.path(temp_dir)
}