TRAMP package redefines lisp functions
file-name-directory
and file-name-nondirectory
to
accommodate the unique file naming syntax that TRAMP requires.
The replacements dissect the file name, use the original handler for the localname, take that result, and then re-build the TRAMP file name. By relying on the original handlers for localnames, TRAMP benefits from platform specific hacks to the original handlers.