Skip to content

Commit 1f7d26f

Browse files
committed
[refactor] remove pgut_fopen()
1 parent a454bd7 commit 1f7d26f

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

src/utils/configuration.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,14 @@ config_read_opt(const char *path, ConfigOption options[], int elevel,
555555
if (!options)
556556
return parsed_options;
557557

558-
if ((fp = pgut_fopen(path, "rt", missing_ok)) == NULL)
559-
return parsed_options;
558+
if ((fp = fio_open_stream(path, FIO_BACKUP_HOST)) == NULL)
559+
{
560+
if (missing_ok && errno == ENOENT)
561+
return parsed_options;
562+
563+
elog(ERROR, "could not open file \"%s\": %s",
564+
path, strerror(errno));
565+
}
560566

561567
while (fgets(buf, lengthof(buf), fp))
562568
{

src/utils/pgut.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ pgut_strndup(const char *str, size_t n)
980980
/*
981981
* Allocates new string, that contains part of filepath string minus trailing filename string
982982
* If trailing filename string not found, returns copy of filepath.
983-
* Result must be free by caller.
983+
* Result must be freed by caller.
984984
*/
985985
char *
986986
pgut_str_strip_trailing_filename(const char *filepath, const char *filename)
@@ -993,23 +993,6 @@ pgut_str_strip_trailing_filename(const char *filepath, const char *filename)
993993
return pgut_strndup(filepath, fp_len);
994994
}
995995

996-
FILE *
997-
pgut_fopen(const char *path, const char *mode, bool missing_ok)
998-
{
999-
FILE *fp;
1000-
1001-
if ((fp = fio_open_stream(path, FIO_BACKUP_HOST)) == NULL)
1002-
{
1003-
if (missing_ok && errno == ENOENT)
1004-
return NULL;
1005-
1006-
elog(ERROR, "could not open file \"%s\": %s",
1007-
path, strerror(errno));
1008-
}
1009-
1010-
return fp;
1011-
}
1012-
1013996
#ifdef WIN32
1014997
static int select_win32(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
1015998
#define select select_win32

src/utils/pgut.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ extern char *pgut_str_strip_trailing_filename(const char *filepath, const char *
6969
#define pgut_new0(type) ((type *) pgut_malloc0(sizeof(type)))
7070
#define pgut_newarray(type, n) ((type *) pgut_malloc(sizeof(type) * (n)))
7171

72-
/*
73-
* file operations
74-
*/
75-
extern FILE *pgut_fopen(const char *path, const char *mode, bool missing_ok);
76-
7772
/*
7873
* Assert
7974
*/

0 commit comments

Comments
 (0)