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

Changes

Jump to: navigation, search

Nasal library/os.path

2,064 bytes added, 20:30, 15 April 2018
More doc
{{Nasal doc
|syntax = os.path.realpath;
|text = A string variable that is a string and gives the full file path. This should only be used when the path is an absolute path. If the path is relative, it will simply be appended to the FlightGear folder (the level up from [[$FG_ROOT]]).
|example1 = var path = os.path.new(getprop("/sim/fg-home"));
print(path.realpath); # prints the absolute path of $FG_HOME
}}
 
==== file ====
{{Nasal doc
|syntax = os.path.file;
|text = A string variable that gives the last part of the filepath.
|example1 = var path = os.path.new(getprop("/sim/fg-home"));
print(path.file); # prints "flightgear.org"
}}
==== dir ====
{{Nasal doc
|syntax = os.path.dir;
|text = A string variable that gives all of the filepath except the last element (see <code>os.path.file</code> above).
|example1 = var path = os.path.new("Program Files/temp/text.txt");
print(path.dir); # prints "Program Files/temp"
}}
==== base ====
{{Nasal doc
|syntax = os.path.base;
|text = A string variable that gives all of the filepath except the extension of the file. If the filepath points to a folder, it has the same value as [[#realpath|realpath]].
|example1 = var path = os.path.new("Program Files/temp/text.txt");
print(path.base); # prints "Program Files/temp/text"
}}
==== file_base ====
{{Nasal doc
|syntax = os.path.file_base;
|text = A string variable that gives the file name without the extension. If the filepath points to a folder, it will simply be the folder name.
|example1 = var path = os.path.new("Program Files/temp/text.txt");
print(path.file_base); # prints "text"
}}
==== extension ====
{{Nasal doc
|syntax = os.path.extension;
|text = A string variable that gives the file's extension. If the filepath points to a folder, it will be an empty string.
|example1 = var path = os.path.new("Program Files/temp/text.txt");
print(path.extension); # prints "txt"
}}
==== lower_extension ====
{{Nasal doc
|syntax = os.path.lower_extension;
|text = A string variable that gives the file's extension, but converted to lowercase. If the filepath points to a folder, it will be an empty string.
|example1 = var path = os.path.new("Program Files/temp/text.TXT");
print(path.lower_extension); # prints "txt"
}}
==== complete_lower_extension ====
{{Nasal doc
|syntax = os.path.complete_lower_extension;
|text = This is to be used when a file has a double extension (e.g., <code>.tar.gz</code>). It also converts it to lowercase. If the filepath points to a folder, it will be an empty string.
|example1 = var path = os.path.new("Program Files/temp/text.TAR.GZ");
print(path.complete_lower_extension); # prints "tar.gz"
}}
==== str ====
==== mtime ====

Navigation menu