1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +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:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -5,8 +5,8 @@
*/
#include "ProjectTemplate.h"
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DirIterator.h>
@ -19,7 +19,7 @@
namespace HackStudio {
ProjectTemplate::ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority)
ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority)
: m_id(id)
, m_name(name)
, m_description(description)
@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(String const& id, String const& name, String co
{
}
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manifest_path)
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString 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(String const& manife
// Fallback to a generic executable icon if one isn't found
auto icon = GUI::Icon::default_icon("filetype-executable"sv);
auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
if (Core::File::exists(bitmap_path_32)) {
auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(bitmap_path_32);
@ -61,11 +61,11 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manife
return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority));
}
Result<void, String> ProjectTemplate::create_project(String const& name, String const& path)
Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path)
{
// Check if a file or directory already exists at the project path
if (Core::File::exists(path))
return String("File or directory already exists at specified location.");
return DeprecatedString("File or directory already exists at specified location.");
dbgln("Creating project at path '{}' with name '{}'", path, name);
@ -75,19 +75,19 @@ Result<void, String> ProjectTemplate::create_project(String const& name, String
auto result = Core::File::copy_file_or_directory(path, content_path());
dbgln("Copying {} -> {}", content_path(), path);
if (result.is_error())
return String::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
return DeprecatedString::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 String::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
return DeprecatedString::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(String::formatted("{}/{}.postcreate", templates_path(), m_id));
auto postcreate_script_path = LexicalPath::canonicalized_path(DeprecatedString::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, String> ProjectTemplate::create_project(String const& name, String
if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
return String("Failed to spawn project post-create script.");
return DeprecatedString("Failed to spawn project post-create script.");
}
// Command spawned, wait for exit.
int status;
if (waitpid(child_pid, &status, 0) < 0)
return String("Failed to spawn project post-create script.");
return DeprecatedString("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 String("Project post-creation script exited with non-zero error code.");
return DeprecatedString("Project post-creation script exited with non-zero error code.");
}
return {};