Lua gets the file length and judges whether the file has function sharing

Time:2022-5-7

Get file length

Copy codeThe code is as follows:

 function length_of_file(filename)
  local fh = assert(io.open(filename, “rb”))
  local len = assert(fh:seek(“end”))
  fh:close()
  return len
end


Determine whether the file exists

Copy codeThe code is as follows:

function file_exists(path)
  local file = io.open(path, “rb”)
  if file then file:close() end
  return file ~= nil
end

Recommended Today

Vbstree vbs script simulates the tree command

Copy codeThe code is as follows: ‘————-vbsTree.vbs————————‘description: output the directory structure of a folder with VBS. ‘————————————————Const unit4size = “kbmbgb bytes” Const OutFile = “OutTree.txt” Dim theApp,SelPath,TreePath,TreeStr Set theApp = CreateObject(“Shell.Application”)Set SelPath = theApp. Browseforfolder (0, “please select the path where you want to list subprojects”, 0) If SelPath Is Nothing Then WScript.Quit TreePath = […]