mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:38:10 +00:00
AK: Add a canonicalized_path() convenience function.
This is the same as calling FileSystemPath(foo).string(). The majority of clients only care about canonicalizing a path, so let's have an easy way to express that.
This commit is contained in:
parent
cd497accbe
commit
954a0b8efe
7 changed files with 33 additions and 25 deletions
|
@ -10,14 +10,14 @@ void DirectoryView::handle_activation(const GModelIndex& index)
|
|||
return;
|
||||
dbgprintf("on activation: %d,%d, this=%p, m_model=%p\n", index.row(), index.column(), this, m_model.ptr());
|
||||
auto& entry = model().entry(index.row());
|
||||
FileSystemPath path(String::format("%s/%s", model().path().characters(), entry.name.characters()));
|
||||
auto path = canonicalized_path(String::format("%s/%s", model().path().characters(), entry.name.characters()));
|
||||
if (entry.is_directory()) {
|
||||
open(path.string());
|
||||
open(path);
|
||||
return;
|
||||
}
|
||||
if (entry.is_executable()) {
|
||||
if (fork() == 0) {
|
||||
int rc = execl(path.string().characters(), path.string().characters(), nullptr);
|
||||
int rc = execl(path.characters(), path.characters(), nullptr);
|
||||
if (rc < 0)
|
||||
perror("exec");
|
||||
ASSERT_NOT_REACHED();
|
||||
|
@ -25,9 +25,9 @@ void DirectoryView::handle_activation(const GModelIndex& index)
|
|||
return;
|
||||
}
|
||||
|
||||
if (path.string().to_lowercase().ends_with(".png")) {
|
||||
if (path.to_lowercase().ends_with(".png")) {
|
||||
if (fork() == 0) {
|
||||
int rc = execl("/bin/qs", "/bin/qs", path.string().characters(), nullptr);
|
||||
int rc = execl("/bin/qs", "/bin/qs", path.characters(), nullptr);
|
||||
if (rc < 0)
|
||||
perror("exec");
|
||||
ASSERT_NOT_REACHED();
|
||||
|
@ -36,7 +36,7 @@ void DirectoryView::handle_activation(const GModelIndex& index)
|
|||
}
|
||||
|
||||
if (fork() == 0) {
|
||||
int rc = execl("/bin/TextEditor", "/bin/TextEditor", path.string().characters(), nullptr);
|
||||
int rc = execl("/bin/TextEditor", "/bin/TextEditor", path.characters(), nullptr);
|
||||
if (rc < 0)
|
||||
perror("exec");
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue