Nasal library/os.path

From FlightGear wiki
Revision as of 19:28, 11 February 2018 by Red Leader (talk | contribs) (→‎Class: .new: Add Unix example)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This page contains documentation for the os.path namespace in Nasal. This namespace implements tools (from SGPath) for manipulating file paths. Everything in the geo namespace is sourced from flightgear/src/Scripting/NasalSGPath.cxx

Tip  Copy & paste the examples into your Nasal Console and execute them to see what they do.
Note  Everything here was added to FlightGear 3.0.

Class

os.path

A pseudo-class (actually a Nasal ghost). This is the main class that stores and allows manipulation of file paths. This is also integrated into the os.path.


new()

geo.Coord.new(path);

Constructor function. Returns a new os.path instance.

path
A string pointing to a filepath.

Example

var path = os.path.new("C:/Windows"); # A Windows filepath
# var path = os.path.new("/usr/bin/"); # A Unix filepath
print(path.realpath);

set()

append()

concat()

exists()

canRead()

canWrite()

isFile()

isDir()

isRelative()

isAbsolute()

isNull()

create_dir()

remove()

rename()

realpath

file

dir

base

file_base

extension

lower_extension

complete_lower_extension

str

mtime

Functions

desktop()

standardLocation()