函数:io.type 判断句柄

函数名称:判断句柄

函数功能:判断是否为有效句柄

函数方法

bool = io.type(file)

参数 类型 必填 说明
file userdata 需要判断的文件句柄
返回值 类型 说明
bool string “file“ - 一个打开的文件句柄,"closed file“ - 为一个已关闭的文件句柄,nil - 不是文件句柄

函数用例

file,msg = io.open("/mnt/sdcard/kazhu.txt")
bool = io.type(file)
if bool == "file" then
    dialog("是文件句柄",5)
elseif bool == "closed file" then
    dialog("句柄已关闭",5)
elseif bool == nil then
    dialog("不是文件句柄",5)
end
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""