[Rd] R's internal tar ignores files in sub-directories

Harris A. Jaffee hj at jhu.edu
Tue Sep 30 21:28:22 CEST 2014


Sounds like a bug to me, at least in documentation.  I would say
that it ignores them by accident.  I doubt that skipping files is
intended.

The problem appears to be that the 'files' argument to tar() becomes
the 'path' argument to list.files(), and the spec for 'path' is not
a whole lot more illuminating.  Only the Description in ?list.files
refers to a _named directory_.

Your tar call blindly does list.files("foo/bar.R"), which is empty,
hence your undesired result, when it should only call list.files for
directories.

On Sep 30, 2014, at 2:14 PM, Kevin Ushey <kevinushey at gmail.com> wrote:

> E.g. I am seeing:
> 
>    dir <- file.path(tempdir(), "test-tar")
>    dir.create(dir)
>    setwd(dir)
> 
>    dir.create("foo", showWarnings = FALSE)
>    file.create("foo/bar.R")
> 
>    tar("test.tar", files = "foo/bar.R")
>    dir.create("untarred")
>    untar("test.tar", exdir = "untarred")
>    list.files("untarred", recursive = TRUE) # character(0)
> 
> As far as I can see, the documentation in `?tar` does not reflect that
> R's internal `tar` expects paths to directories, not files themselves.
> Although I would have preferred the files being included, or at least
> a warning / error that they would be excluded.
> 
> Thanks,
> Kevin
> 
>> sessionInfo()
> R version 3.1.1 Patched (2014-09-27 r66695)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> loaded via a namespace (and not attached):
> [1] tools_3.1.1
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list