replace custom home_dir
This commit is contained in:
parent
172006627f
commit
c526f09c0c
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1365,6 +1365,7 @@ dependencies = [
|
||||
"derive_more",
|
||||
"ffprobe",
|
||||
"file-rotate",
|
||||
"home",
|
||||
"lazy_static",
|
||||
"lettre",
|
||||
"lexical-sort",
|
||||
|
@ -112,7 +112,7 @@ pub fn norm_abs_path(
|
||||
let path = &root_path.join(&source_relative);
|
||||
|
||||
if !FOLDER_WHITELIST.iter().any(|f| path.starts_with(f))
|
||||
&& !path.starts_with(&HOME_DIR.to_string())
|
||||
&& !path.starts_with(HOME_DIR.to_string())
|
||||
{
|
||||
return Err(ServiceError::Forbidden(
|
||||
"Access forbidden: Folder cannot be opened.".to_string(),
|
||||
|
@ -14,6 +14,7 @@ crossbeam-channel = "0.5"
|
||||
derive_more = "0.99"
|
||||
ffprobe = "0.4"
|
||||
file-rotate = "0.7"
|
||||
home = "0.5"
|
||||
lazy_static = "1.4"
|
||||
lettre = { version = "0.11", features = ["builder", "rustls-tls", "smtp-transport"], default-features = false }
|
||||
lexical-sort = "0.3"
|
||||
|
@ -15,7 +15,7 @@ use shlex::split;
|
||||
use crate::AdvancedConfig;
|
||||
|
||||
use super::vec_strings;
|
||||
use crate::utils::{free_tcp_socket, home_dir, time_to_sec, OutputMode::*};
|
||||
use crate::utils::{free_tcp_socket, time_to_sec, OutputMode::*};
|
||||
|
||||
pub const DUMMY_LEN: f64 = 60.0;
|
||||
pub const IMAGE_FORMAT: [&str; 21] = [
|
||||
@ -406,7 +406,7 @@ impl PlayoutConfig {
|
||||
|
||||
config.general.config_path = config_path.to_string_lossy().to_string();
|
||||
|
||||
config.general.stat_file = home_dir()
|
||||
config.general.stat_file = home::home_dir()
|
||||
.unwrap_or_else(env::temp_dir)
|
||||
.join(if config.general.stat_file.is_empty() {
|
||||
".ffp_status"
|
||||
|
@ -10,9 +10,6 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
use std::env;
|
||||
|
||||
use chrono::{prelude::*, TimeDelta};
|
||||
use ffprobe::{ffprobe, Stream as FFStream};
|
||||
use rand::prelude::*;
|
||||
@ -33,9 +30,6 @@ pub mod json_serializer;
|
||||
mod json_validate;
|
||||
mod logging;
|
||||
|
||||
#[cfg(windows)]
|
||||
mod windows;
|
||||
|
||||
pub use config::{
|
||||
self as playout_config,
|
||||
OutputMode::{self, *},
|
||||
@ -988,19 +982,6 @@ pub fn custom_format<T: fmt::Display>(template: &str, args: &[T]) -> String {
|
||||
filled_template
|
||||
}
|
||||
|
||||
pub fn home_dir() -> Option<PathBuf> {
|
||||
home_dir_inner()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
use windows::home_dir_inner;
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
fn home_dir_inner() -> Option<PathBuf> {
|
||||
#[allow(deprecated)]
|
||||
env::home_dir()
|
||||
}
|
||||
|
||||
/// Get system time, in non test/debug case.
|
||||
#[cfg(not(any(test, debug_assertions)))]
|
||||
pub fn time_now() -> DateTime<Local> {
|
||||
|
@ -1,43 +0,0 @@
|
||||
use std::{env, ffi::OsString, os::windows::ffi::OsStringExt, path::PathBuf, ptr};
|
||||
|
||||
use winapi::shared::minwindef::MAX_PATH;
|
||||
use winapi::shared::winerror::S_OK;
|
||||
use winapi::um::shlobj::{SHGetFolderPathW, CSIDL_PROFILE};
|
||||
|
||||
pub fn home_dir_inner() -> Option<PathBuf> {
|
||||
env::var_os("USERPROFILE")
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(PathBuf::from)
|
||||
.or_else(home_dir_crt)
|
||||
}
|
||||
|
||||
#[cfg(not(target_vendor = "uwp"))]
|
||||
fn home_dir_crt() -> Option<PathBuf> {
|
||||
unsafe {
|
||||
let mut path: Vec<u16> = Vec::with_capacity(MAX_PATH);
|
||||
match SHGetFolderPathW(
|
||||
ptr::null_mut(),
|
||||
CSIDL_PROFILE,
|
||||
ptr::null_mut(),
|
||||
0,
|
||||
path.as_mut_ptr(),
|
||||
) {
|
||||
S_OK => {
|
||||
let len = wcslen(path.as_ptr());
|
||||
path.set_len(len);
|
||||
let s = OsString::from_wide(&path);
|
||||
Some(PathBuf::from(s))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_vendor = "uwp")]
|
||||
fn home_dir_crt() -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn wcslen(buf: *const u16) -> usize;
|
||||
}
|
Loading…
Reference in New Issue
Block a user