Offers the single function unfoldFileName
to convert a general path to its simplest form.
-
char *unfoldFileName(char *fromString, char *toString, char *basefile)
- Processes a file name to remove various embellishemnts:
- remove path folds: /../, ./, //
- expand references to environment values: $NAME, ${NAME}, or $(NAME)
- expand leading "
~
" with home directory
- make path absolute
If not absolute, the path is made so by prepending
the current working directory and the path to basefile.
(See the description in path.h of HandleRelativeFile
.)
Returns the toString argument, with the modified path. (There is no good guidance on the proper size for toString.)
RESTRICTION: When there are symlinks, "..
" can be meaningful, so the end result would be entirely different. This code does not check for symlinks.
TODO: Discard the toStrring argument and always return a newly created string.
CREDIT: I originally wrote this code as part of the Andrew User Interface System.