Template:IO Restrictions: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
m (cat: Templates, Undocumented templates)
Line 17: Line 17:
To learn more about PropertyList processing via loadxml and savexml, please see $FG_ROOT/Docs/README.commands
To learn more about PropertyList processing via loadxml and savexml, please see $FG_ROOT/Docs/README.commands


Internally, all read/write access is validated via an API called '''fgValidatePath()''', for details please see $FG_SRC/Main/util.cxx
Internally, all read/write access is validated via an API called '''fgValidatePath()''', for details please see $FG_SRC/Main/util.cxx<noinclude>
 
[[Category:Templates]]
[[Category:Undocumented templates]]
</noinclude>

Revision as of 19:51, 30 January 2014

Note: All FlightGear disk I/O handled via Nasal scripting and/or fgcommands, is subject to access validation via IOrules. This includes the SGPath bindings in FlightGear 2.99+

However, unlike $FG_ROOT, $FG_HOME is generally accessible for writing, consider this example:

#  come up with a path and filename in $FG_HOME, inside the Export sub folder, file name is test.xml
var filename = getprop("/sim/fg-home") ~ "/Export/test.xml";

# use the write_properties() helper in io.nas, which is a wrapper for the savexml fgcommand (see README.commands)
io.write_properties( path: filename, prop: "/sim" );

This will dump the sub branch of the /sim property tree into $FG_HOME/Export/test.xml

For additional examples, see $FG_ROOT/Nasal/io.nas

To learn more about PropertyList processing via loadxml and savexml, please see $FG_ROOT/Docs/README.commands

Internally, all read/write access is validated via an API called fgValidatePath(), for details please see $FG_SRC/Main/util.cxx