ImageViewer: Use LexicalPath to grab current_dir

This commit is contained in:
Aziz Berkay Yesilyurt 2021-07-09 01:03:16 +02:00 committed by Andreas Kling
parent dd476c35cb
commit f62f53f723

View file

@ -6,6 +6,7 @@
*/ */
#include "ViewWidget.h" #include "ViewWidget.h"
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h> #include <AK/MappedFile.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <LibCore/DirIterator.h> #include <LibCore/DirIterator.h>
@ -63,12 +64,7 @@ void ViewWidget::navigate(Directions direction)
if (m_path == nullptr) if (m_path == nullptr)
return; return;
auto parts = m_path.split('/'); auto current_dir = LexicalPath(m_path).parent().string();
parts.remove(parts.size() - 1);
StringBuilder sb;
sb.append("/");
sb.join("/", parts);
auto current_dir = sb.to_string();
if (m_files_in_same_dir.is_empty()) { if (m_files_in_same_dir.is_empty()) {
Core::DirIterator iterator(current_dir, Core::DirIterator::Flags::SkipDots); Core::DirIterator iterator(current_dir, Core::DirIterator::Flags::SkipDots);