Skip to content

Commit

Permalink
resolve symlink path
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-zam committed Jan 31, 2019
1 parent a2ee32f commit 961e935
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use actix_web::{server as actix_server, App};
use rlua::prelude::*;
use std::{
path::{Path, PathBuf},
result
result,
fs
};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use serde_json::Value;
Expand Down Expand Up @@ -85,7 +86,13 @@ impl AppState {
}

// Lua arg
lua.globals().set("arg", lua.create_sequence_from(self.init_args.clone())?)?;
let mut cmd_args = self.init_args.clone();
// if file path is symlink, then resolve
match fs::read_link(&cmd_args[0]) {
Ok(p) => cmd_args[0] = String::from(p.to_str().unwrap_or("")),
Err(_) => (),
};
lua.globals().set("arg", lua.create_sequence_from(cmd_args)?)?;

// Lua Bridge
lua.exec::<_, ()>(include_str!("handlers/bridge.lua"), None)?;
Expand Down

0 comments on commit 961e935

Please sign in to comment.