drop the lfs library
I can't feel confident about its sandboxing story yet. And if we can't build a file navigator, what are we even doing with it.
This commit is contained in:
parent
6f5f6849dd
commit
5e976554dd
|
@ -125,8 +125,6 @@ rely on packages distributed by the following reputable brands:
|
||||||
Teliva's codebase also includes forks of the following reputable brands:
|
Teliva's codebase also includes forks of the following reputable brands:
|
||||||
|
|
||||||
* [Lua 5.1](https://www.lua.org/manual/5.1)
|
* [Lua 5.1](https://www.lua.org/manual/5.1)
|
||||||
* The [Lua File System](https://keplerproject.github.io/luafilesystem) library
|
|
||||||
for portably accessing directories (module `lfs`).
|
|
||||||
* The [Kilo](https://github.com/antirez/kilo) text editor, modified to use
|
* The [Kilo](https://github.com/antirez/kilo) text editor, modified to use
|
||||||
ncurses. (Read more about it in this [fantastic walk-through](https://viewsourcecode.org/snaptoken/kilo).)
|
ncurses. (Read more about it in this [fantastic walk-through](https://viewsourcecode.org/snaptoken/kilo).)
|
||||||
* The [lcurses](https://github.com/lcurses/lcurses) binding for ncurses (as
|
* The [lcurses](https://github.com/lcurses/lcurses) binding for ncurses (as
|
||||||
|
@ -188,7 +186,6 @@ them in Teliva and let people use regular Lua. Or other platforms!
|
||||||
- `os.execute`, `os.getenv`, `io.popen`
|
- `os.execute`, `os.getenv`, `io.popen`
|
||||||
- `io.lines` (not a security issue; just difficult to distinguish missing
|
- `io.lines` (not a security issue; just difficult to distinguish missing
|
||||||
files from sandboxing issues)
|
files from sandboxing issues)
|
||||||
- `lfs.chdir`, `lfs.currentdir`
|
|
||||||
|
|
||||||
- Some functions are disabled because they don't seem to make sense in an
|
- Some functions are disabled because they don't seem to make sense in an
|
||||||
ncurses environment. This includes the Lua notions of default files, which
|
ncurses environment. This includes the Lua notions of default files, which
|
||||||
|
|
117
commander.tlv
117
commander.tlv
|
@ -1,117 +0,0 @@
|
||||||
# .tlv file generated by https://github.com/akkartik/teliva
|
|
||||||
# You may edit it if you are careful; however, you may see cryptic errors if you
|
|
||||||
# violate Teliva's assumptions.
|
|
||||||
#
|
|
||||||
# .tlv files are representations of Teliva programs. Teliva programs consist of
|
|
||||||
# sequences of definitions. Each definition is a table of key/value pairs. Keys
|
|
||||||
# and values are both strings.
|
|
||||||
#
|
|
||||||
# Lines in .tlv files always follow exactly one of the following forms:
|
|
||||||
# - comment lines at the top of the file starting with '#' at column 0
|
|
||||||
# - beginnings of definitions starting with '- ' at column 0, followed by a
|
|
||||||
# key/value pair
|
|
||||||
# - key/value pairs consisting of ' ' at column 0, containing either a
|
|
||||||
# spaceless value on the same line, or a multi-line value
|
|
||||||
# - multiline values indented by more than 2 spaces, starting with a '>'
|
|
||||||
#
|
|
||||||
# If these constraints are violated, Teliva may unceremoniously crash. Please
|
|
||||||
# report bugs at http://akkartik.name/contact
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
str_helpers:
|
|
||||||
>-- some string helpers from http://lua-users.org/wiki/StringIndexing
|
|
||||||
>
|
|
||||||
>-- index characters using []
|
|
||||||
>getmetatable('').__index = function(str,i)
|
|
||||||
> if type(i) == 'number' then
|
|
||||||
> return str:sub(i,i)
|
|
||||||
> else
|
|
||||||
> return string[i]
|
|
||||||
> end
|
|
||||||
>end
|
|
||||||
>
|
|
||||||
>-- ranges using (), selected bytes using {}
|
|
||||||
>getmetatable('').__call = function(str,i,j)
|
|
||||||
> if type(i)~='table' then
|
|
||||||
> return str:sub(i,j)
|
|
||||||
> else
|
|
||||||
> local t={}
|
|
||||||
> for k,v in ipairs(i) do
|
|
||||||
> t[k]=str:sub(v,v)
|
|
||||||
> end
|
|
||||||
> return t:concat()
|
|
||||||
> end
|
|
||||||
>end
|
|
||||||
>
|
|
||||||
>-- iterate over an ordered sequence
|
|
||||||
>function q(x)
|
|
||||||
> if type(x) == 'string' then
|
|
||||||
> return x:gmatch('.')
|
|
||||||
> else
|
|
||||||
> return ipairs(x)
|
|
||||||
> end
|
|
||||||
>end
|
|
||||||
>
|
|
||||||
>-- insert within string
|
|
||||||
>function string.insert(str1, str2, pos)
|
|
||||||
> return str1:sub(1,pos)..str2..str1:sub(pos+1)
|
|
||||||
>end
|
|
||||||
>
|
|
||||||
>function string.remove(s, pos)
|
|
||||||
> return s:sub(1,pos-1)..s:sub(pos+1)
|
|
||||||
>end
|
|
||||||
>
|
|
||||||
>-- TODO: backport utf-8 support from Lua 5.3
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
menu:
|
|
||||||
>-- To show app-specific hotkeys in the menu bar, add hotkey/command
|
|
||||||
>-- arrays of strings to the menu array.
|
|
||||||
>menu = {}
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
Window:
|
|
||||||
>Window = curses.stdscr()
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
render:
|
|
||||||
>function render(window)
|
|
||||||
> window:clear()
|
|
||||||
> for f in lfs.dir('.') do
|
|
||||||
> if f ~= '.' and f ~= '..' then
|
|
||||||
> local attr = lfs.attributes(f)
|
|
||||||
> print(f, attr.permissions, attr.size, attr.access, attr.modification)
|
|
||||||
> end
|
|
||||||
> end
|
|
||||||
> window:refresh()
|
|
||||||
>end
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
update:
|
|
||||||
>function update(window)
|
|
||||||
> local key = window:getch()
|
|
||||||
> -- process key here
|
|
||||||
>end
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
init_colors:
|
|
||||||
>function init_colors()
|
|
||||||
> for i=0,7 do
|
|
||||||
> curses.init_pair(i, i, -1)
|
|
||||||
> end
|
|
||||||
> curses.init_pair(8, 7, 0)
|
|
||||||
> curses.init_pair(9, 7, 1)
|
|
||||||
> curses.init_pair(10, 7, 2)
|
|
||||||
> curses.init_pair(11, 7, 3)
|
|
||||||
> curses.init_pair(12, 7, 4)
|
|
||||||
> curses.init_pair(13, 7, 5)
|
|
||||||
> curses.init_pair(14, 7, 6)
|
|
||||||
> curses.init_pair(15, -1, 15)
|
|
||||||
>end
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
main:
|
|
||||||
>function main()
|
|
||||||
> init_colors()
|
|
||||||
>
|
|
||||||
> while true do
|
|
||||||
> render(Window)
|
|
||||||
> update(Window)
|
|
||||||
> end
|
|
||||||
>end
|
|
||||||
- __teliva_timestamp: original
|
|
||||||
doc:blurb:
|
|
||||||
>beginnings of a file browser..
|
|
|
@ -27,7 +27,7 @@ LUA_A= liblua.a
|
||||||
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
|
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
|
||||||
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
|
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
|
||||||
lundump.o lvm.o lzio.o \
|
lundump.o lvm.o lzio.o \
|
||||||
realpath.o lfs.o kilo.o tlv.o teliva.o
|
realpath.o kilo.o tlv.o teliva.o
|
||||||
LIB_O= lauxlib.o lbaselib.o liolib.o lmathlib.o loslib.o \
|
LIB_O= lauxlib.o lbaselib.o liolib.o lmathlib.o loslib.o \
|
||||||
ltablib.o lstrlib.o linit.o
|
ltablib.o lstrlib.o linit.o
|
||||||
|
|
||||||
|
@ -167,7 +167,6 @@ lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \
|
||||||
print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
|
print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
|
||||||
ltm.h lzio.h lmem.h lopcodes.h lundump.h
|
ltm.h lzio.h lmem.h lopcodes.h lundump.h
|
||||||
realpath.o: realpath.c
|
realpath.o: realpath.c
|
||||||
lfs.o: lfs.c lfs.h lua.h lauxlib.h lualib.h
|
|
||||||
kilo.o: kilo.c lua.h teliva.h
|
kilo.o: kilo.c lua.h teliva.h
|
||||||
teliva.o: teliva.c lua.h lauxlib.h lualib.h teliva.h tlv.h
|
teliva.o: teliva.c lua.h lauxlib.h lualib.h teliva.h tlv.h
|
||||||
|
|
||||||
|
|
35
src/lfs.h
35
src/lfs.h
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
** LuaFileSystem
|
|
||||||
** Copyright Kepler Project 2003 - 2020
|
|
||||||
** (http://keplerproject.github.io/luafilesystem)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define 'chdir' for systems that do not implement it */
|
|
||||||
#ifdef NO_CHDIR
|
|
||||||
#define chdir(p) (-1)
|
|
||||||
#define chdir_error "Function 'chdir' not provided by system"
|
|
||||||
#else
|
|
||||||
#define chdir_error strerror(errno)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define chdir(p) (_chdir(p))
|
|
||||||
#define getcwd(d, s) (_getcwd(d, s))
|
|
||||||
#define rmdir(p) (_rmdir(p))
|
|
||||||
#define LFS_EXPORT __declspec (dllexport)
|
|
||||||
#ifndef fileno
|
|
||||||
#define fileno(f) (_fileno(f))
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define LFS_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LFS_EXPORT int luaopen_lfs(lua_State * L);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -21,7 +21,6 @@ static const luaL_Reg lualibs[] = {
|
||||||
{LUA_OSLIBNAME, luaopen_os},
|
{LUA_OSLIBNAME, luaopen_os},
|
||||||
{LUA_STRLIBNAME, luaopen_string},
|
{LUA_STRLIBNAME, luaopen_string},
|
||||||
{LUA_MATHLIBNAME, luaopen_math},
|
{LUA_MATHLIBNAME, luaopen_math},
|
||||||
{LUA_LFSLIBNAME, luaopen_lfs},
|
|
||||||
{LUA_CURSESLIBNAME, luaopen_curses},
|
{LUA_CURSESLIBNAME, luaopen_curses},
|
||||||
{LUA_SOCKETCORELIBNAME, luaopen_socket_core},
|
{LUA_SOCKETCORELIBNAME, luaopen_socket_core},
|
||||||
{LUA_MIMECORELIBNAME, luaopen_mime_core},
|
{LUA_MIMECORELIBNAME, luaopen_mime_core},
|
||||||
|
|
|
@ -33,9 +33,6 @@ LUALIB_API int (luaopen_string) (lua_State *L);
|
||||||
#define LUA_MATHLIBNAME "math"
|
#define LUA_MATHLIBNAME "math"
|
||||||
LUALIB_API int (luaopen_math) (lua_State *L);
|
LUALIB_API int (luaopen_math) (lua_State *L);
|
||||||
|
|
||||||
#define LUA_LFSLIBNAME "lfs"
|
|
||||||
LUALIB_API int (luaopen_lfs) (lua_State *L);
|
|
||||||
|
|
||||||
#define LUA_CURSESLIBNAME "curses"
|
#define LUA_CURSESLIBNAME "curses"
|
||||||
LUALIB_API int (luaopen_curses) (lua_State *L);
|
LUALIB_API int (luaopen_curses) (lua_State *L);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue