28 lines
526 B
C++
28 lines
526 B
C++
#include "../include/FileUtils.h"
|
|
#include <string>
|
|
#include <fstream>
|
|
#include <sys/stat.h>
|
|
|
|
bool FileUtils::fileExists(char *path){
|
|
struct stat s;
|
|
|
|
// Check if file exists, and if it isn't a folder.
|
|
if (stat(path, &s) == 0 && !(s.st_mode & S_IFDIR)){
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
string FileUtils::getFile(char *path){
|
|
ifstream file(path);
|
|
|
|
string line;
|
|
|
|
// There is only one line in the file
|
|
getline(file, line);
|
|
|
|
file.close();
|
|
|
|
return line;
|
|
} |