mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-30 03:56:45 +02:00
better way to check if files exist
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
@ -303,3 +304,10 @@ void bytes_convert_str(char *buf, int size, uint64_t bytes)
|
||||
|
||||
snprintf(buf, size, "%.1f %s", conv, unit);
|
||||
}
|
||||
|
||||
/* checks if a file exists. Returns true or false */
|
||||
bool file_exists(const char *fp)
|
||||
{
|
||||
struct stat s;
|
||||
return stat(fp, &s) == 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user