1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +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

@ -5,7 +5,7 @@
*/
#include "ProjectTemplate.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
@ -19,7 +19,7 @@
namespace HackStudio {
ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority)
ProjectTemplate::ProjectTemplate(ByteString const& id, ByteString const& name, ByteString const& description, const GUI::Icon& icon, int priority)
: m_id(id)
, m_name(name)
, m_description(description)
@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString co
{
}
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString const& manifest_path)
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(ByteString const& manifest_path)
{
auto maybe_config = Core::ConfigFile::open(manifest_path);
if (maybe_config.is_error())
@ -50,7 +50,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString con
// Fallback to a generic executable icon if one isn't found
auto icon = GUI::Icon::default_icon("filetype-executable"sv);
auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
auto bitmap_path_32 = ByteString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
if (FileSystem::exists(bitmap_path_32)) {
auto bitmap_or_error = Gfx::Bitmap::load_from_file(bitmap_path_32);
@ -61,11 +61,11 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString con
return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority));
}
Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path)
Result<void, ByteString> ProjectTemplate::create_project(ByteString const& name, ByteString const& path)
{
// Check if a file or directory already exists at the project path
if (FileSystem::exists(path))
return DeprecatedString("File or directory already exists at specified location.");
return ByteString("File or directory already exists at specified location.");
dbgln("Creating project at path '{}' with name '{}'", path, name);
@ -75,19 +75,19 @@ Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString
auto result = FileSystem::copy_file_or_directory(path, content_path());
dbgln("Copying {} -> {}", content_path(), path);
if (result.is_error())
return DeprecatedString::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
return ByteString::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
} else {
dbgln("No template content directory found for '{}', creating an empty directory for the project.", m_id);
int rc;
if ((rc = mkdir(path.characters(), 0755)) < 0) {
return DeprecatedString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
return ByteString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
}
}
// Check for an executable post-create script in $TEMPLATES_DIR/$ID.postcreate,
// and run it with the path and name
auto postcreate_script_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}.postcreate", templates_path(), m_id));
auto postcreate_script_path = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}.postcreate", templates_path(), m_id));
struct stat postcreate_st;
int result = stat(postcreate_script_path.characters(), &postcreate_st);
if (result == 0 && (postcreate_st.st_mode & S_IXOTH) == S_IXOTH) {
@ -101,19 +101,19 @@ Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString
if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
return DeprecatedString("Failed to spawn project post-create script.");
return ByteString("Failed to spawn project post-create script.");
}
// Command spawned, wait for exit.
int status;
if (waitpid(child_pid, &status, 0) < 0)
return DeprecatedString("Failed to spawn project post-create script.");
return ByteString("Failed to spawn project post-create script.");
int child_error = WEXITSTATUS(status);
dbgln("Post-create script exited with code {}", child_error);
if (child_error != 0)
return DeprecatedString("Project post-creation script exited with non-zero error code.");
return ByteString("Project post-creation script exited with non-zero error code.");
}
return {};