Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1ee26f9

Browse filesBrowse files
author
Nikolay Zakharov
committed
Fix bug: terminate program if file is not exists (#839)
1 parent 41f5baa commit 1ee26f9
Copy full SHA for 1ee26f9

File tree

1 file changed

+22
-11
lines changed
Filter options

1 file changed

+22
-11
lines changed

‎src/utils/file.c

Copy file name to clipboardExpand all lines: src/utils/file.c
+22-11Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,24 +1159,35 @@ fio_stat(char const* path, struct stat* st, bool follow_symlink, fio_location lo
11591159
bool
11601160
fio_is_same_file(char const* filename1, char const* filename2, bool follow_symlink, fio_location location)
11611161
{
1162+
char *abs_name1 = make_absolute_path(filename1);
1163+
char *abs_name2 = make_absolute_path(filename2);
1164+
bool result = strcmp(abs_name1, abs_name2) == 0;
1165+
11621166
#ifndef WIN32
1163-
struct stat stat1, stat2;
1167+
if (!result)
1168+
{
1169+
struct stat stat1, stat2;
11641170

1165-
if (fio_stat(filename1, &stat1, follow_symlink, location) < 0)
1166-
elog(ERROR, "Can't stat file \"%s\": %s", filename1, strerror(errno));
1171+
if (fio_stat(filename1, &stat1, follow_symlink, location) < 0)
1172+
{
1173+
if (errno == ENOENT)
1174+
return false;
1175+
elog(ERROR, "Can't stat file \"%s\": %s", filename1, strerror(errno));
1176+
}
11671177

1168-
if (fio_stat(filename2, &stat2, follow_symlink, location) < 0)
1169-
elog(ERROR, "Can't stat file \"%s\": %s", filename2, strerror(errno));
1178+
if (fio_stat(filename2, &stat2, follow_symlink, location) < 0)
1179+
{
1180+
if (errno == ENOENT)
1181+
return false;
1182+
elog(ERROR, "Can't stat file \"%s\": %s", filename2, strerror(errno));
1183+
}
11701184

1171-
return stat1.st_ino == stat2.st_ino && stat1.st_dev == stat2.st_dev;
1172-
#else
1173-
char *abs_name1 = make_absolute_path(filename1);
1174-
char *abs_name2 = make_absolute_path(filename2);
1175-
bool result = strcmp(abs_name1, abs_name2) == 0;
1185+
result = (stat1.st_ino == stat2.st_ino && stat1.st_dev == stat2.st_dev);
1186+
}
1187+
#endif
11761188
free(abs_name2);
11771189
free(abs_name1);
11781190
return result;
1179-
#endif
11801191
}
11811192

11821193
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.