File utility functions. More...
#include "config.hpp"
#include "logger/logger.hpp"
#include "utils/fs.hpp"
#include "utils/paths.hpp"
#include "utils/exception.hpp"
#include <boost/filesystem.hpp>
#include <dirent.h>
#include <fstream>
#include <streambuf>
#include <cstring>
#include <cerrno>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <iostream>
Namespaces | |
utils | |
Functions | |
std::string | utils::readFileStream (const std::string &path) |
Reads the content of file stream (no seek); Throws exception on error. More... | |
bool | utils::readFileStream (const std::string &path, std::string &result) |
Reads the content of file stream (no seek) More... | |
std::string | utils::readFileContent (const std::string &path) |
Reads the content of a file (performs seek); Throws exception on error. More... | |
bool | utils::readFileContent (const std::string &path, std::string &content) |
Reads the content of a file. More... | |
bool | utils::saveFileContent (const std::string &path, const std::string &content) |
Save the content to the file. More... | |
bool | utils::readFirstLineOfFile (const std::string &path, std::string &ret) |
Read a line from file Its goal is to read a kernel config files (eg. More... | |
bool | utils::removeFile (const std::string &path) |
Remove file. More... | |
bool | utils::isCharDevice (const std::string &path) |
Checks if a char device exists. More... | |
void | utils::assertIsDir (const std::string &path) |
Checks if a path exists and points to a directory. More... | |
void | utils::assertIsAbsolute (const std::string &path) |
Checks if path is absolute. More... | |
bool | utils::mountRun (const std::string &path) |
Mounts run as a tmpfs on a given path. More... | |
bool | utils::mount (const std::string &source, const std::string &target, const std::string &filesystemtype, unsigned long mountflags, const std::string &data) |
Creates mount point. More... | |
bool | utils::umount (const std::string &path) |
Umounts a filesystem. More... | |
bool | utils::isMountPoint (const std::string &path, bool &result) |
Check if given path is a mount point. More... | |
bool | utils::hasSameMountPoint (const std::string &path1, const std::string &path2, bool &result) |
Checks whether the given paths are under the same mount point. More... | |
bool | utils::moveFile (const std::string &src, const std::string &dst) |
Moves the file either by rename if under the same mount point or by copy&delete if under a different one. More... | |
bool | utils::copyDirContents (const std::string &src, const std::string &dst) |
Recursively copy contents of src dir to dst dir. More... | |
bool | utils::createDir (const std::string &path, uid_t uid, uid_t gid, boost::filesystem::perms mode) |
Creates a directory with specific UID, GID and permissions set. More... | |
bool | utils::createDirs (const std::string &path, mode_t mode) |
Recursively creates a directory with specific permissions set. More... | |
bool | utils::createEmptyDir (const std::string &path) |
Creates an empty directory, ready to serve as mount point. More... | |
bool | utils::createFile (const std::string &path, int flags, mode_t mode) |
Creates an empty file. More... | |
bool | utils::createFifo (const std::string &path, mode_t mode) |
Creates an FIFO special file. More... | |
bool | utils::copyFile (const std::string &src, const std::string &dest) |
Copy an file. More... | |
bool | utils::createLink (const std::string &src, const std::string &dest) |
Create hard link. More... | |
File utility functions.