Skip to content

Commit 6cdb588

Browse files
authored
Merge pull request #599 from mfncooper/fix_598
Always try home directory if current directory fails
2 parents a9d2e7b + 55129c0 commit 6cdb588

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/config.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -975,26 +975,27 @@ void config_init (char *fname, struct audio_s *p_audio_config,
975975
if (realpath (fname, absfilepath) != NULL) {
976976
#endif
977977
fp = fopen (absfilepath, "r");
978-
if (fp == NULL) { // Failed. Next, try home dir
979-
strlcpy (absfilepath, "", sizeof(absfilepath));
978+
}
979+
980+
if (fp == NULL) { // Failed. Next, try home dir
981+
strlcpy (absfilepath, "", sizeof(absfilepath));
980982
#ifdef __WIN32__
981-
char *h = getenv("USERPROFILE");
982-
if (h != NULL && fname[0] != '\\' && fname[1] != ':') {
983-
strlcat (absfilepath, h, sizeof(absfilepath));
984-
strlcat (absfilepath, "\\", sizeof(absfilepath));
985-
}
983+
char *h = getenv("USERPROFILE");
984+
if (h != NULL && fname[0] != '\\' && fname[1] != ':') {
985+
strlcat (absfilepath, h, sizeof(absfilepath));
986+
strlcat (absfilepath, "\\", sizeof(absfilepath));
987+
}
986988
#else
987-
// Don't prepend home dir if absolute path given.
988-
char *h = getenv("HOME");
989-
if (h != NULL && fname[0] != '/') {
990-
strlcat (absfilepath, h, sizeof(absfilepath));
991-
strlcat (absfilepath, "/", sizeof(absfilepath));
992-
}
989+
// Don't prepend home dir if absolute path given.
990+
char *h = getenv("HOME");
991+
if (h != NULL && fname[0] != '/') {
992+
strlcat (absfilepath, h, sizeof(absfilepath));
993+
strlcat (absfilepath, "/", sizeof(absfilepath));
994+
}
993995
#endif
994996
strlcat (absfilepath, fname, sizeof(absfilepath));
995997

996-
fp = fopen (absfilepath, "r");
997-
}
998+
fp = fopen (absfilepath, "r");
998999
}
9991000

10001001
if (fp == NULL) {

0 commit comments

Comments
 (0)