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

1,161 bytes added, 20:32, 18 February 2018
More doc
|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() ====
{{Nasal doc
print(path.realpath);
}}
 
==== set() ====
{{Nasal doc
print(path.realpath); # prints new path
}}
 
==== append() ====
{{Nasal doc
print(path.realpath); # prints "C:/Windows/Program Files" or "/usr/bin"
}}
 
==== concat() ====
{{Nasal doc
print(path.realpath); # prints "C:/Windows/Program Files" or "/usr/bin"
}}
 
==== exists() ====
{{Nasal doc
print(path.exists()); # prints 0 (false)
}}
 
==== canRead() ====
{{Nasal doc
print(path.canRead()); # prints 1 (true)
}}
 
==== canWrite() ====
{{Nasal doc
print(path.canWrite()); # prints 1 (true)
}}
 
==== isFile() ====
{{Nasal doc
|syntax = os.path.isFile();
|text = Returns 1 (true) if the path points to a file and 0 (false) if it points to a directory. Note that the path must also exist.
|example1 = var path = os.path.new(getprop("sim/fg-root"));
print(path.isFile()); # prints 0 (false)
path.append("Nasal/io.nas");
print(path.isFile()); # prints 1 (true)
}}
==== isDir() ====
{{Nasal doc
|syntax = os.path.isDir();
|text = Returns 1 (true) if the path points to a directory and 0 (false) if it points to a file. Note that the path must also exist.
|example1 = var path = os.path.new(getprop("sim/fg-root"));
print(path.isDir()); # prints 1 (true)
path.append("Nasal/io.nas");
print(path.isDir()); # prints 0 (false)
}}
==== isRelative() ====
{{Nasal doc
|syntax = os.path.isRelative();
|text = Returns 1 (true) if the path is relative and 0 (false) if it is not.
|example1 = var path = os.path.new(getprop("sim/fg-root"));
path.set("./Nasal");
print(path.isRelative()); # prints 1 (true)
}}
==== isAbsolute() ====
{{Nasal doc
|syntax = os.path.isDir();
|text = Returns 1 (true) if the path is an absolute path and 0 (false) if it is not.
|example1 = var path = os.path.new(getprop("sim/fg-root"));
print(path.isAbsolute()); # prints 1 (true)
}}
==== isNull() ====
==== create_dir() ====

Navigation menu