-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
169 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::fs; | ||
|
||
pub struct FileHandler { | ||
pub lines: Vec<String>, | ||
} | ||
|
||
impl FileHandler { | ||
pub fn new() -> Self { | ||
Self { | ||
lines: Vec::new(), | ||
} | ||
} | ||
|
||
pub fn add_line(&mut self, line: String) { | ||
self.lines.push(line); | ||
} | ||
|
||
pub fn submit(&self) { | ||
if cfg!(target_os = "windows") { | ||
self.submit_windows(); | ||
} else { | ||
self.submit_unix(); | ||
} | ||
} | ||
|
||
fn submit_windows(&self) { | ||
let path = "C:\\Temp\\ReportBook.txt"; | ||
fs::write(path, self.lines.join("\n").as_bytes()).expect("Failed to create tempfile"); | ||
|
||
open::that(path).expect("Failed to open file"); | ||
} | ||
|
||
fn submit_unix(&self) { | ||
let path = "/tmp/ReportBook.txt"; | ||
fs::write(path, self.lines.join("\n").as_bytes()).expect("Failed to create tempfile"); | ||
|
||
open::that(path).expect("Failed to open file"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.