mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +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
|
@ -91,10 +91,10 @@ int main(int argc, char** argv)
|
|||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GAction&) {
|
||||
GInputBox input_box("Enter name:", "New directory", window);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty()) {
|
||||
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
||||
directory_view->path().characters(),
|
||||
input_box.text_value().characters()))
|
||||
.string();
|
||||
auto new_dir_path = canonicalized_path(
|
||||
String::format("%s/%s",
|
||||
directory_view->path().characters(),
|
||||
input_box.text_value().characters()));
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue