Changed option flag for ls to display file and dir count to an unused one and made it read like dir in Windows (which is what it's meant to mimic, after all).

This commit is contained in:
Florian Nücke 2014-07-02 20:11:09 +02:00
parent e7c863a00d
commit a19c05442d
3 changed files with 15 additions and 6 deletions

View File

@ -30,7 +30,11 @@ for i = 1, #dirs do
local lsf = {} local lsf = {}
for f in list do for f in list do
if f:sub(-1) == "/" then if f:sub(-1) == "/" then
table.insert(lsd, f) if options.p then
table.insert(lsd, f)
else
table.insert(lsd, f:sub(1, -2))
end
else else
table.insert(lsf, f) table.insert(lsf, f)
end end
@ -65,13 +69,14 @@ for i = 1, #dirs do
end end
end end
setColor(0xFFFFFF) setColor(0xFFFFFF)
if options.c then if options.M then
io.write("\nDirectories: "..tostring(#lsd)) io.write("\n" .. tostring(#lsf) .. " File(s)")
io.write("\nFiles: "..tostring(#lsf)) io.write("\n" .. tostring(#lsd) .. " Dir(s)")
end end
if not options.l then if not options.l then
io.write("\n") io.write("\n")
end end
end end
end end
io.output():setvbuf("no") io.output():setvbuf("no")
io.output():flush()

View File

@ -12,6 +12,10 @@ OPTIONS
do not ignore entries starting with . do not ignore entries starting with .
-l -l
use a long listing format use a long listing format
-p
append / indicator to directories
-M
display Microsoft-style file and directory count after listing
EXAMPLES EXAMPLES
ls ls

View File

@ -103,10 +103,10 @@ object LuaStateFactory {
// If the file, already exists, make sure it's the same we need, if it's // If the file, already exists, make sure it's the same we need, if it's
// not disable use of the natives. // not disable use of the natives.
if (file.exists()) { if (file.exists()) {
var matching = true
try { try {
val inCurrent = libraryUrl.openStream() val inCurrent = libraryUrl.openStream()
val inExisting = new FileInputStream(file) val inExisting = new FileInputStream(file)
var matching = true
var inCurrentByte = 0 var inCurrentByte = 0
var inExistingByte = 0 var inExistingByte = 0
do { do {