Programming in Lua : 29.1

https://www.lua.org/pil/29.1.html

This first edition was written for Lua 5.0. While still largely relevant for later versions, there are some differences. The fourth edition targets Lua 5.3 and is available at Amazon and other bookstores. By buying the book, you also help to support the Lua project . Programming in Lua Part IV. The C API Chapter 29. Managing Resources Previously, we implemented a dir function that returned a table with all files from a given directory. Our new implementation will return an iterator that returns a new entry each time it is called. With this new implementation, we will be able to traverse a directory with a loop like this one: for fname in dir(".") do print(fname) end To iterate over a directory, in C, we need a DIR structure. Instances of DIR are created by opendir and must be explicitly released by a call to closedir . Our previous implementation of dir kept its ...

Linked on 2023-10-03 03:59:37 | Similar Links