> pictools > doc > path
> pictools > doc > path
Pictools: C libraries for Programs
V3.3 (445)
path.h / path.c
/pictools/path.h / path.c
Library method to variable-expand and canonicalize a path sring
usage, in C code:  include "path.h"

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.

 
Copyright © 2023 ZweiBieren, All rights reserved. Feb 5, 2023 17:05 GMT Page maintained by ZweiBieren