mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Ledger maintenance refactor. (#130)
* Added ledger namespace. * Thread-safe lcl access and update. * Refactored history sync and serving into a thread. * Restructured ledger cache item.
This commit is contained in:
14
src/util.cpp
14
src/util.cpp
@@ -375,6 +375,20 @@ namespace util
|
||||
return remove(path.data());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all files from a directory (not recursive).
|
||||
*/
|
||||
int clear_directory(std::string_view dir_path)
|
||||
{
|
||||
return nftw(
|
||||
dir_path.data(), [](const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
|
||||
if (typeflag == FTW_F) // Is file.
|
||||
return remove(fpath);
|
||||
return 0;
|
||||
},
|
||||
1, FTW_PHYS);
|
||||
}
|
||||
|
||||
void split_string(std::vector<std::string> &collection, std::string_view str, std::string_view delimeter)
|
||||
{
|
||||
if (str.empty())
|
||||
|
||||
Reference in New Issue
Block a user