Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/paths.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua.in')
-rw-r--r--init.lua.in23
1 files changed, 14 insertions, 9 deletions
diff --git a/init.lua.in b/init.lua.in
index 197ca42..d72a482 100644
--- a/init.lua.in
+++ b/init.lua.in
@@ -120,18 +120,23 @@ end
function findprogram(exe)
if is_win() then
- local k = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\' .. exe;
- local x = getregistryvalue('HKEY_LOCAL_MACHINE', k, '')
- if type(x) == 'string' then return x end
- x = getregistryvalue('HKEY_LOCAL_MACHINE', k .. '.exe', '')
- if type(x) == 'string' then return x end
- local path = os.getenv("PATH") or "."
+ if not exe:match('[.]exe$') then
+ exe = exe .. '.exe'
+ end
+ local path, k, x = os.getenv("PATH") or "."
for dir in path:gmatch('[^;]+') do
x = concat(dir, exe)
if filep(x) then return x end
- x = x .. '.exe'
- if filep(x) then return x end
end
+ k = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\' .. exe
+ x = getregistryvalue('HKEY_CURRENT_USER', k, '')
+ if type(x) == 'string' then return x end
+ x = getregistryvalue('HKEY_LOCAL_MACHINE', k, '')
+ if type(x) == 'string' then return x end
+ k = 'Applications\\' .. exe .. '\\shell\\open\\command'
+ x = getregistryvalue('HKEY_CLASSES_ROOT', k, '')
+ if type(x) == 'string' and x:match('"') then x = x:match('"[^"]+"') end
+ if type(x) == 'string' then return x end
else
local path = os.getenv("PATH") or "."
for dir in path:gmatch('[^:]+') do
@@ -140,4 +145,4 @@ function findprogram(exe)
end
end
return nil
-end \ No newline at end of file
+end