Nasal library/os.path: Difference between revisions

Doc canRead() and Write()
(Doc canRead() and Write())
Line 79: Line 79:


==== canRead() ====
==== canRead() ====
{{Nasal doc
|syntax = os.path.canRead();
|text = Returns 1 (true) if the path can be read (from Nasal) and 0 (false) if it cannot. This follows the rules for allowed paths.
|example1 = var path = os.path.new("C:/Windows");
# var path = os.path.new("/usr"); # alternative Unix filepath
print(path.canRead()); # prints 0 (false)
path.set(getprop("sim/fg-home"));
print(path.canRead()); # prints 1 (true)
}}
==== canWrite() ====
==== canWrite() ====
{{Nasal doc
|syntax = os.path.canWrite();
|text = Returns 1 (true) if the path can be written to (from Nasal) and 0 (false) if it cannot. This follows the rules for allowed paths.
|example1 = var path = os.path.new("C:/Windows");
# var path = os.path.new("/usr"); # alternative Unix filepath
print(path.canWrite()); # prints 0 (false)
path.set(getprop("sim/fg-home") ~ "/txt.log");
print(path.canWrite()); # prints 1 (true)
}}
==== isFile() ====
==== isFile() ====
==== isDir() ====
==== isDir() ====