From a0799c95fa737a76a9e03156b42a4871ec4dd2dc Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 21 Sep 2008 19:57:05 -0400 Subject: Modified some of the pm browsers to play nice with Windows. --- core/ext/pm/modules_browser.lua | 45 +++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'core/ext/pm/modules_browser.lua') diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua index 28800fc3..9c0c8992 100644 --- a/core/ext/pm/modules_browser.lua +++ b/core/ext/pm/modules_browser.lua @@ -18,23 +18,46 @@ end function get_contents_for(full_path) full_path = modify_path(full_path) local dirpath = table.concat(full_path, '/') - local p = io.popen('ls -1p "'..dirpath..'"') - local out = p:read('*all') - p:close() - if #out == 0 then - error('No such directory: '..dirpath) - return {} - end local dir = {} - for entry in out:gmatch('[^\n]+') do - if entry:sub(-1, -1) == '/' then - local name = entry:sub(1, -2) + if not WIN32 then + local p = io.popen('ls -1p "'..dirpath..'"') + local out = p:read('*all') + p:close() + if #out == 0 then + error('No such directory: '..dirpath) + return dir + end + for entry in out:gmatch('[^\n]+') do + if entry:sub(-1, -1) == '/' then + local name = entry:sub(1, -2) + dir[name] = { + parent = true, + display_text = name, + pixbuf = 'gtk-directory' + } + else + dir[entry] = { display_text = entry } + end + end + else + local p = io.popen('dir /A:D /B "'..dirpath..'"') + local out = p:read('*all') + p:close() + if out:match('^File Not Found') then + error('No such directory: '..dirpath) + return dir + end + for name in out:gmatch('[^\n]+') do dir[name] = { parent = true, display_text = name, pixbuf = 'gtk-directory' } - else + end + p = io.popen('dir /A:-D /B "'..dirpath..'"') + out = p:read('*all') + p:close() + for entry in out:gmatch('[^\n]+') do dir[entry] = { display_text = entry } end end -- cgit v1.2.3