forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watchman_dir.h
40 lines (32 loc) · 1.34 KB
/
watchman_dir.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright 2012-present Facebook, Inc.
* Licensed under the Apache License, Version 2.0 */
#pragma once
#include <unordered_map>
struct watchman_dir {
/* the name of this dir, relative to its parent */
w_string name;
/* the parent dir */
watchman_dir* parent;
/* files contained in this dir (keyed by file->name) */
struct Deleter {
void operator()(watchman_file*) const;
};
std::unordered_map<w_string_piece, std::unique_ptr<watchman_file, Deleter>>
files;
/* child dirs contained in this dir (keyed by dir->name) */
std::unordered_map<w_string_piece, std::unique_ptr<watchman_dir>> dirs;
// If we think this dir was deleted, we'll avoid recursing
// to its children when processing deletes
bool last_check_existed{true};
watchman_dir(w_string name, watchman_dir* parent);
watchman_dir* getChildDir(w_string_piece name) const;
/** Returns the direct child file named name, or nullptr
* if there is no such entry */
watchman_file* getChildFile(w_string_piece name) const;
/** Walk up to the chain of dirs via ->parent to and then produce
* the full path to this dir relative to the root of the watch */
w_string getFullPath() const;
/** Compute the full path to this dir and concatenate child
* with it, to produce the path to the child */
w_string getFullPathToChild(w_string_piece child) const;
};