summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-05-26 14:52:44 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-26 14:35:10 +0200
commit602c3fdb3a0975418886e32cf9cc53b45d2f8964 (patch)
tree079b3ebdaf7db517625496e35acf1158adacad77 /Applications
parentf746bbda174d914d5de9379084a6fb2095c58d68 (diff)
downloadserenity-602c3fdb3a0975418886e32cf9cc53b45d2f8964.zip
AK: Rename FileSystemPath -> LexicalPath
And move canonicalized_path() to a static method on LexicalPath. This is to make it clear that FileSystemPath/canonicalized_path() only perform *lexical* canonicalization.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/FileManager/DirectoryView.cpp1
-rw-r--r--Applications/FileManager/FileUtils.cpp18
-rw-r--r--Applications/FileManager/PropertiesDialog.cpp9
-rw-r--r--Applications/FileManager/PropertiesDialog.h1
-rw-r--r--Applications/FileManager/main.cpp14
-rw-r--r--Applications/Help/ManualSectionNode.cpp8
-rw-r--r--Applications/HexEditor/HexEditorWidget.cpp14
-rw-r--r--Applications/HexEditor/HexEditorWidget.h4
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp14
-rw-r--r--Applications/TextEditor/TextEditorWidget.h5
10 files changed, 44 insertions, 44 deletions
diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp
index 2efa86825f..4873277dca 100644
--- a/Applications/FileManager/DirectoryView.cpp
+++ b/Applications/FileManager/DirectoryView.cpp
@@ -25,7 +25,6 @@
*/
#include "DirectoryView.h"
-#include <AK/FileSystemPath.h>
#include <AK/NumberFormat.h>
#include <AK/StringBuilder.h>
#include <AK/URL.h>
diff --git a/Applications/FileManager/FileUtils.cpp b/Applications/FileManager/FileUtils.cpp
index 82580e1d2b..20187415d7 100644
--- a/Applications/FileManager/FileUtils.cpp
+++ b/Applications/FileManager/FileUtils.cpp
@@ -25,7 +25,7 @@
*/
#include "FileUtils.h"
-#include <AK/FileSystemPath.h>
+#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <LibCore/DirIterator.h>
#include <stdio.h>
@@ -134,7 +134,7 @@ bool copy_file(const String& src_path, const String& dst_path, const struct stat
if (errno != EISDIR) {
return false;
}
- auto dst_dir_path = String::format("%s/%s", dst_path.characters(), FileSystemPath(src_path).basename().characters());
+ auto dst_dir_path = String::format("%s/%s", dst_path.characters(), LexicalPath(src_path).basename().characters());
dst_fd = creat(dst_dir_path.characters(), 0666);
if (dst_fd < 0) {
return false;
@@ -186,21 +186,21 @@ String get_duplicate_name(const String& path, int duplicate_count)
if (duplicate_count == 0) {
return path;
}
- FileSystemPath fsp(path);
+ LexicalPath lexical_path(path);
StringBuilder duplicated_name;
duplicated_name.append('/');
- for (size_t i = 0; i < fsp.parts().size() - 1; ++i) {
- duplicated_name.appendf("%s/", fsp.parts()[i].characters());
+ for (size_t i = 0; i < lexical_path.parts().size() - 1; ++i) {
+ duplicated_name.appendf("%s/", lexical_path.parts()[i].characters());
}
auto prev_duplicate_tag = String::format("(%d)", duplicate_count);
- auto title = fsp.title();
+ auto title = lexical_path.title();
if (title.ends_with(prev_duplicate_tag)) {
// remove the previous duplicate tag "(n)" so we can add a new tag.
title = title.substring(0, title.length() - prev_duplicate_tag.length());
}
- duplicated_name.appendf("%s (%d)", fsp.title().characters(), duplicate_count);
- if (!fsp.extension().is_empty()) {
- duplicated_name.appendf(".%s", fsp.extension().characters());
+ duplicated_name.appendf("%s (%d)", lexical_path.title().characters(), duplicate_count);
+ if (!lexical_path.extension().is_empty()) {
+ duplicated_name.appendf(".%s", lexical_path.extension().characters());
}
return duplicated_name.build();
}
diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp
index 0813e5fbd0..8caa182dd5 100644
--- a/Applications/FileManager/PropertiesDialog.cpp
+++ b/Applications/FileManager/PropertiesDialog.cpp
@@ -25,6 +25,7 @@
*/
#include "PropertiesDialog.h"
+#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/CheckBox.h>
@@ -42,8 +43,8 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
: Dialog(parent_window)
, m_model(model)
{
- auto file_path = FileSystemPath(path);
- ASSERT(file_path.is_valid());
+ auto lexical_path = LexicalPath(path);
+ ASSERT(lexical_path.is_valid());
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.set_layout<GUI::VerticalBoxLayout>();
@@ -72,8 +73,8 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_icon->set_preferred_size(32, 32);
- m_name = file_path.basename();
- m_path = file_path.string();
+ m_name = lexical_path.basename();
+ m_path = lexical_path.string();
m_name_box = file_container.add<GUI::TextBox>();
m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
diff --git a/Applications/FileManager/PropertiesDialog.h b/Applications/FileManager/PropertiesDialog.h
index 6bb5621936..3ed9554194 100644
--- a/Applications/FileManager/PropertiesDialog.h
+++ b/Applications/FileManager/PropertiesDialog.h
@@ -26,7 +26,6 @@
#pragma once
-#include <AK/FileSystemPath.h>
#include <LibCore/File.h>
#include <LibGUI/Button.h>
#include <LibGUI/Dialog.h>
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 6ecdb03e9f..c2d2547dc9 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -27,7 +27,7 @@
#include "DirectoryView.h"
#include "FileUtils.h"
#include "PropertiesDialog.h"
-#include <AK/FileSystemPath.h>
+#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <AK/URL.h>
#include <LibCore/ConfigFile.h>
@@ -165,7 +165,7 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location
auto mkdir_action = GUI::Action::create("New directory...", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window);
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
- auto new_dir_path = canonicalized_path(
+ auto new_dir_path = LexicalPath::canonicalized_path(
String::format("%s/%s",
model->root_path().characters(),
input_box->text_value().characters()));
@@ -179,7 +179,7 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location
auto touch_action = GUI::Action::create("New file...", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
auto input_box = GUI::InputBox::construct("Enter name:", "New file", window);
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
- auto new_file_path = canonicalized_path(
+ auto new_file_path = LexicalPath::canonicalized_path(
String::format("%s/%s",
model->root_path().characters(),
input_box->text_value().characters()));
@@ -323,7 +323,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window);
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
- auto new_dir_path = canonicalized_path(
+ auto new_dir_path = LexicalPath::canonicalized_path(
String::format("%s/%s",
directory_view.path().characters(),
input_box->text_value().characters()));
@@ -442,7 +442,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
selected = selected_file_paths();
} else {
path = directories_model->full_path(tree_view.selection().first());
- container_dir_path = FileSystemPath(path).basename();
+ container_dir_path = LexicalPath(path).basename();
selected = tree_view_selected_file_paths();
}
@@ -510,7 +510,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
String message;
if (paths.size() == 1) {
- message = String::format("Really delete %s?", FileSystemPath(paths[0]).basename().characters());
+ message = String::format("Really delete %s?", LexicalPath(paths[0]).basename().characters());
} else {
message = String::format("Really delete %d files?", paths.size());
}
@@ -791,7 +791,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
continue;
auto new_path = String::format("%s/%s",
target_node.full_path(directory_view.model()).characters(),
- FileSystemPath(url_to_copy.path()).basename().characters());
+ LexicalPath(url_to_copy.path()).basename().characters());
if (url_to_copy.path() == new_path)
continue;
diff --git a/Applications/Help/ManualSectionNode.cpp b/Applications/Help/ManualSectionNode.cpp
index 5ac4bc5350..d6a1237a23 100644
--- a/Applications/Help/ManualSectionNode.cpp
+++ b/Applications/Help/ManualSectionNode.cpp
@@ -26,7 +26,7 @@
#include "ManualSectionNode.h"
#include "ManualPageNode.h"
-#include <AK/FileSystemPath.h>
+#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <AK/String.h>
#include <LibCore/DirIterator.h>
@@ -46,10 +46,10 @@ void ManualSectionNode::reify_if_needed() const
Vector<String> page_names;
while (dir_iter.has_next()) {
- FileSystemPath file_path(dir_iter.next_path());
- if (file_path.extension() != "md")
+ LexicalPath lexical_path(dir_iter.next_path());
+ if (lexical_path.extension() != "md")
continue;
- page_names.append(file_path.title());
+ page_names.append(lexical_path.title());
}
quick_sort(page_names);
diff --git a/Applications/HexEditor/HexEditorWidget.cpp b/Applications/HexEditor/HexEditorWidget.cpp
index 565cd42c1c..73bee7a7ef 100644
--- a/Applications/HexEditor/HexEditorWidget.cpp
+++ b/Applications/HexEditor/HexEditorWidget.cpp
@@ -87,7 +87,7 @@ HexEditorWidget::HexEditorWidget()
if (valid && file_size > 0) {
m_document_dirty = false;
m_editor->set_buffer(ByteBuffer::create_zeroed(file_size));
- set_path(FileSystemPath());
+ set_path(LexicalPath());
update_title();
} else {
GUI::MessageBox::show("Invalid file size entered.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
@@ -129,7 +129,7 @@ HexEditorWidget::HexEditorWidget()
}
m_document_dirty = false;
- set_path(FileSystemPath(save_path.value()));
+ set_path(LexicalPath(save_path.value()));
dbg() << "Wrote document to " << save_path.value();
});
@@ -211,11 +211,11 @@ HexEditorWidget::~HexEditorWidget()
{
}
-void HexEditorWidget::set_path(const FileSystemPath& file)
+void HexEditorWidget::set_path(const LexicalPath& lexical_path)
{
- m_path = file.string();
- m_name = file.title();
- m_extension = file.extension();
+ m_path = lexical_path.string();
+ m_name = lexical_path.title();
+ m_extension = lexical_path.extension();
update_title();
}
@@ -239,7 +239,7 @@ void HexEditorWidget::open_file(const String& path)
m_document_dirty = false;
m_editor->set_buffer(file->read_all()); // FIXME: On really huge files, this is never going to work. Should really create a framework to fetch data from the file on-demand.
- set_path(FileSystemPath(path));
+ set_path(LexicalPath(path));
}
bool HexEditorWidget::request_close()
diff --git a/Applications/HexEditor/HexEditorWidget.h b/Applications/HexEditor/HexEditorWidget.h
index 8661a92ccc..55152518ab 100644
--- a/Applications/HexEditor/HexEditorWidget.h
+++ b/Applications/HexEditor/HexEditorWidget.h
@@ -27,8 +27,8 @@
#pragma once
#include "HexEditor.h"
-#include <AK/FileSystemPath.h>
#include <AK/Function.h>
+#include <AK/LexicalPath.h>
#include <LibGUI/Application.h>
#include <LibGUI/TextEditor.h>
#include <LibGUI/Widget.h>
@@ -45,7 +45,7 @@ public:
private:
HexEditorWidget();
- void set_path(const FileSystemPath& file);
+ void set_path(const LexicalPath& file);
void update_title();
RefPtr<HexEditor> m_editor;
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp
index 3fb924f793..d4c0bc33cd 100644
--- a/Applications/TextEditor/TextEditorWidget.cpp
+++ b/Applications/TextEditor/TextEditorWidget.cpp
@@ -301,7 +301,7 @@ TextEditorWidget::TextEditorWidget()
m_document_dirty = false;
m_editor->set_text(StringView());
- set_path(FileSystemPath());
+ set_path(LexicalPath());
update_title();
});
@@ -333,7 +333,7 @@ TextEditorWidget::TextEditorWidget()
}
m_document_dirty = false;
- set_path(FileSystemPath(save_path.value()));
+ set_path(LexicalPath(save_path.value()));
dbg() << "Wrote document to " << save_path.value();
});
@@ -465,11 +465,11 @@ TextEditorWidget::~TextEditorWidget()
{
}
-void TextEditorWidget::set_path(const FileSystemPath& file)
+void TextEditorWidget::set_path(const LexicalPath& lexical_path)
{
- m_path = file.string();
- m_name = file.title();
- m_extension = file.extension();
+ m_path = lexical_path.string();
+ m_name = lexical_path.title();
+ m_extension = lexical_path.extension();
if (m_extension == "cpp" || m_extension == "h") {
m_cpp_highlight->activate();
@@ -508,7 +508,7 @@ void TextEditorWidget::open_sesame(const String& path)
m_document_dirty = false;
m_document_opening = true;
- set_path(FileSystemPath(path));
+ set_path(LexicalPath(path));
m_editor->set_focus(true);
}
diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h
index b52e826b79..c3bdcd4482 100644
--- a/Applications/TextEditor/TextEditorWidget.h
+++ b/Applications/TextEditor/TextEditorWidget.h
@@ -26,14 +26,15 @@
#pragma once
-#include <AK/FileSystemPath.h>
#include <AK/Function.h>
+#include <AK/LexicalPath.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
#include <LibGUI/TextEditor.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibWeb/Forward.h>
+
class TextEditorWidget final : public GUI::Widget {
C_OBJECT(TextEditorWidget)
public:
@@ -47,7 +48,7 @@ public:
private:
TextEditorWidget();
- void set_path(const FileSystemPath& file);
+ void set_path(const LexicalPath& file);
void update_title();
void update_markdown_preview();