On 26 September 2013 01:20, Gary V. Vaughan <g...@vaughan.pe> wrote: > In the rockspec for Zile I have: > > build = { > copy_directories = { "bin", "doc" }, > … > } > > Where the doc directory contains COPYING, FAQ and some other stuff I'd like > to display with a key chord invoked from Zmacs. > > How do I find the contents of the copied doc tree from Lua (so that it works > regardless of the rocks tree location that contains it)?
Finding resource files portably and with relocatable packages is always tricky... I tried a first approach at tackling this problem with this: https://github.com/hishamhm/datafile I just tested it with zile, and I had to make a minor tweak in LuaRocks to make it work (LuaRocks tested for Lua 5.1 by checking "if setfenv then" and looks like there's a checker for undeclared globals in zile that doesn't like this). After I made the tweak in LR (now in git) I was able do to this in zmacs/main.lua: local datafile = require("datafile") local PATH_FAQ = datafile.path("doc/FAQ") and the LuaRocks-aware opener was able to find the file. datafile is alpha-quality software though, but I really think we need a small portable library to avoid hardcoding paths to resource files. Unix people don't care a lot about making binary installations relocatable (even though I think they should), but on Windows at least I think it's expected that software shouldn't break if you choose to install a binary in a different folder. (datafile supports 'contexts' which helps it finding files. I have 'config' and 'cache' right now as predefined contexts, which are inspired by freedesktop.org paths; "doc" probably deserves to be a predefined context as well.) -- Hisham ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk _______________________________________________ Luarocks-developers mailing list Luarocks-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/luarocks-developers