Anton Gomez Alvedro
8b16a71d50
Adds assert() for Nasal and fixes io.include internal marking
...
- A simple assert() function is added to the globals namespace.
- io.include() marks the target namespace to avoid dependency loops.
If the namespace is marked before the script to be included is
compiled, a parse error leaves the target namespace marked while
the script has not been loaded. This patch fixes this problem.
2014-06-06 21:41:10 -05:00
Anton Gomez Alvedro
6ae3fae393
Add io.include() function to Nasal base library
...
io.inlude() loads and executes a Nasal file in place, effectively embedding
the script in the calling namespace. The function adds a symbol mark in the
namespace to avoid duplicate loading.
Additionally, in this path:
+ io.basename() & io.dirname(): Convenience functions for managing path
strings. Designed after their unix counterparts.
+ string.normpath(): Improved support for relative paths. It can now handle
paths starting with double dots, like ../../Directory
2013-12-08 11:51:34 -06:00
Thomas Geymayer
d80722065f
Fix path validation (ensure listeners are attached to existing nodes)
2013-04-29 22:27:26 +02:00
ThorstenB
6662ba5006
Access checker: properly convert paths to the norm.
...
The same was already done for fg-root and fg-home paths - it was only
missing for fg-scenery and fg-aircraft paths.
2012-11-16 20:34:32 +01:00
James Turner
d4fb116cd2
Nasal IO changes to work with new loadxml features
2011-05-25 21:27:07 +01:00
James Turner
8fd716f2ca
Extend IORules system to permit aircraft dirs.
2010-08-16 11:08:24 +01:00
mfranz
cf88f5e8a4
remove is{dir,reg,lnk,sock,fifo,blk,chr}. The vector returned by io.stat()
...
does now contain the type in element 11.
2009-02-15 21:08:55 +00:00
mfranz
fed30b2f05
io.nas: add deprecation warning to io.is{dir,fifo,lnk,...}
2009-02-15 18:26:20 +00:00
mfranz
117dac8b4f
removelistener() must not remove path validation listeners
2008-12-12 14:57:38 +00:00
mfranz
bcc043a368
security wrappers: move original func var into wrapper closure
2008-11-26 16:17:55 +00:00
mfranz
2f76461c8c
io.nas/stat: drop use of broken bits library
...
gui.nas/OverlaySelector: me.data is no longer a node; only sort once
2008-10-21 21:37:41 +00:00
mfranz
c350a7b6a8
s/fixpath/normpath/ (as in python)
2008-10-15 16:35:11 +00:00
mfranz
fe8f9134ec
fun hack to get useful error message
2008-10-06 23:21:54 +00:00
mfranz
d9b5505a39
load_nasal(): hack around new Nasal bug
2008-10-06 21:21:13 +00:00
mfranz
4ac84809e9
nasal: cleanup & minor fixes
...
- fuel.nas: use props.initNode()
- debug.nas: fix comment
- globals.nas: load_nasal(): check extension and set module arg
- io.nas: update log message (the rules are no longer for io.open() only)
2008-08-10 17:53:41 +00:00
mfranz
49defb639e
- load_nasal(): catch usage of improper namespaces (e.g. $FG_HOME/Nasal/isa.nas)
...
- IOrules: add harmless rule for extremely popular Nasal addon script :-)
2008-07-30 20:34:52 +00:00
mfranz
daee426f00
minor reorganization and cosmetics
2008-07-24 17:41:40 +00:00
mfranz
9148a4b2eb
cosmetics: white space fix & one "var" added
2008-07-23 19:37:51 +00:00
mfranz
f046c00c3d
make valdiation listeners safe
2008-07-23 15:42:16 +00:00
mfranz
fee6139da5
partly revert last change: thisfunc() isn't safe enough for this purpose
2008-07-23 00:41:18 +00:00
mfranz
7bbbfa6a8e
use thisfunc() instead of caller(0)[1]
2008-07-22 23:26:46 +00:00
mfranz
54e6ec55b4
closure(): better error formatting
2008-07-22 22:50:42 +00:00
mfranz
e522611638
closure(): level is optional and defaults to 0
2008-07-22 22:38:34 +00:00
mfranz
1ad5b18ec8
closure(): must freeze io.open for the comparison
2008-07-22 22:26:09 +00:00
mfranz
dc4b8633a3
new io.open()'s closure musn't get manipulated either
2008-07-22 21:30:47 +00:00
mfranz
3cfc93927f
make sure the closure of security code can't be manipulated by wrapping
...
closure()
2008-07-22 21:23:54 +00:00
mfranz
cb3150b915
(failing attempt to) lock down two functions
2008-07-22 16:46:18 +00:00
mfranz
32f1730c6e
- load_nasal: better error message if compile() fails
...
- io.open handler: extract validation to separate function and
- add detached read/write validation listeners
2008-07-11 15:37:27 +00:00
mfranz
3be5c6956b
io: use default attribs rather than a hard-coded number for globals identification
...
gui/tutorial/aircraft: use io.read_properties()/io.write_properties()
2008-07-11 09:37:33 +00:00
mfranz
9be716de1c
typo
2008-07-10 16:55:45 +00:00
mfranz
8909695f36
add io.{read,write}_properties() convenience wrappers for
...
fgcommand("loadxml") and fgcommand("savexml")
2008-07-10 16:53:43 +00:00
mfranz
6e24e077ba
- invert io.load_nasal() return value
...
- let load_rules() return nil or the path (rather than 0 or 1)
- better log output
- cosmetics
2008-07-03 16:23:13 +00:00
mfranz
6f9f70e84d
- don't use undefined variable `curr'
...
- cosmetics
2008-06-22 18:00:02 +00:00
mfranz
caca942012
revert last change: don't append cwd to relative paths for now. There's
...
no way yet to safely detect absolute paths, so this would break on MS Windows.
This will only mean that relative paths will always fail, as they don't
match any pattern. These are all absolute.
2008-06-22 13:54:36 +00:00
mfranz
875b99c90e
whoops, wrong quotes
2008-06-22 12:17:02 +00:00
mfranz
5240b57018
io.open(): turn relative paths into absolute ones before checking
2008-06-22 11:31:41 +00:00
mfranz
d86b1b9c74
string.nas: new functions string.join() and string.replace()
...
debug.nas: let benchmark() repeat tested function
io.nas: cosmetics
aircraft.nas: initialize time property only once
2008-06-21 07:10:32 +00:00
mfranz
ab08bfb8eb
make sure that a die() (e.g. caused by an IOrules file being read protected)
...
doesn't disable the whole security mechanism
2008-06-16 11:19:29 +00:00
mfranz
94e010e4d1
whoops ... s/and/or/
2008-06-16 11:00:05 +00:00
mfranz
bf9c2dc6a5
read rules for io.open() file access from $FG_ROOT/Nasal/IOrules or, if
...
available, from $FG_HOME/Nasal/IOrules. That's desirable because
ordinary users aren't allowed to edit files in $FG_ROOT.
2008-06-16 10:47:02 +00:00
mfranz
7cc783c2f5
this comes from not using tabs ... sigh
2008-06-16 07:16:10 +00:00
mfranz
b5cdfeb2b8
... and allow reading only from ~/.fgfs/* and $FG_ROOT/*
2008-06-16 07:07:50 +00:00
mfranz
df018fff49
only allow writing to ~/.fgfs/Scenery/*.stg and ~/.fgfs/Export/*
2008-06-16 06:32:32 +00:00
mfranz
141f1c8da4
must not use setlistener in $FG_ROOT/Nasal/*.nas ...
2008-06-15 10:11:32 +00:00
mfranz
0fad328217
load_nasal: boolify result, as the number doesn't mean anything and might
...
be confusing
2008-06-14 22:39:28 +00:00
mfranz
62cc0f457c
load_nasal: fix module and let it return whether there was an error
2008-06-14 14:25:34 +00:00
mfranz
a79c0e95c5
move load_nasal() here from the debug module
2008-06-14 14:22:34 +00:00
mfranz
c159ea1755
io.open(): drop die() color
2008-06-13 19:19:54 +00:00
mfranz
4a30ad6efe
io.open(): remove debug messages (for easier code review)
2008-06-13 19:14:48 +00:00
mfranz
59e3d65545
and die() with red color for now
2008-06-13 13:18:16 +00:00