File: extract.zip.r

package info (click to toggle)
r-bioc-arrayexpress 1.66.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
extract.zip = function (file, extractpath = dirname(file)[1]) {
  topic = basename(file)
  path = dirname(file)
  if (file.exists(file.path(path, topic))){
    lapply(1:length(file), function(i) unzip(zipfile = file.path(path[i], topic[i]), exdir = extractpath))
    rc = lapply(1:length(file), function(i) unzip(zipfile = file.path(path[i], topic[i]), list = TRUE, exdir = extractpath))
    
    if(length(rc) > 1)
      rc = do.call(c, sapply(1:length(file), function(i) as.character(rc[[i]][,1])))
    else rc = as.character(rc[[1]][,1])    
    
    if(inherits(rc,"try-error"))
      stop("Cannot extract the files the downloaded archive. Please install unzip on your machine")   
  }else
    stop(sprintf("%s does not exist",file.path(path, topic)))  
  return(rc)
}