1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

truncate: remove read permissions from OpenOptions

Remove "read" permissions from the `OpenOptions` when opening a new file
just to truncate it. We will never read from the file, only write to
it. (Specifically, we will only call `File::set_len()`.)
This commit is contained in:
Jeffrey Finkelstein 2021-05-21 18:23:50 -04:00 committed by Jan Scheer
parent 4e73b919e9
commit b898e54d7a

View file

@ -189,12 +189,7 @@ fn truncate(
}; };
for filename in &filenames { for filename in &filenames {
let path = Path::new(filename); let path = Path::new(filename);
match OpenOptions::new() match OpenOptions::new().write(true).create(!no_create).open(path) {
.read(true)
.write(true)
.create(!no_create)
.open(path)
{
Ok(file) => { Ok(file) => {
let fsize = match reference { let fsize = match reference {
Some(_) => refsize, Some(_) => refsize,