mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:02:45 +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
					
				
					 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. |  * 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/StringBuilder.h> | ||||||
| #include <AK/StringView.h> | #include <AK/StringView.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| FileSystemPath::FileSystemPath(const StringView& s) | LexicalPath::LexicalPath(const StringView& s) | ||||||
|     : m_string(s) |     : m_string(s) | ||||||
| { | { | ||||||
|     canonicalize(); |     canonicalize(); | ||||||
|     m_is_valid = true; |     m_is_valid = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void FileSystemPath::canonicalize() | void LexicalPath::canonicalize() | ||||||
| { | { | ||||||
|     if (m_string.is_empty()) { |     if (m_string.is_empty()) { | ||||||
|         m_parts.clear(); |         m_parts.clear(); | ||||||
|  | @ -105,14 +105,14 @@ void FileSystemPath::canonicalize() | ||||||
|     m_string = builder.to_string(); |     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); |     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 { | namespace AK { | ||||||
| 
 | 
 | ||||||
| class FileSystemPath { | class LexicalPath { | ||||||
| public: | public: | ||||||
|     FileSystemPath() {} |     LexicalPath() { } | ||||||
|     explicit FileSystemPath(const StringView&); |     explicit LexicalPath(const StringView&); | ||||||
| 
 | 
 | ||||||
|     bool is_valid() const { return m_is_valid; } |     bool is_valid() const { return m_is_valid; } | ||||||
|     bool is_absolute() const { return m_is_absolute; } |     bool is_absolute() const { return m_is_absolute; } | ||||||
|  | @ -49,6 +49,8 @@ public: | ||||||
| 
 | 
 | ||||||
|     bool has_extension(const StringView&) const; |     bool has_extension(const StringView&) const; | ||||||
| 
 | 
 | ||||||
|  |     static String canonicalized_path(const StringView&); | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     void canonicalize(); |     void canonicalize(); | ||||||
| 
 | 
 | ||||||
|  | @ -62,9 +64,6 @@ private: | ||||||
|     bool m_is_absolute { false }; |     bool m_is_absolute { false }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| String canonicalized_path(const StringView&); |  | ||||||
| 
 |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| using AK::canonicalized_path; | using AK::LexicalPath; | ||||||
| using AK::FileSystemPath; |  | ||||||
|  | @ -26,17 +26,17 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/TestSuite.h> | #include <AK/TestSuite.h> | ||||||
| 
 | 
 | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| 
 | 
 | ||||||
| TEST_CASE(construct) | TEST_CASE(construct) | ||||||
| { | { | ||||||
|     EXPECT_EQ(FileSystemPath().is_valid(), false); |     EXPECT_EQ(LexicalPath().is_valid(), false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_CASE(basic) | TEST_CASE(basic) | ||||||
| { | { | ||||||
|     FileSystemPath path("/abc/def/ghi.txt"); |     LexicalPath path("/abc/def/ghi.txt"); | ||||||
|     EXPECT_EQ(path.is_valid(), true); |     EXPECT_EQ(path.is_valid(), true); | ||||||
|     EXPECT_EQ(path.basename(), "ghi.txt"); |     EXPECT_EQ(path.basename(), "ghi.txt"); | ||||||
|     EXPECT_EQ(path.title(), "ghi"); |     EXPECT_EQ(path.title(), "ghi"); | ||||||
|  | @ -48,8 +48,8 @@ TEST_CASE(basic) | ||||||
| 
 | 
 | ||||||
| TEST_CASE(dotdot_coalescing) | TEST_CASE(dotdot_coalescing) | ||||||
| { | { | ||||||
|     EXPECT_EQ(FileSystemPath("/home/user/../../not/home").string(), "/not/home"); |     EXPECT_EQ(LexicalPath("/home/user/../../not/home").string(), "/not/home"); | ||||||
|     EXPECT_EQ(FileSystemPath("/../../../../").string(), "/"); |     EXPECT_EQ(LexicalPath("/../../../../").string(), "/"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Temporarily disabled, as they were broken by commit a3e4dfdf9859a9b955bf4728328f740a47de5851
 | // Temporarily disabled, as they were broken by commit a3e4dfdf9859a9b955bf4728328f740a47de5851
 | ||||||
|  | @ -59,21 +59,21 @@ TEST_CASE(dotdot_coalescing) | ||||||
| TEST_CASE(relative_paths) | TEST_CASE(relative_paths) | ||||||
| { | { | ||||||
|     { |     { | ||||||
|         FileSystemPath path("simple"); |         LexicalPath path("simple"); | ||||||
|         EXPECT_EQ(path.is_valid(), true); |         EXPECT_EQ(path.is_valid(), true); | ||||||
|         EXPECT_EQ(path.string(), "./simple"); |         EXPECT_EQ(path.string(), "./simple"); | ||||||
|         EXPECT_EQ(path.parts().size(), 2u); |         EXPECT_EQ(path.parts().size(), 2u); | ||||||
|         EXPECT_EQ(path.basename(), "simple"); |         EXPECT_EQ(path.basename(), "simple"); | ||||||
|     } |     } | ||||||
|     { |     { | ||||||
|         FileSystemPath path("a/relative/path"); |         LexicalPath path("a/relative/path"); | ||||||
|         EXPECT_EQ(path.is_valid(), true); |         EXPECT_EQ(path.is_valid(), true); | ||||||
|         EXPECT_EQ(path.string(), "./a/relative/path"); |         EXPECT_EQ(path.string(), "./a/relative/path"); | ||||||
|         EXPECT_EQ(path.parts().size(), 4u); |         EXPECT_EQ(path.parts().size(), 4u); | ||||||
|         EXPECT_EQ(path.basename(), "path"); |         EXPECT_EQ(path.basename(), "path"); | ||||||
|     } |     } | ||||||
|     { |     { | ||||||
|         FileSystemPath path("./././foo"); |         LexicalPath path("./././foo"); | ||||||
|         EXPECT_EQ(path.is_valid(), true); |         EXPECT_EQ(path.is_valid(), true); | ||||||
|         EXPECT_EQ(path.string(), "./foo"); |         EXPECT_EQ(path.string(), "./foo"); | ||||||
|         EXPECT_EQ(path.parts().size(), 2u); |         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.is_valid(), true); | ||||||
|         EXPECT_EQ(path.string(), "."); |         EXPECT_EQ(path.string(), "."); | ||||||
|         EXPECT_EQ(path.parts().size(), 1u); |         EXPECT_EQ(path.parts().size(), 1u); | ||||||
|  | @ -123,4 +123,4 @@ TEST_CASE(has_extension) | ||||||
| 
 | 
 | ||||||
| #endif | #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. |  * 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/StringBuilder.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
| 
 | 
 | ||||||
|  | @ -314,22 +314,22 @@ URL URL::complete_url(const String& string) const | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     StringBuilder builder; |     StringBuilder builder; | ||||||
|     FileSystemPath fspath(path()); |     LexicalPath lexical_path(path()); | ||||||
|     builder.append('/'); |     builder.append('/'); | ||||||
| 
 | 
 | ||||||
|     bool document_url_ends_in_slash = path()[path().length() - 1] == '/'; |     bool document_url_ends_in_slash = path()[path().length() - 1] == '/'; | ||||||
| 
 | 
 | ||||||
|     for (size_t i = 0; i < fspath.parts().size(); ++i) { |     for (size_t i = 0; i < lexical_path.parts().size(); ++i) { | ||||||
|         if (i == fspath.parts().size() - 1 && !document_url_ends_in_slash) |         if (i == lexical_path.parts().size() - 1 && !document_url_ends_in_slash) | ||||||
|             break; |             break; | ||||||
|         builder.append(fspath.parts()[i]); |         builder.append(lexical_path.parts()[i]); | ||||||
|         builder.append('/'); |         builder.append('/'); | ||||||
|     } |     } | ||||||
|     builder.append(string); |     builder.append(string); | ||||||
|     auto built = builder.to_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('/')) { |     if (string.ends_with('/') && !built.ends_with('/')) { | ||||||
|         builder.clear(); |         builder.clear(); | ||||||
|         builder.append(built); |         builder.append(built); | ||||||
|  | @ -399,7 +399,7 @@ URL URL::create_with_url_or_path(const String& url_or_path) | ||||||
|     if (url.is_valid()) |     if (url.is_valid()) | ||||||
|         return url; |         return url; | ||||||
| 
 | 
 | ||||||
|     String path = canonicalized_path(url_or_path); |     String path = LexicalPath::canonicalized_path(url_or_path); | ||||||
|     return URL::create_with_file_protocol(path); |     return URL::create_with_file_protocol(path); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -407,7 +407,7 @@ String URL::basename() const | ||||||
| { | { | ||||||
|     if (!m_valid) |     if (!m_valid) | ||||||
|         return {}; |         return {}; | ||||||
|     return FileSystemPath(m_path).basename(); |     return LexicalPath(m_path).basename(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -25,7 +25,6 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "DirectoryView.h" | #include "DirectoryView.h" | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/NumberFormat.h> | #include <AK/NumberFormat.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "FileUtils.h" | #include "FileUtils.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
| #include <stdio.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) { |         if (errno != EISDIR) { | ||||||
|             return false; |             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); |         dst_fd = creat(dst_dir_path.characters(), 0666); | ||||||
|         if (dst_fd < 0) { |         if (dst_fd < 0) { | ||||||
|             return false; |             return false; | ||||||
|  | @ -186,21 +186,21 @@ String get_duplicate_name(const String& path, int duplicate_count) | ||||||
|     if (duplicate_count == 0) { |     if (duplicate_count == 0) { | ||||||
|         return path; |         return path; | ||||||
|     } |     } | ||||||
|     FileSystemPath fsp(path); |     LexicalPath lexical_path(path); | ||||||
|     StringBuilder duplicated_name; |     StringBuilder duplicated_name; | ||||||
|     duplicated_name.append('/'); |     duplicated_name.append('/'); | ||||||
|     for (size_t i = 0; i < fsp.parts().size() - 1; ++i) { |     for (size_t i = 0; i < lexical_path.parts().size() - 1; ++i) { | ||||||
|         duplicated_name.appendf("%s/", fsp.parts()[i].characters()); |         duplicated_name.appendf("%s/", lexical_path.parts()[i].characters()); | ||||||
|     } |     } | ||||||
|     auto prev_duplicate_tag = String::format("(%d)", duplicate_count); |     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)) { |     if (title.ends_with(prev_duplicate_tag)) { | ||||||
|         // remove the previous duplicate tag "(n)" so we can add a new tag.
 |         // remove the previous duplicate tag "(n)" so we can add a new tag.
 | ||||||
|         title = title.substring(0, title.length() - prev_duplicate_tag.length()); |         title = title.substring(0, title.length() - prev_duplicate_tag.length()); | ||||||
|     } |     } | ||||||
|     duplicated_name.appendf("%s (%d)", fsp.title().characters(), duplicate_count); |     duplicated_name.appendf("%s (%d)", lexical_path.title().characters(), duplicate_count); | ||||||
|     if (!fsp.extension().is_empty()) { |     if (!lexical_path.extension().is_empty()) { | ||||||
|         duplicated_name.appendf(".%s", fsp.extension().characters()); |         duplicated_name.appendf(".%s", lexical_path.extension().characters()); | ||||||
|     } |     } | ||||||
|     return duplicated_name.build(); |     return duplicated_name.build(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "PropertiesDialog.h" | #include "PropertiesDialog.h" | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibGUI/BoxLayout.h> | #include <LibGUI/BoxLayout.h> | ||||||
| #include <LibGUI/CheckBox.h> | #include <LibGUI/CheckBox.h> | ||||||
|  | @ -42,8 +43,8 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo | ||||||
|     : Dialog(parent_window) |     : Dialog(parent_window) | ||||||
|     , m_model(model) |     , m_model(model) | ||||||
| { | { | ||||||
|     auto file_path = FileSystemPath(path); |     auto lexical_path = LexicalPath(path); | ||||||
|     ASSERT(file_path.is_valid()); |     ASSERT(lexical_path.is_valid()); | ||||||
| 
 | 
 | ||||||
|     auto& main_widget = set_main_widget<GUI::Widget>(); |     auto& main_widget = set_main_widget<GUI::Widget>(); | ||||||
|     main_widget.set_layout<GUI::VerticalBoxLayout>(); |     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_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); | ||||||
|     m_icon->set_preferred_size(32, 32); |     m_icon->set_preferred_size(32, 32); | ||||||
| 
 | 
 | ||||||
|     m_name = file_path.basename(); |     m_name = lexical_path.basename(); | ||||||
|     m_path = file_path.string(); |     m_path = lexical_path.string(); | ||||||
| 
 | 
 | ||||||
|     m_name_box = file_container.add<GUI::TextBox>(); |     m_name_box = file_container.add<GUI::TextBox>(); | ||||||
|     m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); | ||||||
|  |  | ||||||
|  | @ -26,7 +26,6 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <LibCore/File.h> | #include <LibCore/File.h> | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
| #include <LibGUI/Dialog.h> | #include <LibGUI/Dialog.h> | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| #include "DirectoryView.h" | #include "DirectoryView.h" | ||||||
| #include "FileUtils.h" | #include "FileUtils.h" | ||||||
| #include "PropertiesDialog.h" | #include "PropertiesDialog.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <AK/URL.h> | #include <AK/URL.h> | ||||||
| #include <LibCore/ConfigFile.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 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); |         auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window); | ||||||
|         if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { |         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", |                 String::format("%s/%s", | ||||||
|                     model->root_path().characters(), |                     model->root_path().characters(), | ||||||
|                     input_box->text_value().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 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); |         auto input_box = GUI::InputBox::construct("Enter name:", "New file", window); | ||||||
|         if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { |         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", |                 String::format("%s/%s", | ||||||
|                     model->root_path().characters(), |                     model->root_path().characters(), | ||||||
|                     input_box->text_value().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 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); |         auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window); | ||||||
|         if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { |         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", |                 String::format("%s/%s", | ||||||
|                     directory_view.path().characters(), |                     directory_view.path().characters(), | ||||||
|                     input_box->text_value().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(); |                     selected = selected_file_paths(); | ||||||
|                 } else { |                 } else { | ||||||
|                     path = directories_model->full_path(tree_view.selection().first()); |                     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(); |                     selected = tree_view_selected_file_paths(); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  | @ -510,7 +510,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio | ||||||
| 
 | 
 | ||||||
|         String message; |         String message; | ||||||
|         if (paths.size() == 1) { |         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 { |         } else { | ||||||
|             message = String::format("Really delete %d files?", paths.size()); |             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; |                 continue; | ||||||
|             auto new_path = String::format("%s/%s", |             auto new_path = String::format("%s/%s", | ||||||
|                 target_node.full_path(directory_view.model()).characters(), |                 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) |             if (url_to_copy.path() == new_path) | ||||||
|                 continue; |                 continue; | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "ManualSectionNode.h" | #include "ManualSectionNode.h" | ||||||
| #include "ManualPageNode.h" | #include "ManualPageNode.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/QuickSort.h> | #include <AK/QuickSort.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
|  | @ -46,10 +46,10 @@ void ManualSectionNode::reify_if_needed() const | ||||||
| 
 | 
 | ||||||
|     Vector<String> page_names; |     Vector<String> page_names; | ||||||
|     while (dir_iter.has_next()) { |     while (dir_iter.has_next()) { | ||||||
|         FileSystemPath file_path(dir_iter.next_path()); |         LexicalPath lexical_path(dir_iter.next_path()); | ||||||
|         if (file_path.extension() != "md") |         if (lexical_path.extension() != "md") | ||||||
|             continue; |             continue; | ||||||
|         page_names.append(file_path.title()); |         page_names.append(lexical_path.title()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     quick_sort(page_names); |     quick_sort(page_names); | ||||||
|  |  | ||||||
|  | @ -87,7 +87,7 @@ HexEditorWidget::HexEditorWidget() | ||||||
|             if (valid && file_size > 0) { |             if (valid && file_size > 0) { | ||||||
|                 m_document_dirty = false; |                 m_document_dirty = false; | ||||||
|                 m_editor->set_buffer(ByteBuffer::create_zeroed(file_size)); |                 m_editor->set_buffer(ByteBuffer::create_zeroed(file_size)); | ||||||
|                 set_path(FileSystemPath()); |                 set_path(LexicalPath()); | ||||||
|                 update_title(); |                 update_title(); | ||||||
|             } else { |             } else { | ||||||
|                 GUI::MessageBox::show("Invalid file size entered.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); |                 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; |         m_document_dirty = false; | ||||||
|         set_path(FileSystemPath(save_path.value())); |         set_path(LexicalPath(save_path.value())); | ||||||
|         dbg() << "Wrote document to " << 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_path = lexical_path.string(); | ||||||
|     m_name = file.title(); |     m_name = lexical_path.title(); | ||||||
|     m_extension = file.extension(); |     m_extension = lexical_path.extension(); | ||||||
|     update_title(); |     update_title(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -239,7 +239,7 @@ void HexEditorWidget::open_file(const String& path) | ||||||
| 
 | 
 | ||||||
|     m_document_dirty = false; |     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.
 |     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() | bool HexEditorWidget::request_close() | ||||||
|  |  | ||||||
|  | @ -27,8 +27,8 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "HexEditor.h" | #include "HexEditor.h" | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
| #include <LibGUI/TextEditor.h> | #include <LibGUI/TextEditor.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
|  | @ -45,7 +45,7 @@ public: | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     HexEditorWidget(); |     HexEditorWidget(); | ||||||
|     void set_path(const FileSystemPath& file); |     void set_path(const LexicalPath& file); | ||||||
|     void update_title(); |     void update_title(); | ||||||
| 
 | 
 | ||||||
|     RefPtr<HexEditor> m_editor; |     RefPtr<HexEditor> m_editor; | ||||||
|  |  | ||||||
|  | @ -301,7 +301,7 @@ TextEditorWidget::TextEditorWidget() | ||||||
| 
 | 
 | ||||||
|         m_document_dirty = false; |         m_document_dirty = false; | ||||||
|         m_editor->set_text(StringView()); |         m_editor->set_text(StringView()); | ||||||
|         set_path(FileSystemPath()); |         set_path(LexicalPath()); | ||||||
|         update_title(); |         update_title(); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  | @ -333,7 +333,7 @@ TextEditorWidget::TextEditorWidget() | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         m_document_dirty = false; |         m_document_dirty = false; | ||||||
|         set_path(FileSystemPath(save_path.value())); |         set_path(LexicalPath(save_path.value())); | ||||||
|         dbg() << "Wrote document to " << 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_path = lexical_path.string(); | ||||||
|     m_name = file.title(); |     m_name = lexical_path.title(); | ||||||
|     m_extension = file.extension(); |     m_extension = lexical_path.extension(); | ||||||
| 
 | 
 | ||||||
|     if (m_extension == "cpp" || m_extension == "h") { |     if (m_extension == "cpp" || m_extension == "h") { | ||||||
|         m_cpp_highlight->activate(); |         m_cpp_highlight->activate(); | ||||||
|  | @ -508,7 +508,7 @@ void TextEditorWidget::open_sesame(const String& path) | ||||||
|     m_document_dirty = false; |     m_document_dirty = false; | ||||||
|     m_document_opening = true; |     m_document_opening = true; | ||||||
| 
 | 
 | ||||||
|     set_path(FileSystemPath(path)); |     set_path(LexicalPath(path)); | ||||||
| 
 | 
 | ||||||
|     m_editor->set_focus(true); |     m_editor->set_focus(true); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -26,14 +26,15 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <LibGUI/ActionGroup.h> | #include <LibGUI/ActionGroup.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
| #include <LibGUI/TextEditor.h> | #include <LibGUI/TextEditor.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibWeb/Forward.h> | #include <LibWeb/Forward.h> | ||||||
|  | 
 | ||||||
| class TextEditorWidget final : public GUI::Widget { | class TextEditorWidget final : public GUI::Widget { | ||||||
|     C_OBJECT(TextEditorWidget) |     C_OBJECT(TextEditorWidget) | ||||||
| public: | public: | ||||||
|  | @ -47,7 +48,7 @@ public: | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     TextEditorWidget(); |     TextEditorWidget(); | ||||||
|     void set_path(const FileSystemPath& file); |     void set_path(const LexicalPath& file); | ||||||
|     void update_title(); |     void update_title(); | ||||||
|     void update_markdown_preview(); |     void update_markdown_preview(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| #include "Editor.h" | #include "Editor.h" | ||||||
| #include "EditorWrapper.h" | #include "EditorWrapper.h" | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
| #include <LibCore/File.h> | #include <LibCore/File.h> | ||||||
| #include <LibGUI/Application.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); |         Core::DirIterator it("/usr/share/man/man2", Core::DirIterator::Flags::SkipDots); | ||||||
|         while (it.has_next()) { |         while (it.has_next()) { | ||||||
|             auto path = String::format("/usr/share/man/man2/%s", it.next_path().characters()); |             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); |             paths.set(title, path); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "Project.h" | #include "Project.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/QuickSort.h> | #include <AK/QuickSort.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
|  | @ -169,7 +169,7 @@ private: | ||||||
| Project::Project(const String& path, Vector<String>&& filenames) | Project::Project(const String& path, Vector<String>&& filenames) | ||||||
|     : m_path(path) |     : 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_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")); |     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) | ProjectFile* Project::get_file(const String& filename) | ||||||
| { | { | ||||||
|     for (auto& file : m_files) { |     for (auto& file : m_files) { | ||||||
|         if (FileSystemPath(file.name()).string() == FileSystemPath(filename).string()) |         if (LexicalPath(file.name()).string() == LexicalPath(filename).string()) | ||||||
|             return &file; |             return &file; | ||||||
|     } |     } | ||||||
|     return nullptr; |     return nullptr; | ||||||
|  | @ -307,7 +307,7 @@ void Project::rebuild_tree() | ||||||
|     root->type = ProjectTreeNode::Type::Project; |     root->type = ProjectTreeNode::Type::Project; | ||||||
| 
 | 
 | ||||||
|     for (auto& file : m_files) { |     for (auto& file : m_files) { | ||||||
|         FileSystemPath path(file.name()); |         LexicalPath path(file.name()); | ||||||
|         ProjectTreeNode* current = root.ptr(); |         ProjectTreeNode* current = root.ptr(); | ||||||
|         StringBuilder partial_path; |         StringBuilder partial_path; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -242,7 +242,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|         String message; |         String message; | ||||||
|         if (files.size() == 1) { |         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 { |         } else { | ||||||
|             message = String::format("Really remove %d files from the project?", files.size()); |             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) | void open_project(String filename) | ||||||
| { | { | ||||||
|     FileSystemPath path(filename); |     LexicalPath lexical_path(filename); | ||||||
|     if (chdir(path.dirname().characters()) < 0) { |     if (chdir(lexical_path.dirname().characters()) < 0) { | ||||||
|         perror("chdir"); |         perror("chdir"); | ||||||
|         exit(1); |         exit(1); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -121,10 +121,10 @@ set(KERNEL_SOURCES | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| set(AK_SOURCES | set(AK_SOURCES | ||||||
|     ../AK/FileSystemPath.cpp |  | ||||||
|     ../AK/FlyString.cpp |     ../AK/FlyString.cpp | ||||||
|     ../AK/JsonParser.cpp |     ../AK/JsonParser.cpp | ||||||
|     ../AK/JsonValue.cpp |     ../AK/JsonValue.cpp | ||||||
|  |     ../AK/LexicalPath.cpp | ||||||
|     ../AK/LogStream.cpp |     ../AK/LogStream.cpp | ||||||
|     ../AK/String.cpp |     ../AK/String.cpp | ||||||
|     ../AK/StringBuilder.cpp |     ../AK/StringBuilder.cpp | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/StringBuilder.h> | ||||||
| #include <Kernel/Devices/BlockDevice.h> | #include <Kernel/Devices/BlockDevice.h> | ||||||
| #include <Kernel/FileSystem/Custody.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)) |     if (!parent_inode.metadata().may_write(*Process::current)) | ||||||
|         return KResult(-EACCES); |         return KResult(-EACCES); | ||||||
| 
 | 
 | ||||||
|     FileSystemPath p(path); |     LexicalPath p(path); | ||||||
|     dbg() << "VFS::mknod: '" << p.basename() << "' mode=" << mode << " dev=" << dev << " in " << parent_inode.identifier(); |     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(); |     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(); |     auto& parent_inode = parent_custody.inode(); | ||||||
|     if (!parent_inode.metadata().may_write(*Process::current)) |     if (!parent_inode.metadata().may_write(*Process::current)) | ||||||
|         return KResult(-EACCES); |         return KResult(-EACCES); | ||||||
|     FileSystemPath p(path); |     LexicalPath p(path); | ||||||
| #ifdef VFS_DEBUG | #ifdef VFS_DEBUG | ||||||
|     dbg() << "VFS::create: '" << p.basename() << "' in " << parent_inode.identifier(); |     dbg() << "VFS::create: '" << p.basename() << "' in " << parent_inode.identifier(); | ||||||
| #endif | #endif | ||||||
|  | @ -349,7 +349,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base) | ||||||
|     if (!parent_inode.metadata().may_write(*Process::current)) |     if (!parent_inode.metadata().may_write(*Process::current)) | ||||||
|         return KResult(-EACCES); |         return KResult(-EACCES); | ||||||
| 
 | 
 | ||||||
|     FileSystemPath p(path); |     LexicalPath p(path); | ||||||
| #ifdef VFS_DEBUG | #ifdef VFS_DEBUG | ||||||
|     dbg() << "VFS::mkdir: '" << p.basename() << "' in " << parent_inode.identifier(); |     dbg() << "VFS::mkdir: '" << p.basename() << "' in " << parent_inode.identifier(); | ||||||
| #endif | #endif | ||||||
|  | @ -449,7 +449,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base) | ||||||
|             return KResult(-EACCES); |             return KResult(-EACCES); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto new_basename = FileSystemPath(new_path).basename(); |     auto new_basename = LexicalPath(new_path).basename(); | ||||||
| 
 | 
 | ||||||
|     if (!new_custody_or_error.is_error()) { |     if (!new_custody_or_error.is_error()) { | ||||||
|         auto& new_custody = *new_custody_or_error.value(); |         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()) |     if (result.is_error()) | ||||||
|         return result; |         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()) |     if (result.is_error()) | ||||||
|         return result; |         return result; | ||||||
| 
 | 
 | ||||||
|  | @ -555,7 +555,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base) | ||||||
|     if (old_inode.is_directory()) |     if (old_inode.is_directory()) | ||||||
|         return KResult(-EPERM); |         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) | KResult VFS::unlink(StringView path, Custody& base) | ||||||
|  | @ -579,7 +579,7 @@ KResult VFS::unlink(StringView path, Custody& base) | ||||||
|             return KResult(-EACCES); |             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()) |     if (result.is_error()) | ||||||
|         return result; |         return result; | ||||||
| 
 | 
 | ||||||
|  | @ -600,7 +600,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base) | ||||||
|     if (!parent_inode.metadata().may_write(*Process::current)) |     if (!parent_inode.metadata().may_write(*Process::current)) | ||||||
|         return KResult(-EACCES); |         return KResult(-EACCES); | ||||||
| 
 | 
 | ||||||
|     FileSystemPath p(linkpath); |     LexicalPath p(linkpath); | ||||||
|     dbg() << "VFS::symlink: '" << p.basename() << "' (-> '" << target << "') in " << parent_inode.identifier(); |     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()); |     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()) |     if (inode_or_error.is_error()) | ||||||
|  | @ -649,7 +649,7 @@ KResult VFS::rmdir(StringView path, Custody& base) | ||||||
|     if (result.is_error()) |     if (result.is_error()) | ||||||
|         return result; |         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) | RefPtr<Inode> VFS::get_inode(InodeIdentifier inode_id) | ||||||
|  |  | ||||||
|  | @ -25,7 +25,6 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/Demangle.h> | #include <AK/Demangle.h> | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/RefPtr.h> | #include <AK/RefPtr.h> | ||||||
| #include <AK/ScopeGuard.h> | #include <AK/ScopeGuard.h> | ||||||
| #include <AK/StdLibExtras.h> | #include <AK/StdLibExtras.h> | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/RefPtr.h> | #include <AK/RefPtr.h> | ||||||
| #include <AK/ScopeGuard.h> | #include <AK/ScopeGuard.h> | ||||||
|  | @ -70,9 +70,9 @@ void* dlopen(const char* filename, int flags) | ||||||
|         ASSERT_NOT_REACHED(); |         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()) { |     if (existing_elf_object.has_value()) { | ||||||
|         return const_cast<ELF::DynamicLoader*>(existing_elf_object.value()); |         return const_cast<ELF::DynamicLoader*>(existing_elf_object.value()); | ||||||
|     } |     } | ||||||
|  | @ -105,11 +105,11 @@ void* dlopen(const char* filename, int flags) | ||||||
|         return nullptr; |         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."; |     g_dlerror_msg = "Successfully loaded ELF object."; | ||||||
| 
 | 
 | ||||||
|     // we have one refcount already
 |     // 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) | void* dlsym(void* handle, const char* symbol_name) | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/String.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/StandardPaths.h> | #include <LibCore/StandardPaths.h> | ||||||
|  | @ -37,12 +37,12 @@ namespace Core { | ||||||
| String StandardPaths::home_directory() | String StandardPaths::home_directory() | ||||||
| { | { | ||||||
|     if (auto* home_env = getenv("HOME")) |     if (auto* home_env = getenv("HOME")) | ||||||
|         return canonicalized_path(home_env); |         return LexicalPath::canonicalized_path(home_env); | ||||||
| 
 | 
 | ||||||
|     auto* pwd = getpwuid(getuid()); |     auto* pwd = getpwuid(getuid()); | ||||||
|     String path = pwd ? pwd->pw_dir : "/"; |     String path = pwd ? pwd->pw_dir : "/"; | ||||||
|     endpwent(); |     endpwent(); | ||||||
|     return canonicalized_path(path); |     return LexicalPath::canonicalized_path(path); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| String StandardPaths::desktop_directory() | String StandardPaths::desktop_directory() | ||||||
|  | @ -50,7 +50,7 @@ String StandardPaths::desktop_directory() | ||||||
|     StringBuilder builder; |     StringBuilder builder; | ||||||
|     builder.append(home_directory()); |     builder.append(home_directory()); | ||||||
|     builder.append("/Desktop"); |     builder.append("/Desktop"); | ||||||
|     return canonicalized_path(builder.to_string()); |     return LexicalPath::canonicalized_path(builder.to_string()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| String StandardPaths::downloads_directory() | String StandardPaths::downloads_directory() | ||||||
|  | @ -58,7 +58,7 @@ String StandardPaths::downloads_directory() | ||||||
|     StringBuilder builder; |     StringBuilder builder; | ||||||
|     builder.append(home_directory()); |     builder.append(home_directory()); | ||||||
|     builder.append("/Downloads"); |     builder.append("/Downloads"); | ||||||
|     return canonicalized_path(builder.to_string()); |     return LexicalPath::canonicalized_path(builder.to_string()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| String StandardPaths::tempfile_directory() | String StandardPaths::tempfile_directory() | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/StringBuilder.h> | ||||||
| #include <AK/Utf32View.h> | #include <AK/Utf32View.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
|  | @ -43,10 +43,10 @@ static Vector<u32> supported_emoji_codepoints() | ||||||
|     Core::DirIterator dt("/res/emoji", Core::DirIterator::SkipDots); |     Core::DirIterator dt("/res/emoji", Core::DirIterator::SkipDots); | ||||||
|     while (dt.has_next()) { |     while (dt.has_next()) { | ||||||
|         auto filename = dt.next_path(); |         auto filename = dt.next_path(); | ||||||
|         auto fspath = FileSystemPath(filename); |         auto lexical_path = LexicalPath(filename); | ||||||
|         if (fspath.extension() != "png") |         if (lexical_path.extension() != "png") | ||||||
|             continue; |             continue; | ||||||
|         auto basename = fspath.basename(); |         auto basename = lexical_path.basename(); | ||||||
|         if (!basename.starts_with("U+")) |         if (!basename.starts_with("U+")) | ||||||
|             continue; |             continue; | ||||||
|         u32 codepoint = strtoul(basename.characters() + 2, nullptr, 16); |         u32 codepoint = strtoul(basename.characters() + 2, nullptr, 16); | ||||||
|  |  | ||||||
|  | @ -24,8 +24,8 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <LibGUI/Action.h> | #include <LibGUI/Action.h> | ||||||
| #include <LibGUI/BoxLayout.h> | #include <LibGUI/BoxLayout.h> | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
|  | @ -142,7 +142,7 @@ 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 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"); |         auto& input_box = add<InputBox>("Enter name:", "New directory"); | ||||||
|         if (input_box.exec() == InputBox::ExecOK && !input_box.text_value().is_empty()) { |         if (input_box.exec() == InputBox::ExecOK && !input_box.text_value().is_empty()) { | ||||||
|             auto new_dir_path = FileSystemPath(String::format("%s/%s", |             auto new_dir_path = LexicalPath(String::format("%s/%s", | ||||||
|                                                 m_model->root_path().characters(), |                                                 m_model->root_path().characters(), | ||||||
|                                                 input_box.text_value().characters())) |                                                 input_box.text_value().characters())) | ||||||
|                                     .string(); |                                     .string(); | ||||||
|  | @ -196,7 +196,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& | ||||||
|         auto& filter_model = (SortingProxyModel&)*m_view->model(); |         auto& filter_model = (SortingProxyModel&)*m_view->model(); | ||||||
|         auto local_index = filter_model.map_to_target(index); |         auto local_index = filter_model.map_to_target(index); | ||||||
|         const FileSystemModel::Node& node = m_model->node(local_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(); |         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")) { |     if (path.has_extension(".png")) { | ||||||
|         auto bitmap = Gfx::Bitmap::load_from_file(path.string()); |         auto bitmap = Gfx::Bitmap::load_from_file(path.string()); | ||||||
|  | @ -292,7 +292,7 @@ void FilePicker::clear_preview() | ||||||
| 
 | 
 | ||||||
| void FilePicker::on_file_return() | 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) { |     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); |         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. |  * 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 <AK/Optional.h> | ||||||
| #include <LibCore/StandardPaths.h> | #include <LibCore/StandardPaths.h> | ||||||
| #include <LibGUI/Dialog.h> | #include <LibGUI/Dialog.h> | ||||||
|  | @ -45,10 +45,10 @@ public: | ||||||
| 
 | 
 | ||||||
|     virtual ~FilePicker() override; |     virtual ~FilePicker() override; | ||||||
| 
 | 
 | ||||||
|     FileSystemPath selected_file() const { return m_selected_file; } |     LexicalPath selected_file() const { return m_selected_file; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     void set_preview(const FileSystemPath&); |     void set_preview(const LexicalPath&); | ||||||
|     void clear_preview(); |     void clear_preview(); | ||||||
|     void on_file_return(); |     void on_file_return(); | ||||||
| 
 | 
 | ||||||
|  | @ -68,7 +68,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     RefPtr<MultiView> m_view; |     RefPtr<MultiView> m_view; | ||||||
|     NonnullRefPtr<FileSystemModel> m_model; |     NonnullRefPtr<FileSystemModel> m_model; | ||||||
|     FileSystemPath m_selected_file; |     LexicalPath m_selected_file; | ||||||
| 
 | 
 | ||||||
|     RefPtr<TextBox> m_filename_textbox; |     RefPtr<TextBox> m_filename_textbox; | ||||||
|     RefPtr<Label> m_preview_image_label; |     RefPtr<Label> m_preview_image_label; | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/StringBuilder.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
| #include <LibGUI/FileSystemModel.h> | #include <LibGUI/FileSystemModel.h> | ||||||
|  | @ -162,24 +162,24 @@ String FileSystemModel::Node::full_path(const FileSystemModel& model) const | ||||||
|     } |     } | ||||||
|     builder.append('/'); |     builder.append('/'); | ||||||
|     builder.append(name); |     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 | ModelIndex FileSystemModel::index(const StringView& path, int column) const | ||||||
| { | { | ||||||
|     FileSystemPath canonical_path(path); |     LexicalPath lexical_path(path); | ||||||
|     const Node* node = m_root; |     const Node* node = m_root; | ||||||
|     if (canonical_path.string() == "/") |     if (lexical_path.string() == "/") | ||||||
|         return m_root->index(*this, column); |         return m_root->index(*this, column); | ||||||
|     for (size_t i = 0; i < canonical_path.parts().size(); ++i) { |     for (size_t i = 0; i < lexical_path.parts().size(); ++i) { | ||||||
|         auto& part = canonical_path.parts()[i]; |         auto& part = lexical_path.parts()[i]; | ||||||
|         bool found = false; |         bool found = false; | ||||||
|         for (auto& child : node->children) { |         for (auto& child : node->children) { | ||||||
|             if (child.name == part) { |             if (child.name == part) { | ||||||
|                 const_cast<Node&>(child).reify_if_needed(*this); |                 const_cast<Node&>(child).reify_if_needed(*this); | ||||||
|                 node = &child; |                 node = &child; | ||||||
|                 found = true; |                 found = true; | ||||||
|                 if (i == canonical_path.parts().size() - 1) |                 if (i == lexical_path.parts().size() - 1) | ||||||
|                     return child.index(*this, column); |                     return child.index(*this, column); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|  | @ -198,7 +198,7 @@ String FileSystemModel::full_path(const ModelIndex& index) const | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| FileSystemModel::FileSystemModel(const StringView& root_path, Mode mode) | 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_mode(mode) | ||||||
| { | { | ||||||
|     m_directory_icon = Icon::default_icon("filetype-folder"); |     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) | 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(); |     update(); | ||||||
| 
 | 
 | ||||||
|     if (m_root->has_error()) { |     if (m_root->has_error()) { | ||||||
|  |  | ||||||
|  | @ -24,7 +24,6 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibGUI/Action.h> | #include <LibGUI/Action.h> | ||||||
| #include <LibGUI/ActionGroup.h> | #include <LibGUI/ActionGroup.h> | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/BufferStream.h> | #include <AK/BufferStream.h> | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/MappedFile.h> | #include <AK/MappedFile.h> | ||||||
| #include <AK/NonnullOwnPtrVector.h> | #include <AK/NonnullOwnPtrVector.h> | ||||||
| #include <LibGfx/GIFLoader.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()); |     GIFImageDecoderPlugin gif_decoder((const u8*)mapped_file.data(), mapped_file.size()); | ||||||
|     auto bitmap = gif_decoder.bitmap(); |     auto bitmap = gif_decoder.bitmap(); | ||||||
|     if (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; |     return bitmap; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -536,7 +536,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size) | ||||||
|     m_context->data_size = size; |     m_context->data_size = size; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| GIFImageDecoderPlugin::~GIFImageDecoderPlugin() {} | GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { } | ||||||
| 
 | 
 | ||||||
| Size GIFImageDecoderPlugin::size() | Size GIFImageDecoderPlugin::size() | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/MappedFile.h> | #include <AK/MappedFile.h> | ||||||
| #include <AK/NetworkOrdered.h> | #include <AK/NetworkOrdered.h> | ||||||
| #include <LibCore/puff.h> | #include <LibCore/puff.h> | ||||||
|  | @ -193,7 +193,7 @@ RefPtr<Gfx::Bitmap> load_png(const StringView& path) | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     auto bitmap = load_png_impl((const u8*)mapped_file.data(), mapped_file.size()); |     auto bitmap = load_png_impl((const u8*)mapped_file.data(), mapped_file.size()); | ||||||
|     if (bitmap) |     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; |     return bitmap; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -28,7 +28,6 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/BinarySearch.h> | #include <AK/BinarySearch.h> | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/NonnullOwnPtr.h> | #include <AK/NonnullOwnPtr.h> | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "TerminalWidget.h" | #include "TerminalWidget.h" | ||||||
| #include "XtermColors.h" | #include "XtermColors.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/StdLibExtras.h> | #include <AK/StdLibExtras.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
|  | @ -843,7 +843,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event) | ||||||
|         // Then add them to the context menu.
 |         // Then add them to the context menu.
 | ||||||
|         // FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
 |         // FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
 | ||||||
|         for (auto& handler : handlers) { |         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 af = Core::ConfigFile::open(af_path); | ||||||
|             auto handler_name = af->read_entry("App", "Name", handler); |             auto handler_name = af->read_entry("App", "Name", handler); | ||||||
|             auto handler_icon = af->read_entry("Icons", "16x16", {}); |             auto handler_icon = af->read_entry("Icons", "16x16", {}); | ||||||
|  |  | ||||||
|  | @ -24,7 +24,6 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/Timer.h> | #include <LibCore/Timer.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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 <AK/URL.h> | ||||||
| #include <LibCore/File.h> | #include <LibCore/File.h> | ||||||
| #include <LibCore/MimeData.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"); |     auto title_element = create_element(document, "title"); | ||||||
|     head_element->append_child(title_element); |     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()))); |     auto title_text = adopt(*new Text(document, String::format("%s [%dx%d]", basename.characters(), bitmap->width(), bitmap->height()))); | ||||||
|     title_element->append_child(title_text); |     title_element->append_child(title_text); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -25,8 +25,8 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "Launcher.h" | #include "Launcher.h" | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <LibCore/ConfigFile.h> | #include <LibCore/ConfigFile.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  | @ -191,7 +191,7 @@ Vector<String> Launcher::handlers_for_path(const String& path) | ||||||
|     if (S_ISDIR(st.st_mode)) |     if (S_ISDIR(st.st_mode)) | ||||||
|         return { "/bin/FileManager" }; |         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 handlers_for(extension, m_file_handlers, [](auto& handler, auto& key) { | ||||||
|         return handler.file_types.contains(key); |         return handler.file_types.contains(key); | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "ShutdownDialog.h" | #include "ShutdownDialog.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/QuickSort.h> | #include <AK/QuickSort.h> | ||||||
| #include <LibCore/ConfigFile.h> | #include <LibCore/ConfigFile.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
|  | @ -171,7 +171,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() | ||||||
|         while (dt.has_next()) { |         while (dt.has_next()) { | ||||||
|             auto theme_name = dt.next_path(); |             auto theme_name = dt.next_path(); | ||||||
|             auto theme_path = String::format("/res/themes/%s", theme_name.characters()); |             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; }); |         quick_sort(g_themes, [](auto& a, auto& b) { return a.name < b.name; }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "Client.h" | #include "Client.h" | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/DateTime.h> | #include <LibCore/DateTime.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
|  | @ -82,7 +82,7 @@ void Client::handle_request(ByteBuffer raw_request) | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto requested_path = canonicalized_path(request.resource()); |     auto requested_path = LexicalPath::canonicalized_path(request.resource()); | ||||||
|     dbg() << "Canonical requested path: '" << requested_path << "'"; |     dbg() << "Canonical requested path: '" << requested_path << "'"; | ||||||
| 
 | 
 | ||||||
|     StringBuilder path_builder; |     StringBuilder path_builder; | ||||||
|  |  | ||||||
|  | @ -26,7 +26,6 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/Badge.h> | #include <AK/Badge.h> | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/QuickSort.h> | #include <AK/QuickSort.h> | ||||||
| #include <LibCore/DirIterator.h> | #include <LibCore/DirIterator.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  |  | ||||||
|  | @ -26,8 +26,8 @@ | ||||||
| 
 | 
 | ||||||
| #include "Shell.h" | #include "Shell.h" | ||||||
| #include "Execution.h" | #include "Execution.h" | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <AK/ScopeGuard.h> | #include <AK/ScopeGuard.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/ArgsParser.h> | #include <LibCore/ArgsParser.h> | ||||||
|  | @ -222,12 +222,12 @@ int Shell::builtin_cd(int argc, const char** argv) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FileSystemPath canonical_path(new_path); |     LexicalPath lexical_path(new_path); | ||||||
|     if (!canonical_path.is_valid()) { |     if (!lexical_path.is_valid()) { | ||||||
|         printf("FileSystemPath failed to canonicalize '%s'\n", new_path.characters()); |         printf("LexicalPath failed to canonicalize '%s'\n", new_path.characters()); | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
|     const char* path = canonical_path.string().characters(); |     const char* path = lexical_path.string().characters(); | ||||||
| 
 | 
 | ||||||
|     struct stat st; |     struct stat st; | ||||||
|     int rc = stat(path, &st); |     int rc = stat(path, &st); | ||||||
|  | @ -245,7 +245,7 @@ int Shell::builtin_cd(int argc, const char** argv) | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
|     setenv("OLDPWD", cwd.characters(), 1); |     setenv("OLDPWD", cwd.characters(), 1); | ||||||
|     cwd = canonical_path.string(); |     cwd = lexical_path.string(); | ||||||
|     setenv("PWD", cwd.characters(), 1); |     setenv("PWD", cwd.characters(), 1); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  | @ -612,13 +612,13 @@ int Shell::builtin_popd(int argc, const char** argv) | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FileSystemPath canonical_path(path.characters()); |     LexicalPath lexical_path(path.characters()); | ||||||
|     if (!canonical_path.is_valid()) { |     if (!lexical_path.is_valid()) { | ||||||
|         fprintf(stderr, "FileSystemPath failed to canonicalize '%s'\n", path.characters()); |         fprintf(stderr, "LexicalPath failed to canonicalize '%s'\n", path.characters()); | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const char* real_path = canonical_path.string().characters(); |     const char* real_path = lexical_path.string().characters(); | ||||||
| 
 | 
 | ||||||
|     struct stat st; |     struct stat st; | ||||||
|     int rc = stat(real_path, &st); |     int rc = stat(real_path, &st); | ||||||
|  | @ -639,7 +639,7 @@ int Shell::builtin_popd(int argc, const char** argv) | ||||||
|             return 1; |             return 1; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         cwd = canonical_path.string(); |         cwd = lexical_path.string(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
|  | @ -699,13 +699,13 @@ int Shell::builtin_pushd(int argc, const char** argv) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FileSystemPath canonical_path(path_builder.to_string()); |     LexicalPath lexical_path(path_builder.to_string()); | ||||||
|     if (!canonical_path.is_valid()) { |     if (!lexical_path.is_valid()) { | ||||||
|         fprintf(stderr, "FileSystemPath failed to canonicalize '%s'\n", path_builder.to_string().characters()); |         fprintf(stderr, "LexicalPath failed to canonicalize '%s'\n", path_builder.to_string().characters()); | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const char* real_path = canonical_path.string().characters(); |     const char* real_path = lexical_path.string().characters(); | ||||||
| 
 | 
 | ||||||
|     struct stat st; |     struct stat st; | ||||||
|     int rc = stat(real_path, &st); |     int rc = stat(real_path, &st); | ||||||
|  | @ -726,7 +726,7 @@ int Shell::builtin_pushd(int argc, const char** argv) | ||||||
|             return 1; |             return 1; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         cwd = canonical_path.string(); |         cwd = lexical_path.string(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
|  | @ -1662,7 +1662,7 @@ Vector<Line::CompletionSuggestion> Shell::complete(const Line::Editor& editor) | ||||||
|         path = token.substring(0, last_slash + 1); |         path = token.substring(0, last_slash + 1); | ||||||
|         if (path[0] != '/') |         if (path[0] != '/') | ||||||
|             path = String::format("%s/%s", cwd.characters(), path.characters()); |             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); |         token = token.substring(last_slash + 1, token.length() - last_slash - 1); | ||||||
|     } else { |     } else { | ||||||
|         // We have no slashes, so the directory to search is the current
 |         // 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. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
| int main(int argc, char** argv) | int main(int argc, char** argv) | ||||||
|  | @ -38,6 +38,6 @@ int main(int argc, char** argv) | ||||||
|         printf("usage: basename <path>\n"); |         printf("usage: basename <path>\n"); | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
|     printf("%s\n", FileSystemPath(argv[1]).basename().characters()); |     printf("%s\n", LexicalPath(argv[1]).basename().characters()); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/String.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/ArgsParser.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; |         StringBuilder builder; | ||||||
|         builder.append(dst_path); |         builder.append(dst_path); | ||||||
|         builder.append('/'); |         builder.append('/'); | ||||||
|         builder.append(FileSystemPath(src_path).basename()); |         builder.append(LexicalPath(src_path).basename()); | ||||||
|         dst_path = builder.to_string(); |         dst_path = builder.to_string(); | ||||||
|         dst_fd = creat(dst_path.characters(), 0666); |         dst_fd = creat(dst_path.characters(), 0666); | ||||||
|         if (dst_fd < 0) { |         if (dst_fd < 0) { | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/FileSystemPath.h> | #include <AK/LexicalPath.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibCore/ArgsParser.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) { |     for (const auto& pattern : du_option.excluded_patterns) { | ||||||
|         if (basename.matches(pattern, CaseSensitivity::CaseSensitive)) |         if (basename.matches(pattern, CaseSensitivity::CaseSensitive)) | ||||||
|             return 0; |             return 0; | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/StringBuilder.h> | ||||||
| #include <LibCore/ArgsParser.h> | #include <LibCore/ArgsParser.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
|  | @ -52,18 +52,18 @@ int main(int argc, char** argv) | ||||||
|     bool has_errors = false; |     bool has_errors = false; | ||||||
| 
 | 
 | ||||||
|     for (auto& directory : directories) { |     for (auto& directory : directories) { | ||||||
|         FileSystemPath canonical_path(directory); |         LexicalPath lexical_path(directory); | ||||||
|         if (!create_parents) { |         if (!create_parents) { | ||||||
|             if (mkdir(canonical_path.string().characters(), mode) < 0) { |             if (mkdir(lexical_path.string().characters(), mode) < 0) { | ||||||
|                 perror("mkdir"); |                 perror("mkdir"); | ||||||
|                 has_errors = true; |                 has_errors = true; | ||||||
|             } |             } | ||||||
|             continue; |             continue; | ||||||
|         } |         } | ||||||
|         StringBuilder path_builder; |         StringBuilder path_builder; | ||||||
|         if (canonical_path.is_absolute()) |         if (lexical_path.is_absolute()) | ||||||
|             path_builder.append("/"); |             path_builder.append("/"); | ||||||
|         for (auto& part : canonical_path.parts()) { |         for (auto& part : lexical_path.parts()) { | ||||||
|             path_builder.append(part); |             path_builder.append(part); | ||||||
|             auto path = path_builder.build(); |             auto path = path_builder.build(); | ||||||
|             struct stat st; |             struct stat st; | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * 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/String.h> | ||||||
| #include <LibCore/ArgsParser.h> | #include <LibCore/ArgsParser.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  | @ -56,7 +56,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     String combined_new_path; |     String combined_new_path; | ||||||
|     if (rc == 0 && S_ISDIR(st.st_mode)) { |     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()); |         combined_new_path = String::format("%s/%s", new_path, old_basename.characters()); | ||||||
|         new_path = combined_new_path.characters(); |         new_path = combined_new_path.characters(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -24,7 +24,6 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <AK/FileSystemPath.h> |  | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sergey Bugaev
						Sergey Bugaev