lua lfs

iter, dir_obj = lfs.dir (path)

Lua iterator over the entries of a given directory. Each time the iterator is called with dir_obj it returns a directory entry‘s name as a string, or nil if there are no more entries. You can also iterate by calling dir_obj:next(), and explicitly close the directory before the iteration finished with dir_obj:close(). Raises an error if path is not a directory.

lfs.attributes(属性) (filepath [, aname])

Returns a table with the file attributes corresponding to filepath (or nil followed by an error message in case of error). If the second optional(可选择的) argument is given, then only the value of the named attribute is returned (this use is equivalent(等价的) to lfs.attributes(filepath).aname, but the table is not created and only one attribute is retrieved(检索)from the O.S.). The attributes are described as follows; attribute mode is a string, all the others are numbers, and the time related attributes use the same time reference(参考) ofos.time:

dev
on Unix systems, this represents the device(装置) that the inode resides(住) on. On Windows systems, represents the drive number of the disk containing the file
ino
on Unix systems, this represents the inode number. On Windows systems this has no meaning
mode
string representing the associated(关联的) protection mode (the values could be filedirectorylinksocketnamed pipechar deviceblock device or other)
nlink
number of hard links to the file
uid
user-id of owner (Unix only, always 0 on Windows)
gid
group-id of owner (Unix only, always 0 on Windows)
rdev
on Unix systems, represents the device(装置) type, for special file inodes. On Windows systems represents the same as dev
access
time of last access
modification
time of last data modification(修改)
change
time of last file status change
size
file size, in bytes
blocks
block allocated(分配) for file; (Unix only)
blksize
optimal(最佳的) file system I/O blocksize; (Unix only)

This function uses stat internally(内部地) thus if the given filepath is a symbolic(象征的) link, it is followed (if it points to another link the chain is followed recursively(递归的)) and the information is about the file it refers to. To obtain information about the link itself, see function lfs.symlinkattributes.

时间: 2024-08-03 20:05:43

lua lfs的相关文章

lua lfs库

 lfs.attributes(filepath [, aname]) 获取路径指定属性    lfs.chdir(path) 改变当前工作目录,成功返回true,失败返回nil加上错误信息    lfs.currentdir 获取当前工作目录,成功返回路径,失败为nil加上错误信息    lfs.dir(path) 返回一个迭代器(function)和一个目录(userdata),每次迭代器都会返回一个路径,直到不是文件目录为止,则迭代器返回nil    lfs.lock(filehandle

lua中清空目录和递归创建目录

lua中的 lfs.mkdir lfs.rmdir只能针对单个目录,且lfs.rmdir不能清空文件夹 于是我想到了使用os.execute 递归创建目录如下os.execute("mkdir ooxx\\ooxx\\ooxx\\ooxx) --windowsos.execute("mkdir -p ooxx/ooxx/ooxx) --unix,linux like 清空目录如下os.execute("del ooxx\) --windowsos.execute("

lua调用dll 编译lfs

From:http://blog.csdn.net/snlscript/article/details/16340653 #include <Windows.h> extern "C"{#include <lua.h>#include <lauxlib.h>#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <lualib.h>

【Lua】Lua + openresty遍历文件目录

OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器,它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项. 今天用OpenResty + lua来遍历指定目录,返回json字符串 我们用Lua来遍历文件目录,并用nginx来访问lua文件,使其返回这个目录的json字符串. Lua代码: 1 local lfs = require("lfs") 2 3 function getType(path) 4 return

Lua 调用 Opencv 的方法

Lua 调用 Opencv 的方法 最近想用 Lua 调用 Opencv 进行相关像素级操作,如:bitwise_and 或者 bitwise_or,从而完成图像 IoU 的计算. 那么,怎么用 Lua 调用 Opencv 呢? 查了 Torch 的官方文档,发现只有这么几个可以调用的包: 链接: https://github.com/torch/torch7/wiki/Cheatsheet 然后,你点击一个进去,发现有这么一个方法,可以安装对应的 Opencv 包:  然后,你就在终端里输入:

LUA实现单词替换功能

背景描述 编程或者文档处理过程, 经常遇到需要将一个单词修改为另外一个单词的情况, 例如 命名为 shall 修改 为 should. 使用工具实现, 则比较方便,不容易出错, 解放双手. 需求规格 对于某个文件夹中的所有文本文件(txt), 将某个单词替换为目标单词. 实现思路 对于替换的单词映射, 在配置文件config.lua进行设置, 存储一个表,表中每一行 对应  src vocanbulary 和 dest vocanbulary 对应工具的主题逻辑代码在 replace.lua中实

【Lua】Lua + LWT + ExtJS构建目录树

Lua处理后台逻辑,Lua lwt搭建后台程序,ExtJS根据后台传来的json数据构建目录树. 前台html和ExtJS代码不用多讲,直接上代码: treePanel.html 1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 5 <title>ExtJS TreePanel</

【Lua】LWT后台用JSON与 ExtJS传递数据

要完成目录树的构建,需要前台ExtJS构筑页面,后台处理逻辑,中间由JSON传递数据. 首先搭建后台环境: 1 require "httpd" 2 require "lfs" 3 4 request, args = ... 5 6 local s = {root = { 7 text = "rootNode", 8 expanded = true, 9 children = { 10 { 11 text = 'book1', 12 leaf =

lua对模块接口扩展的一种方法

module lua中模块的实现,对于使用者来说就是一个库,引用此库后,可以调用库中实现的任意函数. 使用库,可以将一类功能相关的接口做封装,并提供开放接口. 参考: http://blog.codingnow.com/2006/02/lua_51_module.html module 重载需求 我们实现引用程序,往往要引用若干已经实现的库文件, 这些库大都是开源的,以此来加快应用开发进程 应用库后, 应用编码中, 会引用库的一些API, 例如会是 lfs 库中的 dir 来list目录下的文件