1 /* Copyright 2012-present Facebook, Inc.
2  * Licensed under the Apache License, Version 2.0 */
3 #pragma once
4 #include <unordered_map>
5 
6 struct watchman_dir {
7   /* the name of this dir, relative to its parent */
8   w_string name;
9   /* the parent dir */
10   watchman_dir* parent;
11 
12   /* files contained in this dir (keyed by file->name) */
13   struct Deleter {
14     void operator()(watchman_file*) const;
15   };
16   std::unordered_map<w_string_piece, std::unique_ptr<watchman_file, Deleter>>
17       files;
18 
19   /* child dirs contained in this dir (keyed by dir->path) */
20   std::unordered_map<w_string, std::unique_ptr<watchman_dir>> dirs;
21 
22   // If we think this dir was deleted, we'll avoid recursing
23   // to its children when processing deletes
24   bool last_check_existed{true};
25 
26   watchman_dir(w_string name, watchman_dir* parent);
27   watchman_dir* getChildDir(w_string name) const;
28 
29   /** Returns the direct child file named name, or nullptr
30    * if there is no such entry */
31   watchman_file* getChildFile(w_string name) const;
32   w_string getFullPath() const;
33 };
34 void delete_dir(struct watchman_dir* dir);
35