DirList(string[, string])

grandMA3 ユーザマニュアル » プラグイン » Lua 関数 - Object-Free API » DirList(string[, string]) Version 2.2

説明

DirList 関数は、指定パスにあるファイルのテーブルを返します。返されたリストは、オプションのフィルタ引数を用いて処理できます。

引数

  • string:
    文字列形式による目的のパス。
  • string (オプション):
    フィルタ文字列。ワイルドカードとして * を使用できます(後述の例を参照)。

戻り値

  • table:
    返されるテーブルには他のテーブル要素が含まれます。各テーブル要素には以下のキーがあります。
    • name: ファイル名が文字列として返されます。
    • size: ファイルサイズがバイト単位の値として返されます。
    • time: ファイルのタイムスタンプが数値として返されます。

showfile ディレクトリ内のショーファイルを、GetPath() 関数を用いて出力します。

Lua
return function ()
-- Get the path to the show files.
local path = GetPath(Enums.PathType.Showfiles)
-- Make a filter to only list .show files.
local filter = "*show"
-- Use the DirList function to get a table of the files.
local returnTable = DirList(path, filter)

-- Print the information of the files in the returned table.
for _, value in pairs(returnTable) do
Printf(value['name'] .. " - Size: " .. value['size'] .. " bytes - Time: " .. os.date("%c", value['time']))
end
end