File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,8 +118,8 @@ TreeWatch::Add(std::string_view relative_path)
118118 }
119119}
120120
121- FileDescriptor
122- TreeWatch::Find (std::string_view relative_path) const noexcept
121+ const TreeWatch::Directory *
122+ TreeWatch::FindDirectory (std::string_view relative_path) const noexcept
123123{
124124 assert (root.IsOpen ());
125125
@@ -131,12 +131,12 @@ TreeWatch::Find(std::string_view relative_path) const noexcept
131131
132132 const auto i = directory->children .find (name);
133133 if (i == directory->children .end ())
134- return FileDescriptor::Undefined () ;
134+ return nullptr ;
135135
136136 directory = &i->second ;
137137 }
138138
139- return directory-> fd ;
139+ return directory;
140140}
141141
142142TreeWatch::Directory &
Original file line number Diff line number Diff line change @@ -69,9 +69,21 @@ public:
6969 * #FileDescriptor.
7070 */
7171 [[gnu::pure]]
72- FileDescriptor Find (std::string_view relative_path) const noexcept ;
72+ FileDescriptor Find (std::string_view relative_path) const noexcept {
73+ const auto *directory = FindDirectory (relative_path);
74+ return directory != nullptr
75+ ? FileDescriptor{directory->fd }
76+ : FileDescriptor::Undefined ();
77+ }
7378
7479private:
80+ /* *
81+ * Look up a #Directory object. Returns nullptr if the
82+ * specified path is not being watched.
83+ */
84+ [[gnu::pure]]
85+ const Directory *FindDirectory (std::string_view relative_path) const noexcept ;
86+
7587 Directory &MakeChild (Directory &parent, std::string_view name,
7688 bool persist, bool all) noexcept ;
7789
You can’t perform that action at this time.
0 commit comments