aboutsummaryrefslogtreecommitdiff
path: root/core/ext/pm/file_browser.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-12-21 12:49:51 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2008-12-21 12:49:51 -0500
commitaf1cf8a2b1a63dc2d87eb311fafac44de2ee03a1 (patch)
tree7d09151e1cebd741dbb11b61f126362255a3933e /core/ext/pm/file_browser.lua
parent0a1b12c2adda657076129bba70a31dfd08bce140 (diff)
downloadtextadept-af1cf8a2b1a63dc2d87eb311fafac44de2ee03a1.tar.gz
textadept-af1cf8a2b1a63dc2d87eb311fafac44de2ee03a1.zip
Updated core/ext/pm/file_browser.lua to use the LuaFileSystem library.
Diffstat (limited to 'core/ext/pm/file_browser.lua')
-rw-r--r--core/ext/pm/file_browser.lua86
1 files changed, 31 insertions, 55 deletions
diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua
index caae33f6..d2dec609 100644
--- a/core/ext/pm/file_browser.lua
+++ b/core/ext/pm/file_browser.lua
@@ -6,6 +6,9 @@
-- manager entry field.
module('textadept.pm.browsers.file', package.seeall)
+local lfs = require 'lfs'
+local os = require 'os'
+
function matches(entry_text)
if not WIN32 then
return entry_text:sub(1, 1) == '/'
@@ -15,49 +18,16 @@ function matches(entry_text)
end
function get_contents_for(full_path)
- local dirpath = table.concat(full_path, '/')
local dir = {}
- 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,
- text = name,
- pixbuf = 'gtk-directory'
- }
- else
- dir[entry] = { text = entry }
+ local dirpath = table.concat(full_path, '/')
+ for name in lfs.dir(dirpath) do
+ if not name:match('^%.') then
+ dir[name] = { text = name }
+ if lfs.attributes(dirpath..'/'..name, 'mode') == 'directory' then
+ dir[name].parent = true
+ dir[name].pixbuf = 'gtk-directory'
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,
- text = name,
- pixbuf = 'gtk-directory'
- }
- end
- p = io.popen('dir /A:-D /B "'..dirpath..'"')
- out = p:read('*all')
- p:close()
- for entry in out:gmatch('[^\n]+') do
- dir[entry] = { text = entry }
- end
end
return dir
end
@@ -78,20 +48,26 @@ function perform_menu_action(menu_item, selected_item)
textadept.pm.entry_text = filepath
textadept.pm.activate()
elseif menu_item == 'File Details' then
- if not WIN32 then
- local p = io.popen('ls -dhl "'..filepath..'"')
- local out = p:read('*all')
- p:close()
- local perms, num_dirs, owner, group, size, mod_date =
- out:match('^(%S+) (%S+) (%S+) (%S+) (%S+) (%S+ %S)')
- out = 'File details for:\n'..filepath..'\n'..
- 'Perms:\t'..perms..'\n'..
- '#Dirs:\t'..num_dirs..'\n'..
- 'Owner:\t'..owner..'\n'..
- 'Group:\t'..group..'\n'..
- 'Size:\t'..size..'\n'..
- 'Date:\t'..mod_date
- text_input(out, nil, false, 250, 250)
- end
+ local date_format = '%D %T'
+ local attr = lfs.attributes(filepath)
+ local out = string.format( [[
+ Mode: %s
+ Size: %s
+ UID: %s
+ GID: %s
+ Device: %s
+ Accessed: %s
+ Modified: %s
+ Changed: %s
+ ]], attr.mode, attr.size, attr.uid, attr.gid, attr.dev,
+ os.date(date_format, attr.access),
+ os.date(date_format, attr.modification),
+ os.date(date_format, attr.change) )
+ cocoa_dialog( 'textbox', {
+ ['informative-text'] = 'File details for '..filepath,
+ text = out,
+ button1 = 'OK',
+ editable = false
+ } )
end
end