27#ifndef EASY3D_UTIL_FILE_SYSTEM_H
28#define EASY3D_UTIL_FILE_SYSTEM_H
46 namespace file_system {
111 void get_files(
const std::string& path, std::vector<std::string>& files,
bool recursive);
160 bool rename_file(
const std::string& old_name,
const std::string& new_name);
181 std::ifstream::pos_type
file_size(
const std::string& path);
197 std::string
extension(
const std::string& path,
bool lower =
true) ;
315 bool copy_file(
const std::string& original,
const std::string& copy);
bool delete_directory(const std::string &path)
Deletes the directory 'path' (and its contents will be deleted recursively).
void get_sub_directories(const std::string &path, std::vector< std::string > &subs, bool recursive)
Query subdirectory entries of a directory 'path'.
bool create_directory(const std::string &path)
Creates a directory entitled 'path'.
time_t time_stamp(const std::string &path)
Query the time stamp of a file or directory.
void get_files(const std::string &path, std::vector< std::string > &files, bool recursive)
Queries file entries of a directory 'path'.
std::string name_less_extension(const std::string &path)
Gets file path without last extension (e.g., /a/b/c.Ext => /a/b/c; file.ext1.ext2 => file....
bool is_native_style(const std::string &path)
Checks sif the path contains only the current platform's path separators.
std::string home_directory()
Query the home path for the current user.
std::string executable()
Query the name of this executable.
char native_path_separator()
Gets the path separator of the current platform.
std::string parent_directory(const std::string &path)
Query the parent path from full name of a file or directory (e.g., /a/b/c.Ext => /a/b)
std::string name_less_all_extensions(const std::string &path)
Gets file path without all extensions (e.g., /a/b/c.Ext => /a/b/c; file.ext1.ext2 => file).
bool delete_contents(const std::string &path)
Deletes the contents of the directory 'path' (the directory will not be deleted).
std::string convert_to_native_style(const std::string &path)
Convert a path string such that it uses the current platform's path separators.
void write_string_to_file(const std::string &str, const std::string &filename)
Writes the string into a file.
bool set_current_working_directory(const std::string &path)
Set the current working directory.
std::string simple_name(const std::string &path)
Gets file name without path but with extension (e.g, /a/b/c.Ext => c.Ext)
bool is_directory(const std::string &path)
Tests if 'path' is an existing directory.
std::ifstream::pos_type file_size(const std::string &path)
Query the size of the file.
bool is_file(const std::string &path)
Tests if 'path' is an existing file.
std::string replace_extension(std::string const &path, const std::string &ext)
Replaces the extension of the given file with 'ext'. If the file name does not have an extension,...
bool delete_file(const std::string &path)
Deletes the file 'path'.
std::string time_string(const std::string &path)
Query the time stamp of a file or directory as a string.
bool copy_file(const std::string &original, const std::string ©)
Makes a copy of an existing file.
std::string convert_to_windows_style(const std::string &path)
Converts the path to Windows style, i.e., forward slashes (/) to back slashes (\).
std::string extension(const std::string &path, bool lower=true)
Query the file extension without dot (e.g., /a/b/c.Ext => Ext).
bool is_absolute_path(const std::string &path)
Tests if path is absolute, as !get_path_root(path).empty(). .
std::string absolute_path(const std::string &path)
Converts to absolute path (i.e., removes .. and . from a path string).
std::string relative_path(const std::string &from, const std::string &to)
Compute the relative path from 'from' to 'to'.
std::string convert_to_unix_style(const std::string &path)
Converts the path to Unix style, i.e., back slashes (\) to forward slashes (/).
void get_directory_entries(const std::string &path, std::vector< std::string > &entries, bool recursive)
Queries the entries of a directory (including subdirectories and files).
std::string executable_directory()
Query the directory where the executable file is located.
void read_file_to_string(const std::string &filename, std::string &str)
Reads the contents of a file into a string.
bool file_contains_string(const std::string &filename, const std::string &str)
Checks if a file contains string 'str'.
std::string current_working_directory()
Query the current working directory.
std::string path_root(const std::string &path)
Gets root part of a path ("/" or "C:"), or an empty string if none found.
std::string base_name(const std::string &path)
Gets file name without path and last extension (e.g., c:/file.ext1.ext2 => file.ext1; /a/b/c....
bool rename_file(const std::string &old_name, const std::string &new_name)
Rename the file from 'old_name' to 'new_name'.
Definition: collider.cpp:182