35 char constexpr kPathSep =
'/';
43 std::string
const& path,
44 std::string
const& ext = std::string());
47 std::string
dirname(std::string
const& path);
50 std::string
which(std::string
const& executable);
53 void cd(std::string
const& path);
58 bool exists(std::string
const& path,
int modeMask = 0);
63 bool isdir(std::string
const& path,
int modeMask = 0);
67 void mkdir(std::string
const& path,
int mode = 0777);
73 std::string
const& prefix =
"tmp",
74 std::string
const& tmpdir =
"");
80 std::string
const& prefix =
"cherrypi.tmp",
81 std::string
const& tmpdir =
"");
86 void touch(std::string
const& path);
90 void rmrf(std::string
const& path);
94 void mv(std::string
const& source, std::string
const& dest);
97 std::vector<std::string>
find(
98 std::string
const& path,
99 std::string
const& pattern);
102 std::vector<std::string>
findr(
103 std::string
const& path,
104 std::string
const& pattern);
107 std::vector<std::string>
glob(std::string
const& pattern);
110 size_t size(std::string
const& path);
113 std::chrono::system_clock::time_point
mtime(std::string
const& path);
116 std::vector<std::string>
readLines(std::string
const& path);
119 void writeLines(std::string
const& path, std::vector<std::string>);
124 std::vector<std::string>
127 std::vector<unsigned char>
md5(std::string
const& path);
void mv(std::string const &src, std::string const &dest)
moves a file system entry.
Definition: fsutils.cpp:462
void rmrf(std::string const &path)
Recursively remove a file system entry.
Definition: fsutils.cpp:310
std::vector< std::string > readLinesPartition(std::string const &path, int partition, int numPartitions)
Reads data from a given path and splits it into separate lines.
Definition: fsutils.cpp:504
size_t size(std::string const &path)
Get the size of the file in bytes.
Definition: fsutils.cpp:475
std::chrono::system_clock::time_point mtime(std::string const &path)
Get the last modification time of the file.
Definition: fsutils.cpp:483
void touch(std::string const &path)
Update file access and modification times.
Definition: fsutils.cpp:296
void cd(std::string const &path)
Change working directory.
Definition: fsutils.cpp:230
char constexpr kPathSep
Definition: fsutils.h:35
std::string which(std::string const &executable)
Locates an executable on the system.
Definition: fsutils.cpp:192
bool isdir(std::string const &path, int modeMask)
Checks if the given path is a directory.
Definition: fsutils.cpp:248
void writeLines(std::string const &path, std::vector< std::string > data)
writes data to a given path in different lines
Definition: fsutils.cpp:491
std::string mktemp(std::string const &prefix, std::string const &tmpLoc)
Creates a file at a suitable temporary location and returns its name.
Definition: fsutils.cpp:273
std::string dirname(std::string const &path)
Equivalent to dirname(1)
Definition: fsutils.cpp:423
General utilities.
Definition: assert.cpp:7
void mkdir(std::string const &path, int mode)
Creates a directory at the given path.
Definition: fsutils.cpp:452
std::vector< std::string > findr(std::string const &path, std::string const &pattern)
Find files matching a pattern (recursively).
Definition: fsutils.cpp:344
std::string basename(std::string const &path, std::string const &ext)
Equivalent to basename(1)
Definition: fsutils.cpp:402
std::vector< std::string > readLines(std::string const &path)
Reads data from a given path and splits it into separate lines.
Definition: fsutils.cpp:499
std::string mktempd(std::string const &prefix, std::string const &tmpdir)
Creates a directory at a suitable temporary location and returns its name.
Definition: fsutils.cpp:262
std::vector< unsigned char > md5(std::string const &path)
Definition: fsutils.cpp:381
std::vector< std::string > glob(std::string const &pattern)
File globbing.
Definition: fsutils.cpp:365
Utility functions for interacting with the file system.
Definition: fsutils.cpp:37
std::string pwd()
Returns the current working directory.
Definition: fsutils.cpp:182
std::vector< std::string > find(std::string const &path, std::string const &pattern)
Find files matching a pattern (non-recursively).
Definition: fsutils.cpp:328
bool exists(std::string const &path, int modeMask)
Checks if a filesystem entry the given path exists.
Definition: fsutils.cpp:236