aboutsummaryrefslogtreecommitdiff
path: root/core/ext/pm/modules_browser.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-09-21 19:57:05 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2008-09-21 19:57:05 -0400
commita0799c95fa737a76a9e03156b42a4871ec4dd2dc (patch)
treef44f9e3be0afba9fbb21eed2ac42ecdb62b3dd25 /core/ext/pm/modules_browser.lua
parente05c5b2a88f84bc7eca915806e59cbdbd689af9c (diff)
downloadtextadept-a0799c95fa737a76a9e03156b42a4871ec4dd2dc.tar.gz
textadept-a0799c95fa737a76a9e03156b42a4871ec4dd2dc.zip
Modified some of the pm browsers to play nice with Windows.
Diffstat (limited to 'core/ext/pm/modules_browser.lua')
-rw-r--r--core/ext/pm/modules_browser.lua45
1 files changed, 34 insertions, 11 deletions
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