diff options
author | aszlig <aszlig@redmoonstudios.org> | 2017-10-03 23:10:21 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2017-10-03 23:41:43 +0200 |
commit | 175e9328bf9d403c70a0fd3721d1839538558422 (patch) | |
tree | 8bc2d87b5616992c3fcab76699e8f1ec54c4dc33 /pkgs/games/build-support/build-sandbox/src/path-cache.cc | |
parent | b7e0a4c55944b266f2a6c2aa65d093eb31dcc3ad (diff) |
pkgs/sandbox: Implement a path cache
First of all this is to bring down the amount of syscalls we're doing but it's also useful to avoid errors when we try to mount a path over an already mounted path. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/games/build-support/build-sandbox/src/path-cache.cc')
-rw-r--r-- | pkgs/games/build-support/build-sandbox/src/path-cache.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/games/build-support/build-sandbox/src/path-cache.cc b/pkgs/games/build-support/build-sandbox/src/path-cache.cc new file mode 100644 index 00000000..5bfa43a7 --- /dev/null +++ b/pkgs/games/build-support/build-sandbox/src/path-cache.cc @@ -0,0 +1,21 @@ +#include <set> +#include <string> + +typedef std::set<std::string> *path_cache; + +extern "C" { + path_cache new_path_cache(void) + { + return new std::set<std::string>(); + } + + void free_path_cache(path_cache pc) + { + delete pc; + } + + bool cache_path(path_cache pc, const char *path) + { + return pc->insert(std::string(path)).second; + } +} |