lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Nov 3, 2011 at 10:29 PM, David Manura <> wrote:
> file_slurp [1] provides simple functions to read/write entire files from/to a string.

Here's two more Perl-inspired modules written in the same style to
solve another common problem.


  -- /qux/bar/baz.lua
  print(require 'findbin'.bin) --> prints directory of script (/qux/bar)
  require 'lib' (require 'findbin' '/../lib')
     -- adds a path relative to the directory of the current script to the
     -- package search paths (package.path & package.cpath).
  require 'foo'  -- loads from new search paths (/qux/lib/foo.lua)

     module 'findbin' - Locate directory of original Lua script
     module 'lib' - Simple insertion of directories in package search paths.
     module 'file_slurp' - Easily read/write entire files from/to a string.