It's not quite clear what are you trying to accomplish.
If what you want is to parse a string like "/home/user/public_html/welcome.html" (or similarly, "C:\home\user\public_html\welcome.html") and return something like
Code:
name=welcome.html
level=3 // with zero-based level number
then it's a trivial task of simply searching the string for the occurence of '/' or '\'.
If you're looking for a concrete implementation in a particular language, then you should probably ask it in that language's forum (I would call it bad taste to resort here to any language in particular :)
If you actually want to really "parse a physical drive" and get the same result for a given file name, it would require knowledge of the underlying filesystem. Since there is a plethora of those available (among them Ext2, Ext3, NTFS, FAT[32], ReiserFS, UFS; just to mention a few), so it's impossible to answer your question. Even then, it's not a matter of algorithms, but rather a question of "specification of filesystem implementation".
If your question is something completely different, then accept my apology for not knowing any better.
That's it.