File System Library for the Lua Programming Language


LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.

LuaFileSystem offers a portable way to access the underlying directory structure and file attributes.

LuaFileSystem is free software and uses the same license as Lua 5.x (MIT).


Current version is 1.8.0. It works with Lua 5.1, 5.2, 5.3 and 5.4, and it runs on various flavors of Unix (including Linux, BSDs, macOS) and Windows.


LuaFileSystem can be installed using LuaRocks:

$ luarocks install luafilesystem

Its source can be found at its GitHub page.


Version 1.8.0 [22/Apr/2020]
  • Lua 5.4 support
  • and lfs.symlinkattributes now work on Windows
  • MACOSX_DEPLOYMENT_TARGET is configurable in the Makefile
  • Fallback to _POSIX_PATH_MAX when MAXPATHLEN is not avaliable
  • Fixed memory leak in case of realloc failure
Version 1.7.0 [15/Sep/2017]
  • symlinkattributes function now provides 'target' field, containing name of the file that the symlink points to.
  • attributes, symlinkattributes, touch, mkdir, and rmdir functions now return system-dependent error code as the third value on error.
  • Fixed detection of closed files for Lua 5.2+ in setmode, lock, and unlock functions.
  • Fixed various compiler warnings.
Version 1.6.3 [15/Jan/2015]
  • Lua 5.3 support.
  • Assorted bugfixes.
Version 1.6.2 [??/Oct/2012]
  • Full Lua 5.2 compatibility (with Lua 5.1 fallbacks)
Version 1.6.1 [01/Oct/2012]
  • fix build for Lua 5.2
Version 1.6.0 [26/Sep/2012]
  • getcwd fix for Android
  • support for Lua 5.2
  • add
  • other bug fixes
Version 1.5.0 [20/Oct/2009]
  • Added explicit next and close methods to second return value of lfs.dir (the directory object), for explicit iteration or explicit closing.
  • Added directory locking via lfs.lock_dir function (see the manual).
Version 1.4.2 [03/Feb/2009]
  • fixed bug lfs.attributes(filename, 'size') overflow on files > 2 Gb again (bug report and patch by KUBO Takehiro).
  • fixed bug Compile error on Solaris 10 (bug report and patch by Aaron B).
  • fixed compilation problems with Borland C.
Version 1.4.1 [07/May/2008]
  • documentation review
  • fixed Windows compilation issues
  • fixed bug in the Windows tests (patch by Shmuel Zeigerman)
  • fixed bug lfs.attributes(filename, 'size') overflow on files > 2 Gb
Version 1.4.0 [13/Feb/2008]
Version 1.3.0 [26/Oct/2007]
Version 1.2.1 [08/May/2007]
  • compatible only with Lua 5.1 (Lua 5.0 support was dropped)
Version 1.2 [15/Mar/2006]
Version 1.1 [30/May/2005]
Version 1.0 [21/Jan/2005]
Version 1.0 Beta [10/Nov/2004]


The LuaFileSystem library was originally designed and implemented by Roberto Ierusalimschy, André Carregal and Tomás Guisasola. It was then maintained by Fábio Mascarenhas for several years and has since been maintained by many contributors -- see the Git history for detailed credits.

Valid XHTML 1.0!