23#ifndef VCL_IO_FILE_INFO_H
24#define VCL_IO_FILE_INFO_H
26#include <vclib/exceptions/io.h>
27#include <vclib/types.h>
38 std::string mFilename;
45 bool exists()
const {
return exists(mFilename); }
47 std::size_t fileSize()
const {
return fileSize(mFilename); }
49 bool isFileBinary()
const {
return isFileBinary(mFilename); }
63 return std::filesystem::exists(
filename);
74 std::ifstream
file(
filename, std::ios::binary | std::ios::ate);
93 std::ifstream
file(
filename, std::ios::binary | std::ios::ate);
96 file.seekg(0, std::ios::beg);
98 std::vector<unsigned char> buffer(size);
99 if (
file.read((
char*) buffer.data(), size)) {
100 for (
uint i = 0;
i < buffer.size(); ++
i) {
273 const std::string&
ext)
Definition file_info.h:37
static std::size_t fileSize(const std::string &filename)
Get the size of a file.
Definition file_info.h:72
static std::string addExtensionIfNeeded(const std::string &filename, const std::string &ext)
Adds an extension to a file name if it doesn't already have it.
Definition file_info.h:271
static std::string fileNameWithExtension(const std::string &fullpath)
Get the filename with extension of a file.
Definition file_info.h:237
static std::string fileNameWithoutExtension(const std::string &fullpath)
Get the file name without extension of a file.
Definition file_info.h:217
static void separateFileNameFromPath(const std::string &fullpath, std::string &path, std::string &filename)
Extracts the filename (extension included) of a string that contains a fullpath.
Definition file_info.h:169
static bool exists(const std::string &filename)
Check if a file exists.
Definition file_info.h:61
static std::string extension(const std::string &filename)
Get the extension of a file.
Definition file_info.h:257
static bool isFileBinary(const std::string &filename)
Check if a file is binary.
Definition file_info.h:89
static void separateExtensionFromFileName(const std::string &fullname, std::string &rawName, std::string &extension)
Extracts the extension of a string that contains a filename.
Definition file_info.h:134
static std::string pathWithoutFileName(const std::string &fullpath)
Get the path of a file.
Definition file_info.h:197
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43