Skip to content

Commit

Permalink
use opendir to check if a directory exists when setting music library…
Browse files Browse the repository at this point in the history
… path. Closes #215.
  • Loading branch information
ravachol committed Jan 20, 2025
1 parent 0bea996 commit 6deb557
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/kew.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,17 +1348,13 @@ void exitIfAlreadyRunning()

int directoryExists(const char *path)
{
struct stat info;
if (stat(path, &info) != 0)
{
return 0;
}
else if (S_ISDIR(info.st_mode))
{
return 1;
}
DIR *dir = opendir(path);
if (dir != NULL) {
closedir(dir);
return 1;
}

return 0;
return 0;
}

void clearInputBuffer()
Expand Down Expand Up @@ -1449,7 +1445,7 @@ void setMusicPath()
}
else
{
printf("The entered path does not exist.\n");
printf("The entered path does not exist or is inaccessible.\n");
exit(1);
}
}
Expand Down

0 comments on commit 6deb557

Please sign in to comment.