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


Get file length

Copy codeThe code is as follows:

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

Determine whether the file exists

Copy codeThe code is as follows:

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

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 = […]