Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/common/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 1 kB image not shown  

Quelle  pgfnames.c

  Sprache: C
 

/*-------------------------------------------------------------------------
 *
 * pgfnames.c
 *   directory handling functions
 *
 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * IDENTIFICATION
 *   src/common/pgfnames.c
 *
 *-------------------------------------------------------------------------
 */


#ifndef FRONTEND
#include "postgres.h"
#else
#include "postgres_fe.h"
#endif

#include <dirent.h>

#ifndef FRONTEND
#define pg_log_warning(...) elog(WARNING, __VA_ARGS__)
#else
#include "common/logging.h"
#endif

/*
 * pgfnames
 *
 * return a list of the names of objects in the argument directory.  Caller
 * must call pgfnames_cleanup later to free the memory allocated by this
 * function.
 */

char   **
pgfnames(const char *path)
{
 DIR     *dir;
 struct dirent *file;
 char   **filenames;
 int   numnames = 0;
 int   fnsize = 200/* enough for many small dbs */

 dir = opendir(path);
 if (dir == NULL)
 {
  pg_log_warning("could not open directory \"%s\": %m", path);
  return NULL;
 }

 filenames = (char **) palloc(fnsize * sizeof(char *));

 while (errno = 0, (file = readdir(dir)) != NULL)
 {
  if (strcmp(file->d_name, ".") != 0 && strcmp(file->d_name, "..") != 0)
  {
   if (numnames + 1 >= fnsize)
   {
    fnsize *= 2;
    filenames = (char **) repalloc(filenames,
              fnsize * sizeof(char *));
   }
   filenames[numnames++] = pstrdup(file->d_name);
  }
 }

 if (errno)
  pg_log_warning("could not read directory \"%s\": %m", path);

 filenames[numnames] = NULL;

 if (closedir(dir))
  pg_log_warning("could not close directory \"%s\": %m", path);

 return filenames;
}


/*
 * pgfnames_cleanup
 *
 * deallocate memory used for filenames
 */

void
pgfnames_cleanup(char **filenames)
{
 char   **fn;

 for (fn = filenames; *fn; fn++)
  pfree(*fn);

 pfree(filenames);
}

Messung V0.5 in Prozent
C=96 H=84 G=90

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-08-07) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.