Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Nasal library/os.path"

From FlightGear wiki
Jump to: navigation, search
m (Add note on history)
Line 12: Line 12:
 
|text = 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 <code>os.path</code>.
 
|text = 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 <code>os.path</code>.
 
}}
 
}}
 +
 
==== new() ====
 
==== new() ====
 +
{{Nasal doc
 +
|syntax = geo.Coord.new(path);
 +
|text = Constructor function. Returns a new <code>os.path</code> instance.
 +
|param1 = path
 +
|param1text = A string pointing to a filepath.
 +
|example1 = # Note: This is a Windows filepath
 +
var path = os.path.new("C:/Windows");
 +
print(path.realpath);
 +
}}
 +
 
==== set() ====
 
==== set() ====
 
==== append() ====
 
==== append() ====

Revision as of 14:38, 11 February 2018

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

# Note: This is a Windows filepath
var path = os.path.new("C:/Windows");
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()