Changeset 45 for trunk/lua/cli.lua


Ignore:
Timestamp:
05/02/2011 03:18:08 AM (2 years ago)
Author:
reyalP
Message:

rework directory listing to return numeric array in all cases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lua/cli.lua

    r31 r45  
    450450                        local list,msg = chdku.listdir(path,listopts) 
    451451                        if type(list) == 'table' then 
    452                                 local r = ''; 
     452                                local r = '' 
    453453                                if opts.l then 
    454                                         local names={} 
    455                                         local i=1 
    456                                         for k,v in pairs(list) do 
    457                                                 names[i]=k 
    458                                                 i=i+1 
    459                                         end 
    460454                                        -- alphabetic sort TODO sorting/grouping options 
    461                                         table.sort(names) 
    462                                         for i,name in ipairs(names) do 
    463                                                 local st=list[name] 
     455                                        chdku.sortdir_stat(list) 
     456                                        for i,st in ipairs(list) do 
    464457                                                if st.is_dir then 
    465                                                         r = r .. string.format("%s/\n",name) 
     458                                                        r = r .. string.format("%s/\n",st.name) 
    466459                                                else 
    467                                                         r = r .. string.format("%-13s %10d\n",name,list[name].size) 
     460                                                        r = r .. string.format("%-13s %10d\n",st.name,st.size) 
    468461                                                end 
    469462                                        end 
Note: See TracChangeset for help on using the changeset viewer.