mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix default video save directory
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -4,6 +4,7 @@ use hbb_common::{allow_err, bail, log};
|
||||
use libc::{c_char, c_int, c_void};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
path::PathBuf,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
@@ -516,6 +517,17 @@ pub fn get_active_username() -> String {
|
||||
get_value_of_seat0(2)
|
||||
}
|
||||
|
||||
pub fn get_active_user_home() -> Option<PathBuf> {
|
||||
let username = get_active_username();
|
||||
if !username.is_empty() {
|
||||
let home = PathBuf::from(format!("/home/{}", username));
|
||||
if home.exists() {
|
||||
return Some(home);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_prelogin() -> bool {
|
||||
let n = get_active_userid().len();
|
||||
n < 4 && n > 1
|
||||
|
||||
@@ -20,6 +20,7 @@ use hbb_common::{bail, log};
|
||||
use include_dir::{include_dir, Dir};
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
use scrap::{libc::c_void, quartz::ffi::*};
|
||||
use std::path::PathBuf;
|
||||
|
||||
static PRIVILEGES_SCRIPTS_DIR: Dir =
|
||||
include_dir!("$CARGO_MANIFEST_DIR/src/platform/privileges_scripts");
|
||||
@@ -374,6 +375,17 @@ pub fn get_active_userid() -> String {
|
||||
get_active_user("-n")
|
||||
}
|
||||
|
||||
pub fn get_active_user_home() -> Option<PathBuf> {
|
||||
let username = get_active_username();
|
||||
if !username.is_empty() {
|
||||
let home = PathBuf::from(format!("/Users/{}", username));
|
||||
if home.exists() {
|
||||
return Some(home);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_prelogin() -> bool {
|
||||
get_active_userid() == "0"
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use std::io::prelude::*;
|
||||
use std::{
|
||||
ffi::{CString, OsString},
|
||||
fs, io, mem,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
@@ -734,6 +735,18 @@ pub fn get_active_username() -> String {
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
pub fn get_active_user_home() -> Option<PathBuf> {
|
||||
let username = get_active_username();
|
||||
if !username.is_empty() {
|
||||
let drive = std::env::var("SystemDrive").unwrap_or("C:".to_owned());
|
||||
let home = PathBuf::from(format!("{}\\Users\\{}", drive, username));
|
||||
if home.exists() {
|
||||
return Some(home);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_prelogin() -> bool {
|
||||
let username = get_active_username();
|
||||
username.is_empty() || username == "SYSTEM"
|
||||
|
||||
Reference in New Issue
Block a user