Skip to content

Commit 62efeaf

Browse files
Merge pull request #1 from ADawesomeguy/file-separators
Use path.join instead of specified backslash for file separators
2 parents e5ea0c7 + 90756fe commit 62efeaf

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/core/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ pub const TYPE_STRING_UTF8: [u8; 2] = [0xAC, 0x08];
3838
pub const TYPE_STRING_UTF16: [u8; 2] = [0x9C, 0x16];
3939

4040

41-
pub const SCRIPTSLOG_PATH_IN_DOCS: &str = "The Witcher 3\\scriptslog.txt";
41+
pub const SCRIPTSLOG_FILE_NAME: &str = "scriptslog.txt";

src/core/scriptslog.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fs::{File, OpenOptions}, sync::mpsc::{Receiver, TryRecvError}, io::{BufReader, Seek, SeekFrom, Read}, time::Duration};
1+
use std::{fs::{File, OpenOptions}, sync::mpsc::{Receiver, TryRecvError}, io::{BufReader, Seek, SeekFrom, Read}, time::Duration, path::Path};
22
use directories::UserDirs;
33

44
use crate::constants;
@@ -60,18 +60,18 @@ fn scriptslog_file() -> Result<File, String> {
6060
let mut docs = None;
6161
if let Some(ud) = UserDirs::new() {
6262
if let Some(path) = ud.document_dir() {
63-
if let Some(s) = path.to_str() {
64-
docs = Some(s.to_owned());
65-
}
63+
docs = Some(path.to_owned());
6664
}
6765
}
6866

6967
if let Some(docs) = docs {
68+
let scriptslog_path = docs.join(Path::new("The Witcher 3").join(constants::SCRIPTSLOG_FILE_NAME));
69+
7070
let file = OpenOptions::new()
7171
.read(true)
7272
.write(true) // so that it can be created if doesn't exist
7373
.create(true)
74-
.open( docs + "\\" + constants::SCRIPTSLOG_PATH_IN_DOCS );
74+
.open( scriptslog_path );
7575

7676
if let Err(e) = file {
7777
println!("{:?}", e.kind());

0 commit comments

Comments
 (0)