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

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -6,8 +6,8 @@
*/
#include "FileWatcher.h"
#include <AK/ByteString.h>
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/NonnullRefPtr.h>
#include <Kernel/API/InodeWatcherEvent.h>
@ -36,7 +36,7 @@ static constexpr unsigned file_watcher_flags_to_inode_watcher_flags(FileWatcherF
return static_cast<unsigned>(result);
}
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, DeprecatedString> const& wd_to_path)
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, ByteString> const& wd_to_path)
{
u8 buffer[MAXIMUM_EVENT_SIZE];
int rc = read(fd, &buffer, MAXIMUM_EVENT_SIZE);
@ -55,7 +55,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, De
dbgln_if(FILE_WATCHER_DEBUG, "get_event_from_fd: Got an event for a non-existent wd {}?!", event->watch_descriptor);
return {};
}
DeprecatedString const& path = it->value;
ByteString const& path = it->value;
switch (event->type) {
case InodeWatcherEvent::Type::ChildCreated:
@ -80,7 +80,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, De
// We trust that the kernel only sends the name when appropriate.
if (event->name_length > 0) {
DeprecatedString child_name { event->name, event->name_length - 1 };
ByteString child_name { event->name, event->name_length - 1 };
result.event_path = LexicalPath::join(path, child_name).string();
} else {
result.event_path = path;
@ -90,7 +90,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, De
return result;
}
static DeprecatedString canonicalize_path(DeprecatedString path)
static ByteString canonicalize_path(ByteString path)
{
if (!path.is_empty() && path[0] == '/')
return LexicalPath::canonicalized_path(move(path));
@ -99,9 +99,9 @@ static DeprecatedString canonicalize_path(DeprecatedString path)
return LexicalPath::join({ cwd, strlen(cwd) }, move(path)).string();
}
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask)
ErrorOr<bool> FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask)
{
DeprecatedString canonical_path = canonicalize_path(move(path));
ByteString canonical_path = canonicalize_path(move(path));
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);
@ -131,9 +131,9 @@ ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent
return true;
}
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString path)
ErrorOr<bool> FileWatcherBase::remove_watch(ByteString path)
{
DeprecatedString canonical_path = canonicalize_path(move(path));
ByteString canonical_path = canonicalize_path(move(path));
auto it = m_path_to_wd.find(canonical_path);
if (it == m_path_to_wd.end()) {