If you have the path of the file, you can do it manually by making it an absolute path if it is relative (doesn't begin with a /
on Unix, or a letter:
or
or letter:/
or /
on Windows) and then splitting it on file separator characters (/
or
), but I am aware of no built-in function that will do all of this for you.
The basename
and dirname
functions may help, but you'll need to figure out enough of the path of the file yourself, as they only work with strings; they do not interrogate the file system.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…