Skip to content

Commit 1bc861f

Browse files
committed
[Issue #174] Remove old pgFileGetCRC
1 parent 0723eef commit 1bc861f

File tree

1 file changed

+0
-59
lines changed

1 file changed

+0
-59
lines changed

src/dir.c

-59
Original file line numberDiff line numberDiff line change
@@ -381,65 +381,6 @@ pgFileGetCRCgz(const char *file_path, bool use_crc32c, bool missing_ok)
381381
return crc;
382382
}
383383

384-
/*
385-
* Read the file to compute its CRC.
386-
* As a handy side effect, we return filesize via bytes_read parameter.
387-
*/
388-
pg_crc32
389-
pgFileGetCRC(const char *file_path, bool use_crc32c, bool raise_on_deleted,
390-
size_t *bytes_read, fio_location location)
391-
{
392-
FILE *fp;
393-
pg_crc32 crc = 0;
394-
char buf[STDIO_BUFSIZE];
395-
size_t len = 0;
396-
size_t total = 0;
397-
int errno_tmp;
398-
399-
INIT_FILE_CRC32(use_crc32c, crc);
400-
401-
/* open file in binary read mode */
402-
fp = fio_fopen(file_path, PG_BINARY_R, location);
403-
if (fp == NULL)
404-
{
405-
if (!raise_on_deleted && errno == ENOENT)
406-
{
407-
FIN_FILE_CRC32(use_crc32c, crc);
408-
return crc;
409-
}
410-
else
411-
elog(ERROR, "cannot open file \"%s\": %s",
412-
file_path, strerror(errno));
413-
}
414-
415-
/* calc CRC of file */
416-
for (;;)
417-
{
418-
if (interrupted)
419-
elog(ERROR, "interrupted during CRC calculation");
420-
421-
len = fio_fread(fp, buf, sizeof(buf));
422-
if (len == 0)
423-
break;
424-
/* update CRC */
425-
COMP_FILE_CRC32(use_crc32c, crc, buf, len);
426-
total += len;
427-
}
428-
429-
if (bytes_read)
430-
*bytes_read = total;
431-
432-
errno_tmp = errno;
433-
if (len < 0)
434-
elog(WARNING, "cannot read \"%s\": %s", file_path,
435-
strerror(errno_tmp));
436-
437-
FIN_FILE_CRC32(use_crc32c, crc);
438-
fio_fclose(fp);
439-
440-
return crc;
441-
}
442-
443384
void
444385
pgFileFree(void *file)
445386
{

0 commit comments

Comments
 (0)