1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:47:47 +00:00

AK: Remove the LexicalPath::is_valid() API

Since this is always set to true on the non-default constructor and
subsequently never modified, it is somewhat pointless. Furthermore,
there are arguably no invalid relative paths.
This commit is contained in:
Max Wipfli 2021-06-29 13:11:03 +02:00 committed by Andreas Kling
parent caa9daf59e
commit 9b8f35259c
10 changed files with 14 additions and 66 deletions

View file

@ -74,13 +74,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, St
// We trust that the kernel only sends the name when appropriate.
if (event->name_length > 0) {
String child_name { event->name, event->name_length - 1 };
auto lexical_path = LexicalPath::join(path, child_name);
if (!lexical_path.is_valid()) {
dbgln_if(FILE_WATCHER_DEBUG, "get_event_from_fd: Reading from wd {}: Invalid child name '{}'", fd, child_name);
return {};
}
result.event_path = lexical_path.string();
result.event_path = LexicalPath::join(path, child_name).string();
} else {
result.event_path = path;
}
@ -100,11 +94,6 @@ Result<bool, String> FileWatcherBase::add_watch(String path, FileWatcherEvent::T
free(buf);
}
if (!lexical_path.is_valid()) {
dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' invalid", path);
return false;
}
auto const& canonical_path = lexical_path.string();
if (m_path_to_wd.find(canonical_path) != m_path_to_wd.end()) {
dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", canonical_path);
@ -145,11 +134,6 @@ Result<bool, String> FileWatcherBase::remove_watch(String path)
free(buf);
}
if (!lexical_path.is_valid()) {
dbgln_if(FILE_WATCHER_DEBUG, "remove_watch: path '{}' invalid", path);
return false;
}
auto const& canonical_path = lexical_path.string();
auto it = m_path_to_wd.find(canonical_path);
if (it == m_path_to_wd.end()) {