The Path class / Examples |
IMPORT os MAIN DISPLAY "Dir name = ", os.Path.dirname(arg_val(1)) DISPLAY "Base name = ", os.Path.basename(arg_val(1)) DISPLAY "Root name = ", os.Path.rootname(arg_val(1)) DISPLAY "Extension = ", os.Path.extension(arg_val(1)) END MAIN
Example results:
Path | os.Path.dirname | os.Path.basename | os.Path.rootname | os.Path.extension |
---|---|---|---|---|
. |
. |
. |
NULL |
|
.. |
. |
.. |
. |
NULL |
/ |
/ |
/ |
/ |
NULL |
/usr/lib |
/usr |
lib |
/usr/lib |
NULL |
/usr/ |
/ |
usr |
/usr/ |
NULL |
usr |
. |
usr |
usr |
NULL |
file.xx |
. |
file.xx |
file |
xx |
/tmp.yy/file.xx |
/tmp.yy |
file.xx |
/tmp.yy/file |
xx |
/tmp.yy/file.xx.yy |
/tmp.yy |
file.xx.yy |
/tmp.yy/file.xx |
yy |
/tmp.yy/ |
/ |
tmp.yy |
/tmp.yy/ |
NULL |
/tmp.yy/. |
/tmp.yy |
. |
/tmp.yy/ |
NULL |
These examples use UNIX™ file names. On Windows™ the result would be different, as the file name separator is a backslash (\).