MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
Namespaces | Macros | Functions | Variables
file_system.cc File Reference
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <cctype>
#include <cerrno>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include "util/exception.h"
#include "util/system.h"
#include "util/file_system.h"
Include dependency graph for file_system.cc:

Go to the source code of this file.

Namespaces

namespace  util
 Parser, tokenizer, timer, smart pointer, threads, etc.
 
namespace  util::fs
 Cross-platform file system functions.
 

Macros

#define PATH_MAX   2048
 

Functions

std::string util::fs::abspath (std::string const &path)
 Returns the absolute representation of the given path.
 
std::string util::fs::basename (std::string const &path)
 Returns the file name component of the given path.
 
void util::fs::copy_file (char const *src, char const *dst)
 Copies a file from 'src' to 'dst', throws FileException on error.
 
bool util::fs::dir_exists (char const *pathname)
 Determines if the given path is a directory.
 
std::string util::fs::dirname (std::string const &path)
 Returns the directory name component of the given path.
 
bool util::fs::exists (char const *pathname)
 Determines if the given path is a directory.
 
bool util::fs::file_exists (char const *pathname)
 Determines if the given path is a file.
 
char const * util::fs::get_app_data_dir (void)
 Determines the current user's path for application data.
 
std::string util::fs::get_binary_path (void)
 Returns the path of the binary currently executing.
 
char * util::fs::get_cwd (char *buf, size_t size)
 
std::string util::fs::get_cwd_string (void)
 Determines the CWD and returns a convenient string.
 
char const * util::fs::get_home_dir (void)
 Determines the home path for the current user.
 
bool util::fs::is_absolute (std::string const &path)
 Checks whether the given path is absolute.
 
std::string util::fs::join_path (std::string const &path1, std::string const &path2)
 Concatenate and canonicalize two paths.
 
bool util::fs::mkdir (char const *pathname)
 Creates a new directory.
 
void util::fs::read_file_to_string (std::string const &filename, std::string *data)
 Reads the whole file into a string.
 
bool util::fs::rename (char const *from, char const *to)
 Renames the given file 'from' to new name 'to'.
 
std::string util::fs::replace_extension (std::string const &fn, std::string const &ext)
 Replaces extension of the given file with 'ext'.
 
bool util::fs::rmdir (char const *pathname)
 Removes an empty directory.
 
std::string util::fs::sanitize_path (std::string const &path)
 Canonicalize slashes in the given path.
 
bool util::fs::set_cwd (char const *pathname)
 Changes the current working directory to 'pathname' and returns true on success.
 
bool util::fs::unlink (char const *pathname)
 Unlinks (deletes) the given file.
 
void util::fs::write_string_to_file (char const *data, std::size_t len, std::string const &filename)
 Writes the given data into a file.
 
void util::fs::write_string_to_file (std::string const &data, std::string const &filename)
 Writes the given data into a file.
 

Variables

char util::fs::app_data_path [2048] = { 0 }
 
char util::fs::home_path [2048] = { 0 }
 

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   2048

Definition at line 38 of file file_system.cc.