Nasal library/os.path: Difference between revisions

More doc
(Doc canRead() and Write())
(More doc)
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
{{Nasal doc
Line 23: Line 22:
print(path.realpath);
print(path.realpath);
}}
}}
==== set() ====
==== set() ====
{{Nasal doc
{{Nasal doc
Line 37: Line 35:
print(path.realpath); # prints new path
print(path.realpath); # prints new path
}}
}}
==== append() ====
==== append() ====
{{Nasal doc
{{Nasal doc
Line 51: Line 48:
print(path.realpath); # prints "C:/Windows/Program Files" or "/usr/bin"
print(path.realpath); # prints "C:/Windows/Program Files" or "/usr/bin"
}}
}}
==== concat() ====
==== concat() ====
{{Nasal doc
{{Nasal doc
Line 65: Line 61:
print(path.realpath); # prints "C:/Windows/Program Files" or "/usr/bin"
print(path.realpath); # prints "C:/Windows/Program Files" or "/usr/bin"
}}
}}
==== exists() ====
==== exists() ====
{{Nasal doc
{{Nasal doc
Line 77: Line 72:
print(path.exists()); # prints 0 (false)
print(path.exists()); # prints 0 (false)
}}
}}
==== canRead() ====
==== canRead() ====
{{Nasal doc
{{Nasal doc
Line 88: Line 82:
print(path.canRead()); # prints 1 (true)
print(path.canRead()); # prints 1 (true)
}}
}}
==== canWrite() ====
==== canWrite() ====
{{Nasal doc
{{Nasal doc
Line 99: Line 92:
print(path.canWrite()); # prints 1 (true)
print(path.canWrite()); # prints 1 (true)
}}
}}
==== isFile() ====
==== 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() ====
==== 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() ====
==== 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() ====
==== 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() ====
==== isNull() ====
==== create_dir() ====
==== create_dir() ====