refactor(structure): Change structure of /tmp directory (#62)

Co-authored-by: Aram Drevekenin <aram@poor.dev>
This commit is contained in:
Henil 2020-11-21 22:02:46 +05:30 committed by GitHub
parent 11e72b3d6b
commit 6a9ecc42a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View file

@ -95,7 +95,7 @@ impl InputHandler {
self.stdin self.stdin
.read(&mut self.buffer) .read(&mut self.buffer)
.expect("failed to read stdin"); .expect("failed to read stdin");
// uncomment this to print the entered character to a log file (/tmp/mosaic-log.txt) for debugging // uncomment this to print the entered character to a log file (/tmp/mosaic/mosaic-log.txt) for debugging
// debug_log_to_file(format!("buffer {:?}", self.buffer)); // debug_log_to_file(format!("buffer {:?}", self.buffer));
match self.buffer { match self.buffer {
[7, 0, 0, 0, 0, 0, 0, 0, 0, 0] => { [7, 0, 0, 0, 0, 0, 0, 0, 0, 0] => {

View file

@ -27,7 +27,7 @@ use crate::layout::Layout;
use crate::os_input_output::{get_os_input, OsApi}; use crate::os_input_output::{get_os_input, OsApi};
use crate::pty_bus::{PtyBus, PtyInstruction, VteEvent}; use crate::pty_bus::{PtyBus, PtyInstruction, VteEvent};
use crate::screen::{Screen, ScreenInstruction}; use crate::screen::{Screen, ScreenInstruction};
use crate::utils::{consts::MOSAIC_TMP_FOLDER, logging::*}; use crate::utils::{consts::MOSAIC_IPC_PIPE, logging::*};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
enum ApiCommand { enum ApiCommand {
@ -64,23 +64,23 @@ pub fn main() {
if opts.split.is_some() { if opts.split.is_some() {
match opts.split { match opts.split {
Some('h') => { Some('h') => {
let mut stream = UnixStream::connect(MOSAIC_TMP_FOLDER).unwrap(); let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
let api_command = bincode::serialize(&ApiCommand::SplitHorizontally).unwrap(); let api_command = bincode::serialize(&ApiCommand::SplitHorizontally).unwrap();
stream.write_all(&api_command).unwrap(); stream.write_all(&api_command).unwrap();
} }
Some('v') => { Some('v') => {
let mut stream = UnixStream::connect(MOSAIC_TMP_FOLDER).unwrap(); let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
let api_command = bincode::serialize(&ApiCommand::SplitVertically).unwrap(); let api_command = bincode::serialize(&ApiCommand::SplitVertically).unwrap();
stream.write_all(&api_command).unwrap(); stream.write_all(&api_command).unwrap();
} }
_ => {} _ => {}
}; };
} else if opts.move_focus { } else if opts.move_focus {
let mut stream = UnixStream::connect(MOSAIC_TMP_FOLDER).unwrap(); let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
let api_command = bincode::serialize(&ApiCommand::MoveFocus).unwrap(); let api_command = bincode::serialize(&ApiCommand::MoveFocus).unwrap();
stream.write_all(&api_command).unwrap(); stream.write_all(&api_command).unwrap();
} else if opts.open_file.is_some() { } else if opts.open_file.is_some() {
let mut stream = UnixStream::connect(MOSAIC_TMP_FOLDER).unwrap(); let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
let file_to_open = opts.open_file.unwrap(); let file_to_open = opts.open_file.unwrap();
let api_command = bincode::serialize(&ApiCommand::OpenFile(file_to_open)).unwrap(); let api_command = bincode::serialize(&ApiCommand::OpenFile(file_to_open)).unwrap();
stream.write_all(&api_command).unwrap(); stream.write_all(&api_command).unwrap();
@ -273,8 +273,8 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: Opt) {
let send_pty_instructions = send_pty_instructions.clone(); let send_pty_instructions = send_pty_instructions.clone();
let send_screen_instructions = send_screen_instructions.clone(); let send_screen_instructions = send_screen_instructions.clone();
move || { move || {
::std::fs::remove_file("/tmp/mosaic").ok(); std::fs::remove_file(MOSAIC_IPC_PIPE).ok();
let listener = ::std::os::unix::net::UnixListener::bind("/tmp/mosaic") let listener = std::os::unix::net::UnixListener::bind(MOSAIC_IPC_PIPE)
.expect("could not listen on ipc socket"); .expect("could not listen on ipc socket");
for stream in listener.incoming() { for stream in listener.incoming() {

View file

@ -1,3 +1,3 @@
pub const MOSAIC_TMP_LOG_FILE: &str = "/tmp/mosaic-log.txt"; pub const MOSAIC_TMP_LOG_FILE: &str = "/tmp/mosaic/mosaic-log/log.txt";
pub const MOSAIC_TMP_LOG_DIR: &str = "/tmp/mosaic-log"; pub const MOSAIC_TMP_LOG_DIR: &str = "/tmp/mosaic/mosaic-log";
pub const MOSAIC_TMP_FOLDER: &str = "/tmp/mosaic"; pub const MOSAIC_IPC_PIPE: &str = "/tmp/mosaic/ipc";