.\" -*- coding: UTF-8 -*- .\" Copyright (c) 2000 by Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Created, 14 Dec 2000 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH BASENAME 3 "9 Junio 2020" GNU "Manual del Programador de Linux" .SH NOMBRE basename, dirname \- analiza los componentes de un nombre de ruta .SH SINOPSIS .nf \fB#include \fP .PP \fBchar *dirname(char *\fP\fIpath\fP\fB);\fP .PP \fBchar *basename(char *\fP\fIpath\fP\fB);\fP .fi .SH DESCRIPCIÓN Warning: there are two different functions \fBbasename\fP() \- see below. .PP Las funciones \fBdirname\fP() y \fBbasename\fP() descomponen un nombre de ruta terminado en null en un directorio y un nombre de fichero. En el caso habitual, \fBdirname\fP() devuelve la cadena que precede, pero no incluye, al último carácter \(aq/\(aq, y \fBbasename\fP() devuelve el componente que sigue al último carácter \(aq/\(aq. Los carácteres \(aq/\(aq del final no se cuentan como parte del nombre de ruta. .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; lbw21 lb lb l l l. Interfaz Atributo Valor T{ \fBbasename\fP(), \fBdirname\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .SH "CONFORME A" POSIX.1\-2001, POSIX.1\-2008. .SH NOTAS 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 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 Before glibc 2.2.1, the glibc version of \fBdirname\fP() did not correctly handle pathnames with trailing \(aq/\(aq characters, and generated a segfault if given a NULL argument. .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) .SH COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .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 .