1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +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

@ -643,10 +643,6 @@ int Shell::builtin_popd(int argc, const char** argv)
}
LexicalPath lexical_path(path.characters());
if (!lexical_path.is_valid()) {
warnln("LexicalPath failed to canonicalize '{}'", path);
return 1;
}
const char* real_path = lexical_path.string().characters();
@ -729,16 +725,10 @@ int Shell::builtin_pushd(int argc, const char** argv)
}
}
LexicalPath lexical_path(path_builder.to_string());
if (!lexical_path.is_valid()) {
warnln("LexicalPath failed to canonicalize '{}'", path_builder.string_view());
return 1;
}
const char* real_path = lexical_path.string().characters();
auto real_path = LexicalPath::canonicalized_path(path_builder.to_string());
struct stat st;
int rc = stat(real_path, &st);
int rc = stat(real_path.characters(), &st);
if (rc < 0) {
warnln("stat({}) failed: {}", real_path, strerror(errno));
return 1;
@ -750,13 +740,13 @@ int Shell::builtin_pushd(int argc, const char** argv)
}
if (should_switch) {
int rc = chdir(real_path);
int rc = chdir(real_path.characters());
if (rc < 0) {
warnln("chdir({}) failed: {}", real_path, strerror(errno));
return 1;
}
cwd = lexical_path.string();
cwd = real_path;
}
return 0;