mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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.
This commit is contained in:
parent
f746bbda17
commit
602c3fdb3a
Notes:
sideshowbarker
2024-07-19 06:06:58 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/602c3fdb3a0 Pull-request: https://github.com/SerenityOS/serenity/pull/2394 Reviewed-by: https://github.com/awesomekling ✅
44 changed files with 174 additions and 181 deletions
|
@ -24,21 +24,21 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
FileSystemPath::FileSystemPath(const StringView& s)
|
||||
LexicalPath::LexicalPath(const StringView& s)
|
||||
: m_string(s)
|
||||
{
|
||||
canonicalize();
|
||||
m_is_valid = true;
|
||||
}
|
||||
|
||||
void FileSystemPath::canonicalize()
|
||||
void LexicalPath::canonicalize()
|
||||
{
|
||||
if (m_string.is_empty()) {
|
||||
m_parts.clear();
|
||||
|
@ -105,14 +105,14 @@ void FileSystemPath::canonicalize()
|
|||
m_string = builder.to_string();
|
||||
}
|
||||
|
||||
bool FileSystemPath::has_extension(const StringView& extension) const
|
||||
bool LexicalPath::has_extension(const StringView& extension) const
|
||||
{
|
||||
return m_string.ends_with(extension, CaseSensitivity::CaseInsensitive);
|
||||
}
|
||||
|
||||
String canonicalized_path(const StringView& path)
|
||||
String LexicalPath::canonicalized_path(const StringView& path)
|
||||
{
|
||||
return FileSystemPath(path).string();
|
||||
return LexicalPath(path).string();
|
||||
}
|
||||
|
||||
}
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
class FileSystemPath {
|
||||
class LexicalPath {
|
||||
public:
|
||||
FileSystemPath() {}
|
||||
explicit FileSystemPath(const StringView&);
|
||||
LexicalPath() { }
|
||||
explicit LexicalPath(const StringView&);
|
||||
|
||||
bool is_valid() const { return m_is_valid; }
|
||||
bool is_absolute() const { return m_is_absolute; }
|
||||
|
@ -49,6 +49,8 @@ public:
|
|||
|
||||
bool has_extension(const StringView&) const;
|
||||
|
||||
static String canonicalized_path(const StringView&);
|
||||
|
||||
private:
|
||||
void canonicalize();
|
||||
|
||||
|
@ -62,9 +64,6 @@ private:
|
|||
bool m_is_absolute { false };
|
||||
};
|
||||
|
||||
String canonicalized_path(const StringView&);
|
||||
|
||||
};
|
||||
|
||||
using AK::canonicalized_path;
|
||||
using AK::FileSystemPath;
|
||||
using AK::LexicalPath;
|
|
@ -26,17 +26,17 @@
|
|||
|
||||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
|
||||
TEST_CASE(construct)
|
||||
{
|
||||
EXPECT_EQ(FileSystemPath().is_valid(), false);
|
||||
EXPECT_EQ(LexicalPath().is_valid(), false);
|
||||
}
|
||||
|
||||
TEST_CASE(basic)
|
||||
{
|
||||
FileSystemPath path("/abc/def/ghi.txt");
|
||||
LexicalPath path("/abc/def/ghi.txt");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.basename(), "ghi.txt");
|
||||
EXPECT_EQ(path.title(), "ghi");
|
||||
|
@ -48,8 +48,8 @@ TEST_CASE(basic)
|
|||
|
||||
TEST_CASE(dotdot_coalescing)
|
||||
{
|
||||
EXPECT_EQ(FileSystemPath("/home/user/../../not/home").string(), "/not/home");
|
||||
EXPECT_EQ(FileSystemPath("/../../../../").string(), "/");
|
||||
EXPECT_EQ(LexicalPath("/home/user/../../not/home").string(), "/not/home");
|
||||
EXPECT_EQ(LexicalPath("/../../../../").string(), "/");
|
||||
}
|
||||
|
||||
// Temporarily disabled, as they were broken by commit a3e4dfdf9859a9b955bf4728328f740a47de5851
|
||||
|
@ -59,21 +59,21 @@ TEST_CASE(dotdot_coalescing)
|
|||
TEST_CASE(relative_paths)
|
||||
{
|
||||
{
|
||||
FileSystemPath path("simple");
|
||||
LexicalPath path("simple");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), "./simple");
|
||||
EXPECT_EQ(path.parts().size(), 2u);
|
||||
EXPECT_EQ(path.basename(), "simple");
|
||||
}
|
||||
{
|
||||
FileSystemPath path("a/relative/path");
|
||||
LexicalPath path("a/relative/path");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), "./a/relative/path");
|
||||
EXPECT_EQ(path.parts().size(), 4u);
|
||||
EXPECT_EQ(path.basename(), "path");
|
||||
}
|
||||
{
|
||||
FileSystemPath path("./././foo");
|
||||
LexicalPath path("./././foo");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), "./foo");
|
||||
EXPECT_EQ(path.parts().size(), 2u);
|
||||
|
@ -81,7 +81,7 @@ TEST_CASE(relative_paths)
|
|||
}
|
||||
|
||||
{
|
||||
FileSystemPath path(".");
|
||||
LexicalPath path(".");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.string(), ".");
|
||||
EXPECT_EQ(path.parts().size(), 1u);
|
||||
|
@ -123,4 +123,4 @@ TEST_CASE(has_extension)
|
|||
|
||||
#endif
|
||||
|
||||
TEST_MAIN(FileSystemPath)
|
||||
TEST_MAIN(LexicalPath)
|
18
AK/URL.cpp
18
AK/URL.cpp
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/URL.h>
|
||||
|
||||
|
@ -314,22 +314,22 @@ URL URL::complete_url(const String& string) const
|
|||
}
|
||||
|
||||
StringBuilder builder;
|
||||
FileSystemPath fspath(path());
|
||||
LexicalPath lexical_path(path());
|
||||
builder.append('/');
|
||||
|
||||
bool document_url_ends_in_slash = path()[path().length() - 1] == '/';
|
||||
|
||||
for (size_t i = 0; i < fspath.parts().size(); ++i) {
|
||||
if (i == fspath.parts().size() - 1 && !document_url_ends_in_slash)
|
||||
for (size_t i = 0; i < lexical_path.parts().size(); ++i) {
|
||||
if (i == lexical_path.parts().size() - 1 && !document_url_ends_in_slash)
|
||||
break;
|
||||
builder.append(fspath.parts()[i]);
|
||||
builder.append(lexical_path.parts()[i]);
|
||||
builder.append('/');
|
||||
}
|
||||
builder.append(string);
|
||||
auto built = builder.to_string();
|
||||
fspath = FileSystemPath(built);
|
||||
lexical_path = LexicalPath(built);
|
||||
|
||||
built = fspath.string();
|
||||
built = lexical_path.string();
|
||||
if (string.ends_with('/') && !built.ends_with('/')) {
|
||||
builder.clear();
|
||||
builder.append(built);
|
||||
|
@ -399,7 +399,7 @@ URL URL::create_with_url_or_path(const String& url_or_path)
|
|||
if (url.is_valid())
|
||||
return url;
|
||||
|
||||
String path = canonicalized_path(url_or_path);
|
||||
String path = LexicalPath::canonicalized_path(url_or_path);
|
||||
return URL::create_with_file_protocol(path);
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ String URL::basename() const
|
|||
{
|
||||
if (!m_valid)
|
||||
return {};
|
||||
return FileSystemPath(m_path).basename();
|
||||
return LexicalPath(m_path).basename();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include "DirectoryView.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/URL.h>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "Editor.h"
|
||||
#include "EditorWrapper.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -137,7 +137,7 @@ static HashMap<String, String>& man_paths()
|
|||
Core::DirIterator it("/usr/share/man/man2", Core::DirIterator::Flags::SkipDots);
|
||||
while (it.has_next()) {
|
||||
auto path = String::format("/usr/share/man/man2/%s", it.next_path().characters());
|
||||
auto title = FileSystemPath(path).title();
|
||||
auto title = LexicalPath(path).title();
|
||||
paths.set(title, path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "Project.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
|
@ -169,7 +169,7 @@ private:
|
|||
Project::Project(const String& path, Vector<String>&& filenames)
|
||||
: m_path(path)
|
||||
{
|
||||
m_name = FileSystemPath(m_path).basename();
|
||||
m_name = LexicalPath(m_path).basename();
|
||||
|
||||
m_file_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"));
|
||||
m_cplusplus_icon = GUI::Icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"));
|
||||
|
@ -283,7 +283,7 @@ bool Project::save()
|
|||
ProjectFile* Project::get_file(const String& filename)
|
||||
{
|
||||
for (auto& file : m_files) {
|
||||
if (FileSystemPath(file.name()).string() == FileSystemPath(filename).string())
|
||||
if (LexicalPath(file.name()).string() == LexicalPath(filename).string())
|
||||
return &file;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -307,7 +307,7 @@ void Project::rebuild_tree()
|
|||
root->type = ProjectTreeNode::Type::Project;
|
||||
|
||||
for (auto& file : m_files) {
|
||||
FileSystemPath path(file.name());
|
||||
LexicalPath path(file.name());
|
||||
ProjectTreeNode* current = root.ptr();
|
||||
StringBuilder partial_path;
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ int main(int argc, char** argv)
|
|||
|
||||
String message;
|
||||
if (files.size() == 1) {
|
||||
message = String::format("Really remove %s from the project?", FileSystemPath(files[0]).basename().characters());
|
||||
message = String::format("Really remove %s from the project?", LexicalPath(files[0]).basename().characters());
|
||||
} else {
|
||||
message = String::format("Really remove %d files from the project?", files.size());
|
||||
}
|
||||
|
@ -711,8 +711,8 @@ void run(TerminalWrapper& wrapper)
|
|||
|
||||
void open_project(String filename)
|
||||
{
|
||||
FileSystemPath path(filename);
|
||||
if (chdir(path.dirname().characters()) < 0) {
|
||||
LexicalPath lexical_path(filename);
|
||||
if (chdir(lexical_path.dirname().characters()) < 0) {
|
||||
perror("chdir");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -121,10 +121,10 @@ set(KERNEL_SOURCES
|
|||
)
|
||||
|
||||
set(AK_SOURCES
|
||||
../AK/FileSystemPath.cpp
|
||||
../AK/FlyString.cpp
|
||||
../AK/JsonParser.cpp
|
||||
../AK/JsonValue.cpp
|
||||
../AK/LexicalPath.cpp
|
||||
../AK/LogStream.cpp
|
||||
../AK/String.cpp
|
||||
../AK/StringBuilder.cpp
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Kernel/Devices/BlockDevice.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
|
@ -291,7 +291,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
|
|||
if (!parent_inode.metadata().may_write(*Process::current))
|
||||
return KResult(-EACCES);
|
||||
|
||||
FileSystemPath p(path);
|
||||
LexicalPath p(path);
|
||||
dbg() << "VFS::mknod: '" << p.basename() << "' mode=" << mode << " dev=" << dev << " in " << parent_inode.identifier();
|
||||
return parent_inode.fs().create_inode(parent_inode.identifier(), p.basename(), mode, 0, dev, Process::current->uid(), Process::current->gid()).result();
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
|
|||
auto& parent_inode = parent_custody.inode();
|
||||
if (!parent_inode.metadata().may_write(*Process::current))
|
||||
return KResult(-EACCES);
|
||||
FileSystemPath p(path);
|
||||
LexicalPath p(path);
|
||||
#ifdef VFS_DEBUG
|
||||
dbg() << "VFS::create: '" << p.basename() << "' in " << parent_inode.identifier();
|
||||
#endif
|
||||
|
@ -349,7 +349,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
|
|||
if (!parent_inode.metadata().may_write(*Process::current))
|
||||
return KResult(-EACCES);
|
||||
|
||||
FileSystemPath p(path);
|
||||
LexicalPath p(path);
|
||||
#ifdef VFS_DEBUG
|
||||
dbg() << "VFS::mkdir: '" << p.basename() << "' in " << parent_inode.identifier();
|
||||
#endif
|
||||
|
@ -449,7 +449,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
|||
return KResult(-EACCES);
|
||||
}
|
||||
|
||||
auto new_basename = FileSystemPath(new_path).basename();
|
||||
auto new_basename = LexicalPath(new_path).basename();
|
||||
|
||||
if (!new_custody_or_error.is_error()) {
|
||||
auto& new_custody = *new_custody_or_error.value();
|
||||
|
@ -472,7 +472,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
|||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
result = old_parent_inode.remove_child(FileSystemPath(old_path).basename());
|
||||
result = old_parent_inode.remove_child(LexicalPath(old_path).basename());
|
||||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
|
@ -555,7 +555,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
|||
if (old_inode.is_directory())
|
||||
return KResult(-EPERM);
|
||||
|
||||
return parent_inode.add_child(old_inode.identifier(), FileSystemPath(new_path).basename(), old_inode.mode());
|
||||
return parent_inode.add_child(old_inode.identifier(), LexicalPath(new_path).basename(), old_inode.mode());
|
||||
}
|
||||
|
||||
KResult VFS::unlink(StringView path, Custody& base)
|
||||
|
@ -579,7 +579,7 @@ KResult VFS::unlink(StringView path, Custody& base)
|
|||
return KResult(-EACCES);
|
||||
}
|
||||
|
||||
auto result = parent_inode.remove_child(FileSystemPath(path).basename());
|
||||
auto result = parent_inode.remove_child(LexicalPath(path).basename());
|
||||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
|
@ -600,7 +600,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
|
|||
if (!parent_inode.metadata().may_write(*Process::current))
|
||||
return KResult(-EACCES);
|
||||
|
||||
FileSystemPath p(linkpath);
|
||||
LexicalPath p(linkpath);
|
||||
dbg() << "VFS::symlink: '" << p.basename() << "' (-> '" << target << "') in " << parent_inode.identifier();
|
||||
auto inode_or_error = parent_inode.fs().create_inode(parent_inode.identifier(), p.basename(), 0120644, 0, 0, Process::current->uid(), Process::current->gid());
|
||||
if (inode_or_error.is_error())
|
||||
|
@ -649,7 +649,7 @@ KResult VFS::rmdir(StringView path, Custody& base)
|
|||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
return parent_inode.remove_child(FileSystemPath(path).basename());
|
||||
return parent_inode.remove_child(LexicalPath(path).basename());
|
||||
}
|
||||
|
||||
RefPtr<Inode> VFS::get_inode(InodeIdentifier inode_id)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/Demangle.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
|
@ -70,9 +70,9 @@ void* dlopen(const char* filename, int flags)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
FileSystemPath file_path(filename);
|
||||
auto basename = LexicalPath(filename).basename();
|
||||
|
||||
auto existing_elf_object = g_elf_objects.get(file_path.basename());
|
||||
auto existing_elf_object = g_elf_objects.get(basename);
|
||||
if (existing_elf_object.has_value()) {
|
||||
return const_cast<ELF::DynamicLoader*>(existing_elf_object.value());
|
||||
}
|
||||
|
@ -105,11 +105,11 @@ void* dlopen(const char* filename, int flags)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
g_elf_objects.set(file_path.basename(), move(loader));
|
||||
g_elf_objects.set(basename, move(loader));
|
||||
g_dlerror_msg = "Successfully loaded ELF object.";
|
||||
|
||||
// we have one refcount already
|
||||
return const_cast<ELF::DynamicLoader*>(g_elf_objects.get(file_path.basename()).value());
|
||||
return const_cast<ELF::DynamicLoader*>(g_elf_objects.get(basename).value());
|
||||
}
|
||||
|
||||
void* dlsym(void* handle, const char* symbol_name)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
|
@ -37,12 +37,12 @@ namespace Core {
|
|||
String StandardPaths::home_directory()
|
||||
{
|
||||
if (auto* home_env = getenv("HOME"))
|
||||
return canonicalized_path(home_env);
|
||||
return LexicalPath::canonicalized_path(home_env);
|
||||
|
||||
auto* pwd = getpwuid(getuid());
|
||||
String path = pwd ? pwd->pw_dir : "/";
|
||||
endpwent();
|
||||
return canonicalized_path(path);
|
||||
return LexicalPath::canonicalized_path(path);
|
||||
}
|
||||
|
||||
String StandardPaths::desktop_directory()
|
||||
|
@ -50,7 +50,7 @@ String StandardPaths::desktop_directory()
|
|||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Desktop");
|
||||
return canonicalized_path(builder.to_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
String StandardPaths::downloads_directory()
|
||||
|
@ -58,7 +58,7 @@ String StandardPaths::downloads_directory()
|
|||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Downloads");
|
||||
return canonicalized_path(builder.to_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
String StandardPaths::tempfile_directory()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Utf32View.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
|
@ -43,10 +43,10 @@ static Vector<u32> supported_emoji_codepoints()
|
|||
Core::DirIterator dt("/res/emoji", Core::DirIterator::SkipDots);
|
||||
while (dt.has_next()) {
|
||||
auto filename = dt.next_path();
|
||||
auto fspath = FileSystemPath(filename);
|
||||
if (fspath.extension() != "png")
|
||||
auto lexical_path = LexicalPath(filename);
|
||||
if (lexical_path.extension() != "png")
|
||||
continue;
|
||||
auto basename = fspath.basename();
|
||||
auto basename = lexical_path.basename();
|
||||
if (!basename.starts_with("U+"))
|
||||
continue;
|
||||
u32 codepoint = strtoul(basename.characters() + 2, nullptr, 16);
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -142,9 +142,9 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
auto mkdir_action = Action::create("New directory...", Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
|
||||
auto& input_box = add<InputBox>("Enter name:", "New directory");
|
||||
if (input_box.exec() == InputBox::ExecOK && !input_box.text_value().is_empty()) {
|
||||
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
||||
m_model->root_path().characters(),
|
||||
input_box.text_value().characters()))
|
||||
auto new_dir_path = LexicalPath(String::format("%s/%s",
|
||||
m_model->root_path().characters(),
|
||||
input_box.text_value().characters()))
|
||||
.string();
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
|
@ -196,7 +196,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
auto& filter_model = (SortingProxyModel&)*m_view->model();
|
||||
auto local_index = filter_model.map_to_target(index);
|
||||
const FileSystemModel::Node& node = m_model->node(local_index);
|
||||
FileSystemPath path { node.full_path(m_model) };
|
||||
LexicalPath path { node.full_path(m_model) };
|
||||
|
||||
clear_preview();
|
||||
|
||||
|
@ -267,7 +267,7 @@ FilePicker::~FilePicker()
|
|||
{
|
||||
}
|
||||
|
||||
void FilePicker::set_preview(const FileSystemPath& path)
|
||||
void FilePicker::set_preview(const LexicalPath& path)
|
||||
{
|
||||
if (path.has_extension(".png")) {
|
||||
auto bitmap = Gfx::Bitmap::load_from_file(path.string());
|
||||
|
@ -292,7 +292,7 @@ void FilePicker::clear_preview()
|
|||
|
||||
void FilePicker::on_file_return()
|
||||
{
|
||||
FileSystemPath path(String::format("%s/%s", m_model->root_path().characters(), m_filename_textbox->text().characters()));
|
||||
LexicalPath path(String::format("%s/%s", m_model->root_path().characters(), m_filename_textbox->text().characters()));
|
||||
|
||||
if (FilePicker::file_exists(path.string()) && m_mode == Mode::Save) {
|
||||
auto result = MessageBox::show("File already exists, overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
|
@ -45,10 +45,10 @@ public:
|
|||
|
||||
virtual ~FilePicker() override;
|
||||
|
||||
FileSystemPath selected_file() const { return m_selected_file; }
|
||||
LexicalPath selected_file() const { return m_selected_file; }
|
||||
|
||||
private:
|
||||
void set_preview(const FileSystemPath&);
|
||||
void set_preview(const LexicalPath&);
|
||||
void clear_preview();
|
||||
void on_file_return();
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
|||
|
||||
RefPtr<MultiView> m_view;
|
||||
NonnullRefPtr<FileSystemModel> m_model;
|
||||
FileSystemPath m_selected_file;
|
||||
LexicalPath m_selected_file;
|
||||
|
||||
RefPtr<TextBox> m_filename_textbox;
|
||||
RefPtr<Label> m_preview_image_label;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibGUI/FileSystemModel.h>
|
||||
|
@ -162,24 +162,24 @@ String FileSystemModel::Node::full_path(const FileSystemModel& model) const
|
|||
}
|
||||
builder.append('/');
|
||||
builder.append(name);
|
||||
return canonicalized_path(builder.to_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
ModelIndex FileSystemModel::index(const StringView& path, int column) const
|
||||
{
|
||||
FileSystemPath canonical_path(path);
|
||||
LexicalPath lexical_path(path);
|
||||
const Node* node = m_root;
|
||||
if (canonical_path.string() == "/")
|
||||
if (lexical_path.string() == "/")
|
||||
return m_root->index(*this, column);
|
||||
for (size_t i = 0; i < canonical_path.parts().size(); ++i) {
|
||||
auto& part = canonical_path.parts()[i];
|
||||
for (size_t i = 0; i < lexical_path.parts().size(); ++i) {
|
||||
auto& part = lexical_path.parts()[i];
|
||||
bool found = false;
|
||||
for (auto& child : node->children) {
|
||||
if (child.name == part) {
|
||||
const_cast<Node&>(child).reify_if_needed(*this);
|
||||
node = &child;
|
||||
found = true;
|
||||
if (i == canonical_path.parts().size() - 1)
|
||||
if (i == lexical_path.parts().size() - 1)
|
||||
return child.index(*this, column);
|
||||
break;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ String FileSystemModel::full_path(const ModelIndex& index) const
|
|||
}
|
||||
|
||||
FileSystemModel::FileSystemModel(const StringView& root_path, Mode mode)
|
||||
: m_root_path(canonicalized_path(root_path))
|
||||
: m_root_path(LexicalPath::canonicalized_path(root_path))
|
||||
, m_mode(mode)
|
||||
{
|
||||
m_directory_icon = Icon::default_icon("filetype-folder");
|
||||
|
@ -284,7 +284,7 @@ static String permission_string(mode_t mode)
|
|||
|
||||
void FileSystemModel::set_root_path(const StringView& root_path)
|
||||
{
|
||||
m_root_path = canonicalized_path(root_path);
|
||||
m_root_path = LexicalPath::canonicalized_path(root_path);
|
||||
update();
|
||||
|
||||
if (m_root->has_error()) {
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <AK/BufferStream.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <LibGfx/GIFLoader.h>
|
||||
|
@ -99,7 +99,7 @@ RefPtr<Gfx::Bitmap> load_gif(const StringView& path)
|
|||
GIFImageDecoderPlugin gif_decoder((const u8*)mapped_file.data(), mapped_file.size());
|
||||
auto bitmap = gif_decoder.bitmap();
|
||||
if (bitmap)
|
||||
bitmap->set_mmap_name(String::format("Gfx::Bitmap [%dx%d] - Decoded GIF: %s", bitmap->width(), bitmap->height(), canonicalized_path(path).characters()));
|
||||
bitmap->set_mmap_name(String::format("Gfx::Bitmap [%dx%d] - Decoded GIF: %s", bitmap->width(), bitmap->height(), LexicalPath::canonicalized_path(path).characters()));
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
@ -536,7 +536,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size)
|
|||
m_context->data_size = size;
|
||||
}
|
||||
|
||||
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() {}
|
||||
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { }
|
||||
|
||||
Size GIFImageDecoderPlugin::size()
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/NetworkOrdered.h>
|
||||
#include <LibCore/puff.h>
|
||||
|
@ -193,7 +193,7 @@ RefPtr<Gfx::Bitmap> load_png(const StringView& path)
|
|||
return nullptr;
|
||||
auto bitmap = load_png_impl((const u8*)mapped_file.data(), mapped_file.size());
|
||||
if (bitmap)
|
||||
bitmap->set_mmap_name(String::format("Gfx::Bitmap [%dx%d] - Decoded PNG: %s", bitmap->width(), bitmap->height(), canonicalized_path(path).characters()));
|
||||
bitmap->set_mmap_name(String::format("Gfx::Bitmap [%dx%d] - Decoded PNG: %s", bitmap->width(), bitmap->height(), LexicalPath::canonicalized_path(path).characters()));
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <AK/BinarySearch.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "TerminalWidget.h"
|
||||
#include "XtermColors.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
@ -843,7 +843,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
|||
// Then add them to the context menu.
|
||||
// FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
|
||||
for (auto& handler : handlers) {
|
||||
auto af_path = String::format("/res/apps/%s.af", FileSystemPath(handler).basename().characters());
|
||||
auto af_path = String::format("/res/apps/%s.af", LexicalPath(handler).basename().characters());
|
||||
auto af = Core::ConfigFile::open(af_path);
|
||||
auto handler_name = af->read_entry("App", "Name", handler);
|
||||
auto handler_icon = af->read_entry("Icons", "16x16", {});
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
|
@ -377,7 +377,7 @@ static RefPtr<Document> create_image_document(const ByteBuffer& data, const URL&
|
|||
auto title_element = create_element(document, "title");
|
||||
head_element->append_child(title_element);
|
||||
|
||||
auto basename = FileSystemPath(url.path()).basename();
|
||||
auto basename = LexicalPath(url.path()).basename();
|
||||
auto title_text = adopt(*new Text(document, String::format("%s [%dx%d]", basename.characters(), bitmap->width(), bitmap->height())));
|
||||
title_element->append_child(title_text);
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
*/
|
||||
|
||||
#include "Launcher.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <stdio.h>
|
||||
|
@ -191,7 +191,7 @@ Vector<String> Launcher::handlers_for_path(const String& path)
|
|||
if (S_ISDIR(st.st_mode))
|
||||
return { "/bin/FileManager" };
|
||||
|
||||
auto extension = FileSystemPath(path).extension().to_lowercase();
|
||||
auto extension = LexicalPath(path).extension().to_lowercase();
|
||||
|
||||
return handlers_for(extension, m_file_handlers, [](auto& handler, auto& key) {
|
||||
return handler.file_types.contains(key);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "ShutdownDialog.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
|
@ -171,7 +171,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
|
|||
while (dt.has_next()) {
|
||||
auto theme_name = dt.next_path();
|
||||
auto theme_path = String::format("/res/themes/%s", theme_name.characters());
|
||||
g_themes.append({ FileSystemPath(theme_name).title(), theme_path });
|
||||
g_themes.append({ LexicalPath(theme_name).title(), theme_path });
|
||||
}
|
||||
quick_sort(g_themes, [](auto& a, auto& b) { return a.name < b.name; });
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "Client.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
|
@ -82,7 +82,7 @@ void Client::handle_request(ByteBuffer raw_request)
|
|||
return;
|
||||
}
|
||||
|
||||
auto requested_path = canonicalized_path(request.resource());
|
||||
auto requested_path = LexicalPath::canonicalized_path(request.resource());
|
||||
dbg() << "Canonical requested path: '" << requested_path << "'";
|
||||
|
||||
StringBuilder path_builder;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibGfx/Font.h>
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
#include "Shell.h"
|
||||
#include "Execution.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -222,12 +222,12 @@ int Shell::builtin_cd(int argc, const char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
FileSystemPath canonical_path(new_path);
|
||||
if (!canonical_path.is_valid()) {
|
||||
printf("FileSystemPath failed to canonicalize '%s'\n", new_path.characters());
|
||||
LexicalPath lexical_path(new_path);
|
||||
if (!lexical_path.is_valid()) {
|
||||
printf("LexicalPath failed to canonicalize '%s'\n", new_path.characters());
|
||||
return 1;
|
||||
}
|
||||
const char* path = canonical_path.string().characters();
|
||||
const char* path = lexical_path.string().characters();
|
||||
|
||||
struct stat st;
|
||||
int rc = stat(path, &st);
|
||||
|
@ -245,7 +245,7 @@ int Shell::builtin_cd(int argc, const char** argv)
|
|||
return 1;
|
||||
}
|
||||
setenv("OLDPWD", cwd.characters(), 1);
|
||||
cwd = canonical_path.string();
|
||||
cwd = lexical_path.string();
|
||||
setenv("PWD", cwd.characters(), 1);
|
||||
return 0;
|
||||
}
|
||||
|
@ -612,13 +612,13 @@ int Shell::builtin_popd(int argc, const char** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
FileSystemPath canonical_path(path.characters());
|
||||
if (!canonical_path.is_valid()) {
|
||||
fprintf(stderr, "FileSystemPath failed to canonicalize '%s'\n", path.characters());
|
||||
LexicalPath lexical_path(path.characters());
|
||||
if (!lexical_path.is_valid()) {
|
||||
fprintf(stderr, "LexicalPath failed to canonicalize '%s'\n", path.characters());
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* real_path = canonical_path.string().characters();
|
||||
const char* real_path = lexical_path.string().characters();
|
||||
|
||||
struct stat st;
|
||||
int rc = stat(real_path, &st);
|
||||
|
@ -639,7 +639,7 @@ int Shell::builtin_popd(int argc, const char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
cwd = canonical_path.string();
|
||||
cwd = lexical_path.string();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -699,13 +699,13 @@ int Shell::builtin_pushd(int argc, const char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
FileSystemPath canonical_path(path_builder.to_string());
|
||||
if (!canonical_path.is_valid()) {
|
||||
fprintf(stderr, "FileSystemPath failed to canonicalize '%s'\n", path_builder.to_string().characters());
|
||||
LexicalPath lexical_path(path_builder.to_string());
|
||||
if (!lexical_path.is_valid()) {
|
||||
fprintf(stderr, "LexicalPath failed to canonicalize '%s'\n", path_builder.to_string().characters());
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* real_path = canonical_path.string().characters();
|
||||
const char* real_path = lexical_path.string().characters();
|
||||
|
||||
struct stat st;
|
||||
int rc = stat(real_path, &st);
|
||||
|
@ -726,7 +726,7 @@ int Shell::builtin_pushd(int argc, const char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
cwd = canonical_path.string();
|
||||
cwd = lexical_path.string();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1662,7 +1662,7 @@ Vector<Line::CompletionSuggestion> Shell::complete(const Line::Editor& editor)
|
|||
path = token.substring(0, last_slash + 1);
|
||||
if (path[0] != '/')
|
||||
path = String::format("%s/%s", cwd.characters(), path.characters());
|
||||
path = canonicalized_path(path);
|
||||
path = LexicalPath::canonicalized_path(path);
|
||||
token = token.substring(last_slash + 1, token.length() - last_slash - 1);
|
||||
} else {
|
||||
// We have no slashes, so the directory to search is the current
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -38,6 +38,6 @@ int main(int argc, char** argv)
|
|||
printf("usage: basename <path>\n");
|
||||
return 1;
|
||||
}
|
||||
printf("%s\n", FileSystemPath(argv[1]).basename().characters());
|
||||
printf("%s\n", LexicalPath(argv[1]).basename().characters());
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -112,7 +112,7 @@ bool copy_file(String src_path, String dst_path, struct stat src_stat, int src_f
|
|||
StringBuilder builder;
|
||||
builder.append(dst_path);
|
||||
builder.append('/');
|
||||
builder.append(FileSystemPath(src_path).basename());
|
||||
builder.append(LexicalPath(src_path).basename());
|
||||
dst_path = builder.to_string();
|
||||
dst_fd = creat(dst_path.characters(), 0666);
|
||||
if (dst_fd < 0) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -164,7 +164,7 @@ int print_space_usage(const String& path, const DuOption& du_option, int max_dep
|
|||
}
|
||||
}
|
||||
|
||||
const auto basename = FileSystemPath(path).basename();
|
||||
const auto basename = LexicalPath(path).basename();
|
||||
for (const auto& pattern : du_option.excluded_patterns) {
|
||||
if (basename.matches(pattern, CaseSensitivity::CaseSensitive))
|
||||
return 0;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -52,18 +52,18 @@ int main(int argc, char** argv)
|
|||
bool has_errors = false;
|
||||
|
||||
for (auto& directory : directories) {
|
||||
FileSystemPath canonical_path(directory);
|
||||
LexicalPath lexical_path(directory);
|
||||
if (!create_parents) {
|
||||
if (mkdir(canonical_path.string().characters(), mode) < 0) {
|
||||
if (mkdir(lexical_path.string().characters(), mode) < 0) {
|
||||
perror("mkdir");
|
||||
has_errors = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
StringBuilder path_builder;
|
||||
if (canonical_path.is_absolute())
|
||||
if (lexical_path.is_absolute())
|
||||
path_builder.append("/");
|
||||
for (auto& part : canonical_path.parts()) {
|
||||
for (auto& part : lexical_path.parts()) {
|
||||
path_builder.append(part);
|
||||
auto path = path_builder.build();
|
||||
struct stat st;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <stdio.h>
|
||||
|
@ -56,7 +56,7 @@ int main(int argc, char** argv)
|
|||
|
||||
String combined_new_path;
|
||||
if (rc == 0 && S_ISDIR(st.st_mode)) {
|
||||
auto old_basename = FileSystemPath(old_path).basename();
|
||||
auto old_basename = LexicalPath(old_path).basename();
|
||||
combined_new_path = String::format("%s/%s", new_path, old_basename.characters());
|
||||
new_path = combined_new_path.characters();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Vector.h>
|
||||
|
|
Loading…
Reference in a new issue