23#ifndef VCL_IO_FILE_INFO_H
24#define VCL_IO_FILE_INFO_H
26#include "file_format.h"
28#include <vclib/io/exceptions.h>
30#include <vclib/base.h>
41 std::string mFilename;
48 bool exists()
const {
return exists(mFilename); }
50 std::size_t fileSize()
const {
return fileSize(mFilename); }
52 bool isFileBinary()
const {
return isFileBinary(mFilename); }
66 return std::filesystem::exists(
filename);
77 std::ifstream
file(
filename, std::ios::binary | std::ios::ate);
96 std::ifstream
file(
filename, std::ios::binary | std::ios::ate);
99 file.seekg(0, std::ios::beg);
101 std::vector<unsigned char> buffer(size);
102 if (
file.read((
char*) buffer.data(), size)) {
294 const std::string&
ext)
A class representing a box in N-dimensional space.
Definition box.h:46
PointT size() const
Computes the size of the box.
Definition box.h:267
Definition file_info.h:40
static std::size_t fileSize(const std::string &filename)
Get the size of a file.
Definition file_info.h:75
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:292
static std::string fileNameWithExtension(const std::string &fullpath)
Get the filename with extension of a file.
Definition file_info.h:240
static std::string fileNameWithoutExtension(const std::string &fullpath)
Get the file name without extension of a file.
Definition file_info.h:220
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:172
static bool exists(const std::string &filename)
Check if a file exists.
Definition file_info.h:64
static std::string extension(const std::string &filename)
Get the extension of a file.
Definition file_info.h:260
static bool isFileBinary(const std::string &filename)
Check if a file is binary.
Definition file_info.h:92
static FileFormat fileFormat(const std::string &filename)
Get the file format of a file from its filename.
Definition file_info.h:280
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:137
static std::string pathWithoutFileName(const std::string &fullpath)
Get the path of a file.
Definition file_info.h:200