Nasal library/os.path: Difference between revisions

Jump to navigation Jump to search
Doc remove()
mNo edit summary
(Doc remove())
Line 139: Line 139:
path.create_dir(); # Creates $FG_HOME/Export/test/
path.create_dir(); # Creates $FG_HOME/Export/test/
}}
}}
==== remove() ====
{{Nasal doc
|syntax = os.path.remove();
|text = Removes the last element of the path from the file directory. This will only work if the path is absolute and deletion of the file is permitted by the file permissions (typically okay under [[$FG_HOME]]/Export). Note that on Windows, deletion of read-only files are never permitted.
|example1 = var path = os.path.new(getprop("/sim/fg-home") ~ "/Export/demo.txt");
var file = io.open(path.realpath, "w");
io.write(file, 'Hello, World' ~ "/n");
io.close(file);
print(path.exists()); # prints "1"


==== remove() ====
path.remove();
print(path.exists()); # prints "0"
|example2 = var path = os.path.new(getprop("/sim/fg-home") ~ "/Export/test");
path.create_dir();
path.remove(); # folder "/test" is removed
}}
==== rename() ====
==== rename() ====
==== realpath ====
==== realpath ====

Navigation menu