跳至主要內容

取得路徑大小 (LCC.web_file.size)

聲明​

size, err = LCC.web_file.size(path, timeout?)

參數​

  • path
    字串型,待查詢的檔案路徑
  • timeout
    數值型,可選;請求逾時時間(秒),預設 60

回傳值​

  • size
    數值型,目標存在時傳回大小;否則為 nil
  • err
    字串型或 nil,無法取得大小時固定為 'not found'

說明​

透過檢查路徑是否存在來取得大小。
普通檔案傳回位元組數;目錄目前傳回 0。
無法取得大小時,一律傳回 nil, 'not found'。

範例​

local size, err = LCC.web_file.size("/報告/log.txt")
if size then
print("日誌大小: " .. size .. " bytes")
end