www.delorie.com/djgpp/doc/libc/libc_828.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]



#include <sys/stat.h>

char * _truename(const char *path, char *true_path);


Given a path of a file, returns in true_path its canonicalized pathname, with all letters uppercased, default drive and directory made explicit, forward slashes converted to backslashes, asterisks converted to appropriate number of of question marks, file and directory names truncated to 8.3 if necessary, "." and ".." resolved, extra slashes (but the last, if present) removed, SUBSTed, JOINed and ASSIGNed drives resolved. Character devices return as "X:/DEVNAME" (note the forward slash!), where X is the CURRENT drive and DEVNAME is the device name (e.g. CON). This is exactly what DOS TRUENAME command does. See Ralph Brown's Interrupt List for more details.

The named path doesn't have to exist, but the drive, if given as part of it, should be a legal DOS drive, as this function hits the disk.

The function will fail if given a path which (1) is an empty string; or (2) contains only the drive letter (e.g. "c:"); or (3) has leading whitespace. It will also fail if it couldn't allocate memory required for its communication with DOS or for true_path (see below).

_truename may not return what you expect for files that don't exist. For instance, if the current directory was entered using a short filename (`c:\thisis~1' instead of `c:\thisisalongname', say), then the truename of an existing file will be a long filename, but the truename of an non-existing file will be a short filename. This can cause problems when comparing filenames. Use _truename_sfn (see section _truename_sfn) instead in this case.

Upon success, the function will place the result in true_path, if that's non-NULL; the buffer should be large enough to contain the largest possible pathname (PATH_MAX characters). If true_path is a NULL pointer, the space to hold the result will be allocated by calling malloc (see section malloc); it is up to the caller to release the buffer by calling free (see section free).

Return Value

The function returns the pointer to the result. In case of any failure, a NULL pointer is returned, and errno is set.




          "True name of %s is %s\n", path, _truename(path, (char *)0));

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004