mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
vfmt: keep file permissions with -w on !windows (#13334)
This commit is contained in:
parent
7c1b249da0
commit
51513ae19a
3 changed files with 43 additions and 0 deletions
|
@ -259,7 +259,15 @@ fn (foptions &FormatOptions) post_process_file(file string, formatted_file_path
|
|||
file_bak := '${file}.bak'
|
||||
os.cp(file, file_bak) or {}
|
||||
}
|
||||
mut perms_to_restore := u32(0)
|
||||
$if !windows {
|
||||
fm := os.inode(file)
|
||||
perms_to_restore = fm.bitmask()
|
||||
}
|
||||
os.mv_by_cp(formatted_file_path, file) or { panic(err) }
|
||||
$if !windows {
|
||||
os.chmod(file, int(perms_to_restore)) or { panic(err) }
|
||||
}
|
||||
eprintln('Reformatted file: $file')
|
||||
} else {
|
||||
eprintln('Already formatted file: $file')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue