_splitpath

This function used to be supported for QNX 4.x, but not for QNX 6.2.x. ?!?
I guess some people already developped some library functions dealing with
file path/name/ext. for neutrino.

Djibril:

For what it is worth, you can get the ‘dir’ part using dirname(), and the
‘fname.ext’ part using basename(). Neutrino, of course, does not have a
‘node’ part.

Here is an approximation of _splitpath(), but caveat emptor since I have
not completely tested it for equivalence with _splitpath(). It could even be
modified to return, for example, “/net/foo” for the node.

#include <libgen.h> // dirname(), basename()
#include <limits.h> // PATH_MAX, NAME_MAX
#include <string.h> // strncpy(), strcpy(), strcat(), strtok()

void nto_splitpath(const char *apath, char *adir, char *afname, char *aext)
{
static char path[PATH_MAX];
static char fname[NAME_MAX];
char *tok;

strncpy(path, apath, sizeof(path)); // duplicate apath
strcpy(adir, dirname(path)); // extract dir part
strcat(adir, “/”); // append trailing /

strncpy(path, apath, sizeof(path)); // duplicate apath
strncpy(fname, basename(path), sizeof(fname)); // extract fname.ext
*afname = *aext = ‘\0’; // default to no fname.ext

tok = strtok(fname, “.”); // extract fname
if(tok)
{
strcpy(afname, tok);
tok = strtok(NULL, “”); // extract ext
if(tok)
{
*aext = ‘.’; // prefix a dot
strcpy(aext+1, tok);
}
}
}

->>>–Sherwood–>

“Djibril NDIAYE” <djibril.ndiaye@opal-rt.com> wrote in message
news:bckube$92e$1@inn.qnx.com

This function used to be supported for QNX 4.x, but not for QNX 6.2.x. ?!?
I guess some people already developped some library functions dealing with
file path/name/ext. for neutrino.