If you have a file path, you can do it manually by making it an absolute path if it is relative (doesn't start with / on Unix, or letter:\ or \ or letter:/ or / on Windows) and then splitting it to file separator characters ( / or \ ), but I donβt know any built-in function that will do all this for you.
The basename and dirname functions may help, but you only need to figure out the path to the file, since they only work with strings; they do not interrogate the file system.
source share