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 = {}
for f in list do
if f:sub(-1) == "/" then
if options.p then
table.insert(lsd, f)
else
table.insert(lsd, f:sub(1, -2))
end
else
table.insert(lsf, f)
end
@ -65,9 +69,9 @@ for i = 1, #dirs do
end
end
setColor(0xFFFFFF)
if options.c then
io.write("\nDirectories: "..tostring(#lsd))
io.write("\nFiles: "..tostring(#lsf))
if options.M then
io.write("\n" .. tostring(#lsf) .. " File(s)")
io.write("\n" .. tostring(#lsd) .. " Dir(s)")
end
if not options.l then
io.write("\n")
@ -75,3 +79,4 @@ for i = 1, #dirs do
end
end
io.output():setvbuf("no")
io.output():flush()

View File

@ -12,6 +12,10 @@ OPTIONS
do not ignore entries starting with .
-l
use a long listing format
-p
append / indicator to directories
-M
display Microsoft-style file and directory count after listing
EXAMPLES
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
// not disable use of the natives.
if (file.exists()) {
var matching = true
try {
val inCurrent = libraryUrl.openStream()
val inExisting = new FileInputStream(file)
var matching = true
var inCurrentByte = 0
var inExistingByte = 0
do {