.\" -*- coding: UTF-8 -*- '\" t .\" Copyright (c) 2000 by Michael Kerrisk .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" Created, 14 Dec 2000 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH basename 3 "20 ​​Julio 2023" "Páginas de manual de Linux 6.05.01" .SH NOMBRE basename, dirname \- analiza los componentes de un nombre de ruta .SH BIBLIOTECA Biblioteca Estándar C (\fIlibc\fP, \fI\-lc\fP) .SH SINOPSIS .nf \fB#include \fP .PP \fBchar *dirname(char *\fP\fIruta\fP\fB);\fP \fBchar *basename(char *\fP\fIruta\fP\fB);\fP .fi .SH DESCRIPCIÓN Atención: existen 2 funciones \fBbasename\fP() diferentes; vea más adelante. .PP The functions \fBdirname\fP() and \fBbasename\fP() break a null\-terminated pathname string into directory and filename components. In the usual case, \fBdirname\fP() returns the string up to, but not including, the final \[aq]/\[aq], and \fBbasename\fP() returns the component following the final \[aq]/\[aq]. Trailing \[aq]/\[aq] characters are not counted as part of the pathname. .PP Si \fIpath\fP no contiene una barra, \fBdirname\fP() devuelve la cadena "." mientras que \fBbasename\fP() devuelve una copia de \fIpath\fP. Si \fIpath\fP es la cadena "/", entonces tanto \fBdirname\fP() como \fBbasename\fP devuelven la cadena "/". Si \fIpath\fP es un puntero a null o apunta a una cadena vacía, entonces tanto \fBdirname\fP() como \fBbasename\fP() devuelven la cadena ".". .PP Concatenando la cadena devuelta por \fBdirname\fP(), un carácter "/", y la cadena devuelta por \fBbasename\fP() se obtiene el nombre de ruta completo. .PP Both \fBdirname\fP() and \fBbasename\fP() may modify the contents of \fIpath\fP, so it may be desirable to pass a copy when calling one of these functions. .PP 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 \fIpath\fP, so that the string referred to by \fIpath\fP should not be modified or freed until the pointer returned by the function is no longer required. .PP La siguiente lista de ejemplos (extraídos de SUSv2) muestra las cadenas devueltas por \fBdirname\fP() y \fBbasename\fP() para diferentes rutas: .RS .TS lb lb lb l l l l. ruta dirname basename /usr/lib /usr lib /usr/ / usr usr . usr / / / \&. . . \&.. . .. .TE .RE .SH "VALOR DEVUELTO" Tanto \fBdirname\fP() como \fBbasename\fP() devuelven punteros a cadenas terminadas en null. No los envían a \fBfree\fP(3). .SH ATRIBUTOS Para obtener una explicación de los términos usados en esta sección, véase \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. Interfaz Atributo Valor T{ .na .nh \fBbasename\fP(), \fBdirname\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .sp 1 .SH VERSIONES There are two different versions of \fBbasename\fP() \- the POSIX version described above, and the GNU version, which one gets after .PP .in +4n .EX \fB #define _GNU_SOURCE\fP /* Véase feature_test_macros(7) */ \fB#include \fP .EE .in .PP The GNU version never modifies its argument, and returns the empty string when \fIpath\fP has a trailing slash, and in particular also when it is "/". There is no GNU version of \fBdirname\fP(). .PP With glibc, one gets the POSIX version of \fBbasename\fP() when \fI\fP is included, and the GNU version otherwise. .SH ESTÁNDARES POSIX.1\-2008. .SH HISTORIAL POSIX.1\-2001. .SH ERRORES In the glibc implementation, the POSIX versions of these functions modify the \fIpath\fP argument, and segfault when called with a static string such as "/usr/". .PP En versiones de glibc anteriores a 2.2.1 (incluída), \fBdirname\fP() 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. .SH EJEMPLOS Este fragmento de código muestra el uso de \fBbasename\fP() y \fBdirname\fP(): .in +4n .EX 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\en", dname, bname); .EE .in .SH "VÉASE TAMBIÉN" \fBbasename\fP(1), \fBdirname\fP(1) .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .