oracular (3) basename.3.gz

Provided by: manpages-es-dev_4.23.1-1_all bug

NOMBRE

       basename, dirname - analiza los componentes de un nombre de ruta

BIBLIOTECA

       Biblioteca Estándar C (libc, -lc)

SINOPSIS

       #include <libgen.h>

       char *dirname(char *ruta);
       char *basename(char *ruta);

DESCRIPCIÓN

       Atención: existen 2 funciones basename() diferentes; vea más adelante.

       The  functions  dirname()   and  basename()   break  a null-terminated pathname string into directory and
       filename components.  In the usual case, dirname()  returns the string up  to,  but  not  including,  the
       final  '/',  and  basename()  returns the component following the final '/'.  Trailing '/' characters are
       not counted as part of the pathname.

       Si path no contiene una barra, dirname() devuelve la cadena "."  mientras  que  basename()  devuelve  una
       copia  de path. Si path es la cadena "/", entonces tanto dirname() como basename devuelven la cadena "/".
       Si path es un puntero a null o apunta a una  cadena  vacía,  entonces  tanto  dirname()  como  basename()
       devuelven la cadena ".".

       Concatenando  la  cadena  devuelta por dirname(), un carácter "/", y la cadena devuelta por basename() se
       obtiene el nombre de ruta completo.

       Both dirname()  and basename()  may modify the contents of path, so it may be desirable to  pass  a  copy
       when calling one of these functions.

       These functions may return pointers to statically allocated memory which may be overwritten by subsequent
       calls.  Alternatively, they may return a pointer to some part of path, so that the string referred to  by
       path should not be modified or freed until the pointer returned by the function is no longer required.

       La  siguiente  lista  de  ejemplos  (extraídos  de  SUSv2)  muestra las cadenas devueltas por dirname() y
       basename() para diferentes rutas:

              ruta       dirname   basename
              /usr/lib   /usr      lib
              /usr/      /         usr
              usr        .         usr
              /          /         /
              .          .         .
              ..         .         ..

VALOR DEVUELTO

       Tanto dirname() como basename() devuelven punteros a cadenas terminadas en null. No los envían a free(3).

ATRIBUTOS

       Para obtener una explicación de los términos usados en esta sección, véase attributes(7).

       ┌───────────────────────────────────────────────────────────────┬────────────────────┬───────────────────┐
       │InterfazAtributoValor             │
       ├───────────────────────────────────────────────────────────────┼────────────────────┼───────────────────┤
       │basename(), dirname()                                          │ Seguridad del hilo │ Multi-hilo seguro │
       └───────────────────────────────────────────────────────────────┴────────────────────┴───────────────────┘

VERSIONES

       There are two different versions of basename()  - the POSIX version described above, and the GNU version,
       which one gets after

               #define _GNU_SOURCE         /* Véase feature_test_macros(7) */
           #include <string.h>

       The GNU version never modifies its argument, and returns the empty string when path has a trailing slash,
       and in particular also when it is "/".  There is no GNU version of dirname().

       With glibc, one gets the POSIX version of basename()  when <libgen.h> is included, and  the  GNU  version
       otherwise.

ESTÁNDARES

       POSIX.1-2008.

HISTORIAL

       POSIX.1-2001.

ERRORES

       In the glibc implementation, the POSIX versions of these functions modify the path argument, and segfault
       when called with a static string such as "/usr/".

       En versiones de glibc anteriores a 2.2.1 (incluída), dirname() no gestiona correctamente los  nombres  de
       ruta con caracteres '/' al final, y provoca una violación de segmento si se le pasa un argumento NULL.

EJEMPLOS

       Este fragmento de código muestra el uso de basename() y dirname():
           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);

VÉASE TAMBIÉN

       basename(1), dirname(1)

TRADUCCIÓN

       La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars <mpi79470@alu.um.es>
       y Marcos Fouces <marcos@debian.org>

       Esta  traducción  es   documentación   libre;   lea   la   GNU   General   Public   License   Version   3
       ⟨https://www.gnu.org/licenses/gpl-3.0.html⟩  o posterior con respecto a las condiciones de copyright.  No
       existe NINGUNA RESPONSABILIDAD.

       Si encuentra algún error en la traducción de esta página  del  manual,  envíe  un  correo  electrónico  a
       ⟨debian-l10n-spanish@lists.debian.org⟩.