From ee07ad6d68ff5c8b86f5f8a8dca63a598ef23644 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Sat, 14 Nov 2020 20:25:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E8=AF=A5=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=BD=9C=E4=B8=BA=E4=BE=9D=E8=B5=96=E6=97=B6=20fileSy?= =?UTF-8?q?nc=E6=96=87=E4=BB=B6=E7=9A=84=E5=90=AF=E5=8A=A8=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sync/esSyncSrv.erl | 6 ++++-- src/sync/esUtils.erl | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/sync/esSyncSrv.erl b/src/sync/esSyncSrv.erl index 6e56b77..da29eb7 100644 --- a/src/sync/esSyncSrv.erl +++ b/src/sync/esSyncSrv.erl @@ -105,9 +105,11 @@ handleAfter(?None, waiting, State) -> spawn(fun() -> case os:type() of {win32, _Osname} -> - os:cmd("start ./priv/fileSync.exe ./ " ++ integer_to_list(ListenPort)); + CmtStr = "start " ++ esUtils:fileSyncPath("fileSync.exe") ++ " ./ " ++ integer_to_list(ListenPort), + os:cmd(CmtStr); _ -> - os:cmd("./priv/fileSync ./ " ++ integer_to_list(ListenPort)) + CmtStr = esUtils:fileSyncPath("fileSync") ++ " ./ " ++ integer_to_list(ListenPort), + os:cmd(CmtStr) end end), {kpS, State#state{sockMod = SockMod}, {sTimeout, 4000, waitConnOver}}; {error, Reason} -> diff --git a/src/sync/esUtils.erl b/src/sync/esUtils.erl index 95f964f..8d6340f 100644 --- a/src/sync/esUtils.erl +++ b/src/sync/esUtils.erl @@ -870,4 +870,17 @@ addNewFile([OneFile | LeftFile], SrcFiles) -> addNewFile(LeftFile, SrcFiles); _ -> addNewFile(LeftFile, SrcFiles#{OneFile => 1}) - end. \ No newline at end of file + end. + +fileSyncPath(ExecName) -> + case code:priv_dir(?MODULE) of + {error, _} -> + case code:which(?MODULE) of + Filename when is_list(Filename) -> + filename:join([filename:dirname(filename:dirname(Filename)), "priv", ExecName]); + _ -> + filename:join("../priv", ExecName) + end; + Dir -> + filename:join(Dir, ExecName) + end.