1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: fix permission problems after sudo v symlink

This commit is contained in:
Delyan Angelov 2021-02-18 18:11:09 +02:00
parent 0dbc9417e7
commit 252074836b
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -1,23 +1,29 @@
import os import os
import v.pref import v.pref
import v.util
$if windows { $if windows {
$if tinyc { $if tinyc {
#flag -lAdvapi32 #flag -lAdvapi32
#flag -lUser32 #flag -lUser32
} }
} }
fn main() { fn main() {
C.atexit(cleanup_vtmp_folder)
vexe := os.real_path(pref.vexe_path()) vexe := os.real_path(pref.vexe_path())
$if windows { $if windows {
setup_symlink_windows(vexe) setup_symlink_windows(vexe)
} $else { } $else {
setup_symlink(vexe) setup_symlink_unix(vexe)
} }
} }
fn setup_symlink(vexe string) { fn cleanup_vtmp_folder() {
os.rmdir_all(util.get_vtmp_folder()) or { }
}
fn setup_symlink_unix(vexe string) {
link_dir := '/usr/local/bin' link_dir := '/usr/local/bin'
if !os.exists(link_dir) { if !os.exists(link_dir) {
os.mkdir_all(link_dir) or { panic(err) } os.mkdir_all(link_dir) or { panic(err) }
@ -166,7 +172,8 @@ fn set_reg_value(reg_key voidptr, key string, value string) ?bool {
// letting them know that the system environment has changed and should be reloaded // letting them know that the system environment has changed and should be reloaded
fn send_setting_change_msg(message_data string) ?bool { fn send_setting_change_msg(message_data string) ?bool {
$if windows { $if windows {
if C.SendMessageTimeout(os.hwnd_broadcast, os.wm_settingchange, 0, message_data.to_wide(), os.smto_abortifhung, 5000, 0) == 0 { if C.SendMessageTimeout(os.hwnd_broadcast, os.wm_settingchange, 0, message_data.to_wide(),
os.smto_abortifhung, 5000, 0) == 0 {
return error('Could not broadcast WM_SETTINGCHANGE') return error('Could not broadcast WM_SETTINGCHANGE')
} }
return true return true