Commencé à calculer le hash d'un fichier dans la fonction dir(), ne fonctionne pas encore :-(

This commit is contained in:
Christian Zufferey
2019-11-09 18:22:32 +01:00
parent 6b9078063e
commit a8f2632eea
2 changed files with 17 additions and 3 deletions

View File

@@ -134,6 +134,7 @@ telnet -rN $zIP $zport
=node.heap()
status, err = pcall(function () fonction_a_tester() end) if status==false then print("Error: ",err) end
status, err = pcall(function () toto() end) if status==false then print("Error: ",err) end
.

View File

@@ -1,15 +1,28 @@
-- fonction dir() pour afficher les fichiers dans la flash
print("\n dir.lua zf180826.1019 \n")
print("\n dir.lua zf191109.1719 \n")
hash=nil
function zhash(zstring)
local zhash_v = 0
for i = 1, string.len(zstring) do
zhash_v = zhash_v + string.byte(zstring, i) * i
end
return zhash_v
end
status, err = pcall(function () print(zhash("il était une fois trois petits cochons roses...")) end) if status==false then print("Error: ",err) end
function dir()
print("\n-------------------------------")
l=file.list() i=0
for k,v in pairs(l) do
i=i+v
print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes")
print(k..string.rep(" ",24-string.len(k)).." : "..v.." bytes")
end
print("-------------------------------")
print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n')
end
status, err = pcall(function () dir() end) if status==false then print("Error: ",err) end
dir()