1
0
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:
Jfreegman
2014-08-27 22:45:11 -04:00
parent 155e194174
commit 511907fbc5
4 changed files with 22 additions and 18 deletions

View File

@ -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;
}