diff --git a/R/backbone.R b/R/backbone.R index 82a5678b..91187818 100644 --- a/R/backbone.R +++ b/R/backbone.R @@ -10,20 +10,26 @@ fread.gzipped<-function(filepath,...){ # decompress first, fread can't read gzipped files - if (R.utils::isGzipped(filepath)){ + if (R.utils::isGzipped(filepath, method = "content")){ if(.Platform$OS.type == "unix") { - filepath=paste("gunzip -c",filepath) + # being on unix we can pass comand + cmd = paste("gunzip -c",filepath) + ## Read in the file + fread(cmd = cmd,...) } else { + # on windows we have to decompress first + ext = if( endsWith(filepath,".bgz") ) "bgz" else "gz" filepath <- R.utils::gunzip(filepath,temporary = FALSE, overwrite = TRUE, - remove = FALSE) + remove = FALSE, ext = ext, FUN = gzfile) + ## Read in the file + fread(file = filepath,...) } } - ## Read in the file - fread(filepath,...) + } # reads a table in a fast way to a dataframe