[Rd] Fwd: file mode lost in file.copy()?
Henrik Bengtsson
hb at biostat.ucsf.edu
Mon Mar 7 05:26:22 CET 2011
FYI,
this seems to be a known problem that has been address in the the
devel version. From NEWS of R v2.13.0 devel:
NEW FEATURES:
- file.copy() now copies read/write/execute permissions on files (it
already did so for directories in recursive copies).
Source: http://cran.r-project.org/bin/windows/base/NEWS.R-2.13.0dev.html
/Henrik
On Sun, Mar 6, 2011 at 1:08 PM, Yihui Xie <xie at yihui.name> wrote:
> Hi,
>
> I was suggested that this question should be reported to r-devel.
> Could you please make file.copy() preserve the file mode information?
> I see from the source code that file.copy() is basically
> file.append():
>
> if (any(okay)) {
> okay[okay] <- file.create(to[okay])
> if (any(okay))
> okay[okay] <- file.append(to[okay], from[okay])
> }
>
> Maybe something like this should be added to file.copy():
>
> Sys.chmod(to[okay], file.info(from[okay])$mode)
>
> Thanks!
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
>
> ---------- Forwarded message ----------
> From: Yihui Xie <xie at yihui.name>
> Date: Sat, Mar 5, 2011 at 5:31 PM
> Subject: file mode lost in file.copy()?
> To: R Help <r-help at r-project.org>
>
>
> Hi,
>
> Recently I noticed file.copy() would discard the file mode
> information. Is this the expected behaviour or a bug for file.copy()?
>
>> file.create('testfile')
> [1] TRUE
>
>> file.info('testfile')
> size isdir mode mtime ctime
> testfile 0 FALSE 644 2011-03-05 17:06:39 2011-03-05 17:06:39
> atime uid gid uname grname
> testfile 2011-03-05 17:06:40 1000 1000 yihui yihui
>
>> Sys.chmod('testfile', '0755')
>
>> file.info('testfile')
> size isdir mode mtime ctime
> testfile 0 FALSE 755 2011-03-05 17:06:39 2011-03-05 17:06:59
> atime uid gid uname grname
> testfile 2011-03-05 17:07:00 1000 1000 yihui yihui
>
>> file.copy('testfile', 'testfile2')
> [1] TRUE
>
>> file.info('testfile2')
> size isdir mode mtime ctime
> testfile2 0 FALSE 644 2011-03-05 17:07:20 2011-03-05 17:07:20
> atime uid gid uname grname
> testfile2 2011-03-05 17:07:21 1000 1000 yihui yihui
>
>> sessionInfo()
> R version 2.12.2 (2011-02-25)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
> [3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8
> [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8
> [7] LC_PAPER=en_US.utf8 LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list