Provided by: manpages-zh_1.5.2-1_all bug

NAME

       dirname, basename -

 (SYNOPSIS)
       #include <libgen.h>

       char *dirname(char *path);
       char *basename(char *path);

 (DESCRIPTION)
       dirname  basename    null        .  ,  dirname     ,  ()  '/', basename
       '/'   .    '/' ,  '/'     .

        path   '/', dirname    ".",  basename  path   .   path   "/",  dirname
       basename   "/".  path  NULL    , dirname basename   ".".

        dirname  , "/", basename    ,      .

        dirname basename path  ,      ,     . , dirname basename        ,    .

          ( SUSv2)    , dirname basename   :

       path           dirname        basename
       "/usr/lib"     "/usr"         "lib"
       "/usr/"        "/"            "usr"
       "usr"          "."            "usr"
       "/"            "/"            "/"
       "."            "."            "."
       ".."           "."            ".."

 (EXAMPLE)
       char *dirc, *basec, *bname, *dname;
       char *path = "/etc/passwd";

       dirc = strdup(path);
       basec = strdup(path);
       dname = dirname(dirc);
       bname = basename(basec);
       printf("dirname=%s, basename=%s\n", dname, bname);
       free(dirc);
       free(basec);

 (RETURN VALUE)
       dirname basename    null    .

BUGS

        glibc    ,  () 2.2.1, dirname     '/'    .    NULL ,     (segmentation
       violation).

 (CONFORMING TO)
       SUSv2

 (SEE ALSO)
       dirname(1), basename(1)

[]

        <xuming@users.sourceforge.net>

[]

       2003/05/13

Linuxman

       http://cmpp.linuxforum.net