mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullRefPtr<File>> File::open(String filename, OpenMode mode, mode_t permissions)
|
||||
ErrorOr<NonnullRefPtr<File>> File::open(DeprecatedString filename, OpenMode mode, mode_t permissions)
|
||||
{
|
||||
auto file = File::construct(move(filename));
|
||||
if (!file->open_impl(mode, permissions))
|
||||
|
@ -37,7 +37,7 @@ ErrorOr<NonnullRefPtr<File>> File::open(String filename, OpenMode mode, mode_t p
|
|||
return file;
|
||||
}
|
||||
|
||||
File::File(String filename, Object* parent)
|
||||
File::File(DeprecatedString filename, Object* parent)
|
||||
: IODevice(parent)
|
||||
, m_filename(move(filename))
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ bool File::is_device() const
|
|||
return S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_device(String const& filename)
|
||||
bool File::is_device(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -125,7 +125,7 @@ bool File::is_block_device() const
|
|||
return S_ISBLK(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_block_device(String const& filename)
|
||||
bool File::is_block_device(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -141,7 +141,7 @@ bool File::is_char_device() const
|
|||
return S_ISCHR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_char_device(String const& filename)
|
||||
bool File::is_char_device(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -157,7 +157,7 @@ bool File::is_directory() const
|
|||
return S_ISDIR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_directory(String const& filename)
|
||||
bool File::is_directory(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -173,7 +173,7 @@ bool File::is_link() const
|
|||
return S_ISLNK(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_link(String const& filename)
|
||||
bool File::is_link(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (lstat(filename.characters(), &st) < 0)
|
||||
|
@ -186,18 +186,18 @@ bool File::looks_like_shared_library() const
|
|||
return File::looks_like_shared_library(m_filename);
|
||||
}
|
||||
|
||||
bool File::looks_like_shared_library(String const& filename)
|
||||
bool File::looks_like_shared_library(DeprecatedString const& filename)
|
||||
{
|
||||
return filename.ends_with(".so"sv) || filename.contains(".so."sv);
|
||||
}
|
||||
|
||||
bool File::exists(String const& filename)
|
||||
bool File::exists(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
return stat(filename.characters(), &st) == 0;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> File::size(String const& filename)
|
||||
ErrorOr<size_t> File::size(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -205,17 +205,17 @@ ErrorOr<size_t> File::size(String const& filename)
|
|||
return st.st_size;
|
||||
}
|
||||
|
||||
String File::real_path_for(String const& filename)
|
||||
DeprecatedString File::real_path_for(DeprecatedString const& filename)
|
||||
{
|
||||
if (filename.is_null())
|
||||
return {};
|
||||
auto* path = realpath(filename.characters(), nullptr);
|
||||
String real_path(path);
|
||||
DeprecatedString real_path(path);
|
||||
free(path);
|
||||
return real_path;
|
||||
}
|
||||
|
||||
String File::current_working_directory()
|
||||
DeprecatedString File::current_working_directory()
|
||||
{
|
||||
char* cwd = getcwd(nullptr, 0);
|
||||
if (!cwd) {
|
||||
|
@ -223,13 +223,13 @@ String File::current_working_directory()
|
|||
return {};
|
||||
}
|
||||
|
||||
auto cwd_as_string = String(cwd);
|
||||
auto cwd_as_string = DeprecatedString(cwd);
|
||||
free(cwd);
|
||||
|
||||
return cwd_as_string;
|
||||
}
|
||||
|
||||
String File::absolute_path(String const& path)
|
||||
DeprecatedString File::absolute_path(DeprecatedString const& path)
|
||||
{
|
||||
if (File::exists(path))
|
||||
return File::real_path_for(path);
|
||||
|
@ -245,7 +245,7 @@ String File::absolute_path(String const& path)
|
|||
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
ErrorOr<String> File::read_link(String const& link_path)
|
||||
ErrorOr<DeprecatedString> File::read_link(DeprecatedString const& link_path)
|
||||
{
|
||||
// First, try using a 64-byte buffer, that ought to be enough for anybody.
|
||||
char small_buffer[64];
|
||||
|
@ -259,7 +259,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
// returns the full size of the link. Let's see if our small buffer
|
||||
// was enough to read the whole link.
|
||||
if (size <= sizeof(small_buffer))
|
||||
return String { small_buffer, size };
|
||||
return DeprecatedString { small_buffer, size };
|
||||
// Nope, but at least now we know the right size.
|
||||
char* large_buffer_ptr;
|
||||
auto large_buffer = StringImpl::create_uninitialized(size, large_buffer_ptr);
|
||||
|
@ -275,7 +275,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
// If we're here, the symlink has changed while we were looking at it.
|
||||
// If it became shorter, our buffer is valid, we just have to trim it a bit.
|
||||
if (new_size < size)
|
||||
return String { large_buffer_ptr, new_size };
|
||||
return DeprecatedString { large_buffer_ptr, new_size };
|
||||
// Otherwise, here's not much we can do, unless we want to loop endlessly
|
||||
// in this case. Let's leave it up to the caller whether to loop.
|
||||
errno = EAGAIN;
|
||||
|
@ -286,7 +286,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
|
||||
// This is a sad version for other systems. It has to always make a copy of the
|
||||
// link path, and to always make two syscalls to get the right size first.
|
||||
ErrorOr<String> File::read_link(String const& link_path)
|
||||
ErrorOr<DeprecatedString> File::read_link(DeprecatedString const& link_path)
|
||||
{
|
||||
struct stat statbuf = {};
|
||||
int rc = lstat(link_path.characters(), &statbuf);
|
||||
|
@ -299,7 +299,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
// (See above.)
|
||||
if (rc == statbuf.st_size)
|
||||
return { *buffer };
|
||||
return String { buffer_ptr, (size_t)rc };
|
||||
return DeprecatedString { buffer_ptr, (size_t)rc };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -335,7 +335,7 @@ NonnullRefPtr<File> File::standard_error()
|
|||
return *stderr_file;
|
||||
}
|
||||
|
||||
static String get_duplicate_name(String const& path, int duplicate_count)
|
||||
static DeprecatedString get_duplicate_name(DeprecatedString const& path, int duplicate_count)
|
||||
{
|
||||
if (duplicate_count == 0) {
|
||||
return path;
|
||||
|
@ -347,7 +347,7 @@ static String get_duplicate_name(String const& path, int duplicate_count)
|
|||
for (size_t i = 0; i < parts.size() - 1; ++i) {
|
||||
duplicated_name.appendff("{}/", parts[i]);
|
||||
}
|
||||
auto prev_duplicate_tag = String::formatted("({})", duplicate_count);
|
||||
auto prev_duplicate_tag = DeprecatedString::formatted("({})", duplicate_count);
|
||||
auto title = lexical_path.title();
|
||||
if (title.ends_with(prev_duplicate_tag)) {
|
||||
// remove the previous duplicate tag "(n)" so we can add a new tag.
|
||||
|
@ -360,7 +360,7 @@ static String get_duplicate_name(String const& path, int duplicate_count)
|
|||
return duplicated_name.build();
|
||||
}
|
||||
|
||||
ErrorOr<void, File::CopyError> File::copy_file_or_directory(String const& dst_path, String const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode)
|
||||
ErrorOr<void, File::CopyError> File::copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode)
|
||||
{
|
||||
if (add_duplicate_file_marker == AddDuplicateFileMarker::Yes) {
|
||||
int duplicate_count = 0;
|
||||
|
@ -398,14 +398,14 @@ ErrorOr<void, File::CopyError> File::copy_file_or_directory(String const& dst_pa
|
|||
return copy_file(dst_path, src_stat, source, preserve_mode);
|
||||
}
|
||||
|
||||
ErrorOr<void, File::CopyError> File::copy_file(String const& dst_path, struct stat const& src_stat, File& source, PreserveMode preserve_mode)
|
||||
ErrorOr<void, File::CopyError> File::copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, File& source, PreserveMode preserve_mode)
|
||||
{
|
||||
int dst_fd = creat(dst_path.characters(), 0666);
|
||||
if (dst_fd < 0) {
|
||||
if (errno != EISDIR)
|
||||
return CopyError { errno, false };
|
||||
|
||||
auto dst_dir_path = String::formatted("{}/{}", dst_path, LexicalPath::basename(source.filename()));
|
||||
auto dst_dir_path = DeprecatedString::formatted("{}/{}", dst_path, LexicalPath::basename(source.filename()));
|
||||
dst_fd = creat(dst_dir_path.characters(), 0666);
|
||||
if (dst_fd < 0)
|
||||
return CopyError { errno, false };
|
||||
|
@ -470,15 +470,15 @@ ErrorOr<void, File::CopyError> File::copy_file(String const& dst_path, struct st
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void, File::CopyError> File::copy_directory(String const& dst_path, String const& src_path, struct stat const& src_stat, LinkMode link, PreserveMode preserve_mode)
|
||||
ErrorOr<void, File::CopyError> File::copy_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, struct stat const& src_stat, LinkMode link, PreserveMode preserve_mode)
|
||||
{
|
||||
if (mkdir(dst_path.characters(), 0755) < 0)
|
||||
return CopyError { errno, false };
|
||||
|
||||
String src_rp = File::real_path_for(src_path);
|
||||
src_rp = String::formatted("{}/", src_rp);
|
||||
String dst_rp = File::real_path_for(dst_path);
|
||||
dst_rp = String::formatted("{}/", dst_rp);
|
||||
DeprecatedString src_rp = File::real_path_for(src_path);
|
||||
src_rp = DeprecatedString::formatted("{}/", src_rp);
|
||||
DeprecatedString dst_rp = File::real_path_for(dst_path);
|
||||
dst_rp = DeprecatedString::formatted("{}/", dst_rp);
|
||||
|
||||
if (!dst_rp.is_empty() && dst_rp.starts_with(src_rp))
|
||||
return CopyError { errno, false };
|
||||
|
@ -488,10 +488,10 @@ ErrorOr<void, File::CopyError> File::copy_directory(String const& dst_path, Stri
|
|||
return CopyError { errno, false };
|
||||
|
||||
while (di.has_next()) {
|
||||
String filename = di.next_path();
|
||||
DeprecatedString filename = di.next_path();
|
||||
auto result = copy_file_or_directory(
|
||||
String::formatted("{}/{}", dst_path, filename),
|
||||
String::formatted("{}/{}", src_path, filename),
|
||||
DeprecatedString::formatted("{}/{}", dst_path, filename),
|
||||
DeprecatedString::formatted("{}/{}", src_path, filename),
|
||||
RecursionMode::Allowed, link, AddDuplicateFileMarker::Yes, preserve_mode);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -525,7 +525,7 @@ ErrorOr<void, File::CopyError> File::copy_directory(String const& dst_path, Stri
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> File::link_file(String const& dst_path, String const& src_path)
|
||||
ErrorOr<void> File::link_file(DeprecatedString const& dst_path, DeprecatedString const& src_path)
|
||||
{
|
||||
int duplicate_count = 0;
|
||||
while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) {
|
||||
|
@ -539,7 +539,7 @@ ErrorOr<void> File::link_file(String const& dst_path, String const& src_path)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void, File::RemoveError> File::remove(String const& path, RecursionMode mode, bool force)
|
||||
ErrorOr<void, File::RemoveError> File::remove(DeprecatedString const& path, RecursionMode mode, bool force)
|
||||
{
|
||||
struct stat path_stat;
|
||||
if (lstat(path.characters(), &path_stat) < 0) {
|
||||
|
@ -569,14 +569,14 @@ ErrorOr<void, File::RemoveError> File::remove(String const& path, RecursionMode
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<String> File::resolve_executable_from_environment(StringView filename)
|
||||
Optional<DeprecatedString> File::resolve_executable_from_environment(StringView filename)
|
||||
{
|
||||
if (filename.is_empty())
|
||||
return {};
|
||||
|
||||
// Paths that aren't just a file name generally count as already resolved.
|
||||
if (filename.contains('/')) {
|
||||
if (access(String { filename }.characters(), X_OK) != 0)
|
||||
if (access(DeprecatedString { filename }.characters(), X_OK) != 0)
|
||||
return {};
|
||||
|
||||
return filename;
|
||||
|
@ -592,7 +592,7 @@ Optional<String> File::resolve_executable_from_environment(StringView filename)
|
|||
auto directories = path.split_view(':');
|
||||
|
||||
for (auto directory : directories) {
|
||||
auto file = String::formatted("{}/{}", directory, filename);
|
||||
auto file = DeprecatedString::formatted("{}/{}", directory, filename);
|
||||
|
||||
if (access(file.characters(), X_OK) == 0)
|
||||
return file;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue