Re: Remove sort files

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Ian Lance Taylor <ian(at)airs(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Remove sort files
Date: 2001-05-24 01:14:32
Message-ID: 200105240114.f4O1EWl05501@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>
> > + if (temp_de->d_type == DT_REG)
>
> The d_type field, and the corresponding macros such as DT_REG, are not
> portable.
>
> The only portable field in the dirent structure is d_name.
>
> If you want to be really really super portable, you have to think
> about supporting direct.h and other header files. See AC_DIR_HEADER
> and AC_HEADER_DIRENT in the autoconf documentation. But these days
> probably every OS of interest supports dirent.h, which is defined by
> POSIX.

Seems Vadim already added readdir() that does similar work for WAL
files in xlog.c:

while ((xlde = readdir(xldir)) != NULL)
{
if (strlen(xlde->d_name) == 16 &&
strspn(xlde->d_name, "0123456789ABCDEF") == 16 &&
strcmp(xlde->d_name, lastoff) <= 0)
{
elog(LOG, "MoveOfflineLogs: %s %s", (XLOG_archive_dir[0]) ?
"archive" : "remove", xlde->d_name);
sprintf(path, "%s%c%s", XLogDir, SEP_CHAR, xlde->d_name);
if (XLOG_archive_dir[0] == 0)
unlink(path);
}
errno = 0;
}

I will remove the _REG test and add the strspn test he has:

if (strspn(temp_de->d_name, "0123456789.") ==
strlen(temp_de->dname))

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2001-05-24 08:35:12 Re: Remove sort files
Previous Message Ian Lance Taylor 2001-05-24 00:46:43 Re: Remove sort files