👨‍💻 about me home CV/Resume 🖊️ Contact Github LinkedIn I’m a Haskeller 📝 Blog Freedom, privacy, tutorials… 🏆 Best of Fizzbuzz LuaX Calculadoira panda upp Haskell todo pwd TPG Nextcloud Git

#BoycottQatar2022   ┇   Why everyone should boycott the World Cup in Qatar

🆕 since August 2022: LuaX is a Lua eXtended interpretor/cross compiler providing a bunch of useful modules (statically linked, no dependency). Nice integration with upp (new functions and modules available to extend upp macros) and also with a soon released but yet confidential project about actor oriented programming!
💣 Kick GAFAMs out (✔️ ǝlƃooפ, ✔️ ʞooqǝɔɐℲ, ✔️ uozɐɯ∀): Stop giving our soul and money to evils, be free and respectful!
📰 Friday 2. April 2021: upp is a panda companion. It’s a Lua-scriptable lightweight text preprocessor.
🆕 since December 2020: Playing with the actor model in an embedded multicore context. C imperative components become C stream pure functions with no side effect ➡️ C low level programming with high level pure functional programming properties 🏆
📰 Saturday 30. January 2021: Playing with Pandoc Lua filters in Lua. panda is a lightweight alternative to abp providing a consistent set of Pandoc filters (text substitution, file inclusion, diagrams, scripts, …).
🆕 Sunday 24. May 2020: Working at EasyMile for more than 5 years. Critical real-time software in C, simulation and monitoring in Haskell ➡️ perfect combo! It’s efficient and funny ;-)

LuaX: Lua eXtended

Christophe Delord - http://cdelord.fr/luax

File System

fs is a File System module. It provides functions to handle files and directory in a portable way.

local fs = require "fs"

Core module (C)

fs.getcwd()

returns the current working directory.

fs.chdir(path)

changes the current directory to path.

fs.dir([path])

returns the list of files and directories in path (the default path is the current directory).

fs.glob(pattern)

returns the list of path names matching a pattern.

Note: not implemented on Windows.

fs.remove(name)

deletes the file name.

fs.rename(old_name, new_name)

renames the file old_name to new_name.

fs.copy(source_name, target_name)

copies file source_name to target_name. The attributes and times are preserved.

fs.mkdir(path)

creates a new directory path.

fs.stat(name)

reads attributes of the file name. Attributes are:

fs.inode(name)

reads device and inode attributes of the file name. Attributes are:

fs.chmod(name, other_file_name)

sets file name permissions as file other_file_name (string containing the name of another file).

fs.chmod(name, bit1, ..., bitn)

sets file name permissions as bit1 or … or bitn (integers).

fs.touch(name)

sets the access time and the modification time of file name with the current time.

fs.touch(name, number)

sets the access time and the modification time of file name with number.

fs.touch(name, other_name)

sets the access time and the modification time of file name with the times of file other_name.

fs.basename(path)

return the last component of path.

fs.dirname(path)

return all but the last component of path.

fs.splitext(path)

return the name without the extension and the extension.

fs.realpath(path)

return the resolved path name of path.

fs.absname(path)

return the absolute path name of path.

fs.sep

is the directory separator.

fs.uR, fs.uW, fs.uX
fs.gR, fs.gW, fs.gX
fs.oR, fs.oW, fs.oX
fs.aR, fs.aW, fs.aX

are the User/Group/Other/All Read/Write/eXecute mask for fs.chmod.

Additional functions (Lua)

fs.join(...)

return a path name made of several path components (separated by fs.sep). If a coomponent is absolute, the previous components are removed.

fs.is_file(name)

returns true if name is a file.

fs.is_dir(name)

returns true if name is a directory.

fs.findpath(name)

returns the full path of name if name is found in $PATH or nil.

fs.mkdirs(path)

creates a new directory path and its parent directories.

fs.mv(old_name, new_name)

alias for fs.rename(old_name, new_name).

fs.rm(name)

alias for fs.remove(name).

fs.rmdir(path, [params])

deletes the directory path and its content recursively.

fs.walk([path], [{reverse=true|false, links=true|false, cross=true|false}])

returns a list listing directory and file names in path and its subdirectories (the default path is the current directory).

Options:

fs.with_tmpfile(f)

calls f(tmp) where tmp is the name of a temporary file.

fs.with_tmpdir(f)

calls f(tmp) where tmp is the name of a temporary directory.

fs.read(filename)

returns the content of the file filename.

fs.write(filename, ...)

write ... to the file filename.