Work with files / Basic operations

#include <string>
#include <fstream>
#include <sys/stat.h>
using namespace std;

string filePath = "C:\\tmp\\file.txt";

struct stat t_stat;
stat(filePath.c_str(), &t_stat);

//file size (the first method)
int fileSize1 = t_stat.st_size;

//file size (the second method)
ifstream in(filePath,
    ifstream::ate | ifstream::binary);
int fileSize2 = in.tellg();

//file modification time
time_t timeChanges = t_stat.st_mtime;

//file creation time
time_t creationTime = t_stat.st_ctime;

// is readable file
ifstream infile(filePath);
bool isReadable = infile.good();

int pos = filePath.find_last_of(".");
//file extension
string extension = "";
if (pos > 0) {
    extension = filePath.substr(pos + 1);
}

pos = filePath.find_last_of("\\/");
//file directory
string fileDir = "";
if (pos > 0) {
    fileDir = filePath.substr(0, pos);
}