Blame | Last modification | View Log | RSS feed
/** -*- mode: c; tabs: 4 -*- ************************************************** Module name : path.c* Module type : CMDFILE source file* Environment(s): n/a** Description:path functionsReturns:shortpath,The shortpath function retrieves the short path form of aspecified input path.** Version Who Date DescriptionAPY 26/04/04 Created** $Source: /cvsroot/device/DEVL/UTILS/CMDFILE/shtpath.c,v $* $Revision: 1.2 $ $Date: 2004/10/08 03:07:37 $ $State: Exp $* $Author: ayoung $ $Locker: $*...........................................................................*//** Include Files* ---------------*/#include <ctype.h>#include <unistd.h>#if defined(WIN32)#include <windows.h>#endif#include "cmdfile.h"const char * Shortpath( const char *name, char *buf );intdo_shortpath( String_t *str, const char *s ){char name[ PATH_MAX ], buf[ PATH_MAX ];int len;if (expected(s++, ',') > 0 &&(len = pathargument(s, name, PATH_MAX)) > 0){const char *p;p = Shortpath( name, buf );verbose( " shortpath(%s) = %s", name, p );StringCat(str, p);return (1+len);}return (-1);}const char *Shortpath( const char *name, char *buf ){#if defined(WIN32)DWORD ret;if ((ret = GetShortPathName(name, buf, MAX_PATH)) == 0 ||ret > MAX_PATH - 1){strcpy(buf, name); /* error, return orginial */}return (buf);#else(void) strcpy(buf, name);return buf;#endif}