I have some code intending to get the file size of a PNG image (from a different stack overflow post).
#include <fstream>
#include <cstring>
#include <cstddef>
#include <filesystem>
const char* INPUT_FILENAME = "test.png";
using namespace std;
int main()
{
std::ifstream file;
size_t size = 0;
std::cout << "Attempting to open " << INPUT_FILENAME << std::endl;
file.open( INPUT_FILENAME, std::ios::in | std::ios::ate );
char* data = 0;
file.seekg( 0, std::ios::end );
// size = file.tellg();
size = std::filesystem::file_size(INPUT_FILENAME);
std::cout << "File size: " << size << std::endl;
file.seekg( 0, std::ios::beg );
data = new char[ size - 8 + 1 ];
file.seekg( 8 ); // skip the header
file.read( data, size );
data[ size ] = '\0';
std::cout << "Data size: " << std::strlen( data ) << std::endl;
}
Upon running I get the error `no member named 'filesystem' in namespace 'std'; did you mean 'std::__fs::filesystem'. Even attempting to use the latter function results in errors of its own. I need help figuring if this is an issue with not having all the correct packages installed, or possibly my IDE settings? I should note I am running on a MacBook OS 11.2.3 and QtCreator 5.14.2.