25 #ifndef COMMON_UTILS_FS_HPP
26 #define COMMON_UTILS_FS_HPP
29 #include <sys/types.h>
31 #include <boost/filesystem.hpp>
59 bool saveFileContent(
const std::string& path,
const std::string& content);
90 bool listDir(
const std::string& path, std::vector<std::string>& files);
95 bool mountRun(
const std::string& path);
100 bool mount(
const std::string& source,
101 const std::string& target,
102 const std::string& filesystemtype,
103 unsigned long mountflags,
104 const std::string&
data);
109 bool umount(
const std::string& path);
114 bool isMountPoint(
const std::string& path,
bool& result);
119 bool hasSameMountPoint(
const std::string& path1,
const std::string& path2,
bool& result);
126 bool moveFile(
const std::string& src,
const std::string& dst);
136 bool createDir(
const std::string& path, uid_t uid, uid_t gid, boost::filesystem::perms mode);
141 bool createDirs(
const std::string& path, mode_t mode);
153 bool createFile(
const std::string& path,
int flags, mode_t mode);
158 bool createFifo(
const std::string& path, mode_t mode);
163 bool copyFile(
const std::string& src,
const std::string& dest);
168 bool createLink(
const std::string& src,
const std::string& dest);
173 #endif // COMMON_UTILS_FS_HPP
bool createFifo(const std::string &path, mode_t mode)
Creates an FIFO special file.
Definition: fs.cpp:520
std::string readFileStream(const std::string &path)
Reads the content of file stream (no seek); Throws exception on error.
Definition: fs.cpp:50
bool hasSameMountPoint(const std::string &path1, const std::string &path2, bool &result)
Checks whether the given paths are under the same mount point.
Definition: fs.cpp:277
bool 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.
Definition: fs.cpp:408
void assertIsAbsolute(const std::string &path)
Checks if path is absolute.
Definition: fs.cpp:192
bool saveFileContent(const std::string &path, const std::string &content)
Save the content to the file.
Definition: fs.cpp:114
std::string readFileContent(const std::string &path)
Reads the content of a file (performs seek); Throws exception on error.
Definition: fs.cpp:76
bool createDirs(const std::string &path, mode_t mode)
Recursively creates a directory with specific permissions set.
Definition: fs.cpp:447
bool removeFile(const std::string &path)
Remove file.
Definition: fs.cpp:145
bool umount(const std::string &path)
Umounts a filesystem.
Definition: fs.cpp:255
char data[368]
Definition: initctl.cpp:41
bool createFile(const std::string &path, int flags, mode_t mode)
Creates an empty file.
Definition: fs.cpp:505
bool readFirstLineOfFile(const std::string &path, std::string &ret)
Read a line from file Its goal is to read a kernel config files (eg.
Definition: fs.cpp:129
bool isCharDevice(const std::string &path)
Checks if a char device exists.
Definition: fs.cpp:158
bool mount(const std::string &source, const std::string &target, const std::string &filesystemtype, unsigned long mountflags, const std::string &data)
Creates mount point.
Definition: fs.cpp:225
bool isMountPoint(const std::string &path, bool &result)
Check if given path is a mount point.
Definition: fs.cpp:264
bool listDir(const std::string &path, std::vector< std::string > &files)
List all (including '.
void assertIsDir(const std::string &path)
Checks if a path exists and points to a directory.
Definition: fs.cpp:164
bool mountRun(const std::string &path)
Mounts run as a tmpfs on a given path.
Definition: fs.cpp:219
bool copyDirContents(const std::string &src, const std::string &dst)
Recursively copy contents of src dir to dst dir.
Definition: fs.cpp:403
bool copyFile(const std::string &src, const std::string &dest)
Copy an file.
Definition: fs.cpp:530
bool createLink(const std::string &src, const std::string &dest)
Create hard link.
Definition: fs.cpp:562
bool 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 ...
Definition: fs.cpp:295
bool createEmptyDir(const std::string &path)
Creates an empty directory, ready to serve as mount point.
Definition: fs.cpp:477