使用Sys.chmod在R中切换世界可读性

使用Sys.chmod在R中切换世界可读性,r,posix,chmod,cran,R,Posix,Chmod,Cran,如何使用R中的Sys.chmod函数通过“其他”切换可读性,即等效于: chmod o+r myfile chmod o-r myfile 我特别想让模式的其他部分单独使用。chmod o+r: mod <- file.info('tmp.txt')$mode Sys.chmod('tmp.txt', mod|4) modchmod o+r: mod <- file.info('tmp.txt')$mode Sys.chmod('tmp.txt', mod|4) mod

如何使用R中的
Sys.chmod
函数通过“其他”切换可读性,即等效于:

chmod o+r myfile
chmod o-r myfile
我特别想让模式的其他部分单独使用。

chmod o+r:

mod <- file.info('tmp.txt')$mode
Sys.chmod('tmp.txt', mod|4)
modchmod o+r:

mod <- file.info('tmp.txt')$mode
Sys.chmod('tmp.txt', mod|4)
mod