.\" -*- coding: UTF-8 -*- .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%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 .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:26:16 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Thu Apr 11 17:11:33 1996 by Andries Brouwer (aeb@cwi.nl): .\" Corrected type of compar routines, as suggested by .\" Miguel Barreiro (enano@avalon.yaix.es). Added example. .\" Modified Sun Sep 24 20:15:46 2000 by aeb, following Petter Reinholdtsen. .\" Modified 2001-12-26 by aeb, following Joey. Added versionsort. .\" .\" The pieces on scandirat(3) were copyright and licensed as follows. .\" .\" Copyright (c) 2012, Mark R. Bannister .\" based on text in mkfifoat.3 Copyright (c) 2006, Michael Kerrisk .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH SCANDIR 3 "9. Juni 2020" GNU Linux\-Programmierhandbuch .SH BEZEICHNUNG scandir, scandirat, alphasort, versionsort \- durchsucht ein Verzeichnis nach passenden Einträgen .SH ÜBERSICHT .nf \fB#include \fP .PP \fBint scandir(const char *\fP\fIVerzz\fP\fB, struct dirent ***\fP\fInamelist\fP\fB,\fP .RS \fBint (*\fP\fIfilter\fP\fB)(const struct dirent *),\fP \fBint (*\fP\fIvergl\fP\fB)(const struct dirent **, const struct dirent **));\fP .RE .PP \fBint alphasort(const struct dirent **\fP\fIa\fP\fB, const struct dirent **\fP\fIb\fP\fB);\fP .PP \fBint versionsort(const struct dirent **\fP\fIa\fP\fB, const struct dirent **\fP\fIb\fP\fB);\fP \fB#include \fP /* Definition von AT_*\-Konstanten */ \fB#include \fP .PP \fBint scandirat(int \fP\fIVerzdd\fP\fB, const char *\fP\fIVerzz\fP\fB,\fP \fBstruct dirent ***\fP\fInamelist\fP\fB,\fP .RS \fBint (*\fP\fIfilter\fP\fB)(const struct dirent *),\fP \fBint (*\fP\fIvergl\fP\fB)(const struct dirent **, const struct dirent **));\fP .RE .fi .PP .RS -4 Mit Glibc erforderliche Feature\-Test\-Makros (siehe \fBfeature_test_macros\fP(7)): .RE .PP \fBscandir\fP(), \fBalphasort\fP(): .br .RS 4 .PD 0 .ad b /* Seit Glibc 2.10: */ _POSIX_C_SOURCE\ >=\ 200809L || /* Glibc\-Versionen <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE .PD .RE .PP \fBversionsort\fP(): _GNU_SOURCE .PP \fBscandirat\fP(): _GNU_SOURCE .SH BESCHREIBUNG Die Funktion \fBscandir\fP() durchsucht das Verzeichnis \fIVerzz\fP und ruft für jeden Verzeichniseintrag \fBfilter\fP() auf. Einträge, für die \fBfilter()\fP einen Wert ungleich 0 zurückgibt, werden in Zeichenketten gespeichert, derenSpeicher mit \fBmalloc\fP(3) reserviert wird. Danach werden die Zeichenkettenmit \fBqsort\fP(3) unter Verwendung der Vergleichsfunktion \fBvergl\fP() sortiert und im Feld \fInamelist\fP gesammelt, dessen Speicher ebenfalls mit \fBmalloc\fP(3) reserviert wird. Falls \fIfilter\fP gleich NULL ist, werden alle Einträge ausgewählt. .PP Die Funktionen \fBalphasort\fP() und \fBversionsort\fP() können als die Vergleichsfunktion \fIvergl\fP() benutzt werden. Die erste sortiert die Verzeichniseinträge mittels \fBstrcoll\fP(3), die letztere \fBstrverscmp\fP(3) auf den Zeichenketten \fI(*a)\->d_name\fP und \fI(*b)\->d_name\fP. .SS scandirat() Die Funktion \fBscandirat\fP() funktioniert genauso wie \fBscandir\fP(), abgesehen von den hier beschriebenen Unterschieden. .PP Falls der in \fIVerzz\fP angegebene Pfadname relativ ist, wird er relativ zu dem Verzeichnis interpretiert, auf das sich der Dateideskriptor \fIVerzdd\fP bezieht (statt relativ zum aktuellen Arbeitsverzeichnis des aufrufenden Prozesses, so wie \fBscandir\fP() einen relativen Pfadnamen behandeln würde). .PP Falls \fIVerzz\fP relativ ist und \fIVerzdd\fP den besonderen Wert \fBAT_FDCWD\fP annimmt, wird \fIVerzz\fP als relativ zum aktuellen Arbeitsverzeichnis des aufrufenden Prozesses interpretiert (wie von \fBscandir\fP()). .PP Falls \fIVerzz\fP absolut ist, wird \fIVerzdd\fP ignoriert. .PP Lesen Sie \fBopenat\fP(2) für die Erklärung der Notwendigkeit von \fBscandirat\fP(). .SH RÜCKGABEWERT Die Funktion \fBscandir\fP() liefert die Anzahl ausgewählter Verzeichniseinträge oder im Fehlerfall \-1 zurück, wobei \fIerrno\fP gesetzt wird, um die Ursache des Fehlers anzuzeigen. .PP Die Funktionen \fBalphasort\fP() und \fBversionsort\fP() liefern eine Zahl kleiner als Null, Null, oder größer als Null zurück, wenn das erste Argument entsprechend als kleiner, gleich oder größer als das zweite Argument angesehen wird. .SH FEHLER .TP \fBENOENT\fP Der Pfad in \fIVerzz\fP existiert nicht. .TP \fBENOMEM\fP Der Speicher reicht nicht aus, um den Vorgang zu beenden. .TP \fBENOTDIR\fP Der Pfad in \fIVerzz\fP ist kein Verzeichnis. .PP Für \fBscandirat\fP() können die folgenden zusätzlichen Fehler auftreten: .TP \fBEBADF\fP \fIVerzdd\fP ist kein zulässiger Dateideskriptor. .TP \fBENOTDIR\fP \fIVerzz\fP ist ein relativer Pfad und \fIVerzdd\fP ist ein Dateideskriptor, der sich auf eine Datei bezieht, die kein Verzeichnis ist. .SH VERSIONEN \fBversionsort\fP() wurde der Glibc in Version 2.1 hinzugefügt. .PP \fBscandirat\fP() wurde der Glibc in Version 2.15 hinzugefügt. .SH ATTRIBUTE Siehe \fBattributes\fP(7) für eine Erläuterung der in diesem Abschnitt verwandten Ausdrücke. .TS allbox; lbw26 lb lb l l l. Schnittstelle Attribut Wert T{ \fBscandir\fP(), \fBscandirat\fP() T} Multithread\-Fähigkeit MT\-Safe T{ \fBalphasort\fP(), \fBversionsort\fP() T} Multithread\-Fähigkeit MT\-Safe locale .TE .sp 1 .SH "KONFORM ZU" \fBalphasort\fP(), \fBscandir\fP(): 4.3BSD, POSIX.1\-2008. .PP .\" .LP .\" The functions .\" .BR scandir () .\" and .\" .BR alphasort () .\" are from 4.3BSD, and have been available under Linux since libc4. .\" Libc4 and libc5 use the more precise prototype .\" .sp .\" .nf .\" int alphasort(const struct dirent ** a, .\" const struct dirent **b); .\" .fi .\" .sp .\" but glibc 2.0 returns to the imprecise BSD prototype. \fBversionsort\fP() und \fBscandirat\fP() sind GNU\-Erweiterungen. .SH ANMERKUNGEN Seit Glibc 2.1 verwendet \fBalphasort\fP() \fBstrcoll\fP(3); früher nutzte sie \fBstrcmp\fP(3). .PP Vor Glibc 2.10 hatten die zwei Argumente von \fBalphasort\fP() und \fBversionsort\fP() den Typ \fIconst void\ *\fP. Als \fBalphasort\fP() in POSIX.1\-2008 standardisiert wurde, wurde der Argumententyp als typsicherer \fIconst struct dirent\ **\fP spezifiziert und Glibc 2.10 änderte die Definitionen von \fBalphasort\fP() (und dem nicht standardisierten \fBversionsort\fP()), um auf den Standard zu passen. .SH BEISPIELE .\" Das nachfolgende Programm gibt eine Liste von Dateien im aktuellen Verzeichnis in umgekehrter Reihenfolge aus. .SS Programmquelltext \& .EX #define _DEFAULT_SOURCE #include #include #include int main(void) { struct dirent **Namensliste; int n; n = scandir(".", &Namensliste, NULL, alphasort); if (n == \-1) { perror("scandir"); exit(EXIT_FAILURE); } while (n\-\-) { printf("%s\en", Namensliste[n]\->d_name); free(Namensliste[n]); } free(Namensliste); exit(EXIT_SUCCESS); } .EE .SH "SIEHE AUCH" \fBclosedir\fP(3), \fBfnmatch\fP(3), \fBopendir\fP(3), \fBreaddir\fP(3), \fBrewinddir\fP(3), \fBseekdir\fP(3), \fBstrcmp\fP(3), \fBstrcoll\fP(3), \fBstrverscmp\fP(3), \fBtelldir\fP(3) .SH KOLOPHON Diese Seite ist Teil der Veröffentlichung 5.10 des Projekts Linux\-\fIman\-pages\fP. Eine Beschreibung des Projekts, Informationen, wie Fehler gemeldet werden können, sowie die aktuelle Version dieser Seite finden sich unter \%https://www.kernel.org/doc/man\-pages/. .PP .SH ÜBERSETZUNG Die deutsche Übersetzung dieser Handbuchseite wurde von Markus Kaufmann , Martin Eberhard Schauer , Mario Blättermann und Helge Kreutzmann erstellt. .PP Diese Übersetzung ist Freie Dokumentation; lesen Sie die .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE oder neuer bezüglich der Copyright-Bedingungen. Es wird KEINE HAFTUNG übernommen. .PP Wenn Sie Fehler in der Übersetzung dieser Handbuchseite finden, schicken Sie bitte eine E-Mail an die .MT debian-l10n-german@lists.debian.org Mailingliste der Übersetzer .ME .