mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Check errors in is_dir() is_regular_file()
In case of error print the error. And return right value. Improvement based on @pasis advice in https://github.com/profanity-im/profanity/pull/1036 Applying in preparation to merge that PR.
This commit is contained in:
parent
5c77b97c35
commit
c135f989ec
12
src/common.c
12
src/common.c
@ -443,7 +443,11 @@ int
|
||||
is_regular_file(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
stat(path, &st);
|
||||
int ret = stat(path, &st);
|
||||
if (ret != 0) {
|
||||
perror(NULL);
|
||||
return 0;
|
||||
}
|
||||
return S_ISREG(st.st_mode);
|
||||
}
|
||||
|
||||
@ -451,7 +455,11 @@ int
|
||||
is_dir(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
stat(path, &st);
|
||||
int ret = stat(path, &st);
|
||||
if (ret != 0) {
|
||||
perror(NULL);
|
||||
return 0;
|
||||
}
|
||||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user