From 65d94240780e058cbbfdad1fccbc5f9cdd73baaa Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 30 Jun 2016 17:11:52 +0300 Subject: [PATCH] Fix. `event_socket_mkdir` for Windows system. (#1724) --- resources/functions.php | 25 +++++++++++-------------- resources/install/scripts/mkdir.lua | 7 +++++++ 2 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 resources/install/scripts/mkdir.lua diff --git a/resources/functions.php b/resources/functions.php index 060a59243c..67f5477e3a 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1957,27 +1957,24 @@ function number_pad($number,$n) { } function event_socket_mkdir($dir) { - //if the handle does not exist create it + //connect to fs $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if (!$fp) { return false; } //send the mkdir command to freeswitch if ($fp) { - //send the api command to check if the module exists - $switch_cmd = "system mkdir -p '$dir'"; - $switch_result = event_socket_request($fp, 'api '.$switch_cmd); - unset($switch_cmd); - if (trim($switch_result) == "-ERR no reply") { - return true; - } - else { - return false; - } - } - else { - return false; + //build and send the mkdir command to freeswitch + $switch_cmd = "lua mkdir.lua '$dir'"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + fclose($fp); + //check result + if (trim($switch_result) == "-ERR no reply") { + return true; + } } + //can not create directory + return false; } ?> \ No newline at end of file diff --git a/resources/install/scripts/mkdir.lua b/resources/install/scripts/mkdir.lua new file mode 100644 index 0000000000..9d49df84ef --- /dev/null +++ b/resources/install/scripts/mkdir.lua @@ -0,0 +1,7 @@ +require "resources.functions.mkdir" + +local path = argv[1] + +if path and #path > 0 then + mkdir(path) +end