strusBase  0.17
Namespaces | Functions
fileio.hpp File Reference
#include <vector>
#include <string>
#include <cstdio>

Go to the source code of this file.

Namespaces

 strus
 Wrapper to structures needed for atomic counters.
 

Functions

int strus::readFileSize (const std::string &filename, std::size_t &size)
 Evaluate the size of a file in bytes. More...
 
int strus::readFile (const std::string &filename, std::string &res)
 Reads the complete content of a file to a string. More...
 
int strus::readStdin (std::string &res)
 Reads the complete input of stdin to a string. More...
 
int strus::writeFile (const std::string &filename, const std::string &content)
 Writes a string to a file creating the file if it does not exist. More...
 
int strus::appendFile (const std::string &filename, const std::string &content)
 Appends a string to a file creating the file if it does not exist. More...
 
int strus::removeFile (const std::string &filename, bool fail_ifnofexist=false)
 Removes a file. More...
 
int strus::removeDir (const std::string &dirname, bool fail_ifnofexist=false)
 Removes an empty directory. More...
 
int strus::removeDirRecursive (const std::string &dirname, bool fail_ifnofexist=false)
 Removes a directory with all its contents. More...
 
int strus::renameFile (const std::string &old_filename, const std::string &new_filename)
 Moves (renames) a file. More...
 
int strus::createDir (const std::string &dirname, bool fail_ifexist=true)
 Creates a directory if it does not exist yet. More...
 
int strus::mkdirp (const std::string &dirname)
 Creates a directory path (mkdir -p) More...
 
int strus::changeDir (const std::string &dirname)
 Change current directory of the process. More...
 
int strus::readDirFiles (const std::string &path, const std::string &ext, std::vector< std::string > &res)
 Reads all file names matching to the extension ext of a directory to an array of strings. More...
 
int strus::readDirSubDirs (const std::string &path, std::vector< std::string > &res)
 Reads all subdirectories of a directory to an array of strings. More...
 
int strus::readDirItems (const std::string &path, std::vector< std::string > &res)
 Reads all items (directory or file) of a directory to an array of strings. More...
 
int strus::expandFilePattern (const std::string &pathPattern, std::vector< std::string > &res)
 Get all items matching a file path pattern (with '?' and '*' as substitutes) More...
 
bool strus::isFile (const std::string &path)
 Check if a file system path points to a file. More...
 
bool strus::isDir (const std::string &path)
 Check if a file system path points to a directory. More...
 
bool strus::isRelativePath (const std::string &path)
 Check if a file system path is a path starting with a name and not with a directive referencing the current path './' or the file system root '/'. More...
 
bool strus::isAbsolutePath (const std::string &path)
 Check if a file system path is a path starting the file system root '/'. More...
 
bool strus::isExplicitPath (const std::string &path)
 Check if a file path is explicit (relative path or absolute path) More...
 
bool strus::isTextFile (const std::string &path)
 Check if a file system path points to a file with text content (not binary) More...
 
int strus::getParentPath (const std::string &path, std::string &dest)
 Get the parent (containing) path of a file or directory. More...
 
int strus::getAncestorPath (const std::string &path, int level, std::string &dest)
 Get an ancestor (containing) path of a file or directory. More...
 
int strus::getFileName (const std::string &path, std::string &dest, bool withExtension=true)
 Get the file name without parent path of a file or directory. More...
 
int strus::getFileExtension (const std::string &path, std::string &ext)
 Get the extension (including '.') of a file or directory. More...
 
char strus::dirSeparator ()
 Get the OS path element separator. More...
 
bool strus::hasUpdirReference (const std::string &path)
 Return true, if the path contains an upper directory reference '..'. More...
 
std::string strus::joinFilePath (const std::string &parentpath, const std::string &childpath)
 Join two path with directory separator. More...
 
int strus::resolveUpdirReferences (std::string &path)
 Resolve upper directory references in a path, e.g. replace "/home/john/../jack" by "/home/jack". More...