fix path error
This commit is contained in:
parent
ea80038121
commit
e5dca6cf34
BIN
img_logo.png
Normal file
BIN
img_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 406 KiB |
@ -5,6 +5,7 @@
|
||||
#include "logger/logger.hpp"
|
||||
|
||||
#include "buffer/buffer.hpp"
|
||||
#include "utils/func.hpp"
|
||||
|
||||
namespace rrr
|
||||
{
|
||||
@ -187,16 +188,17 @@ namespace rrr
|
||||
void content::create_file(std::string filename)
|
||||
{
|
||||
std::string cmd;
|
||||
auto pwd = func::sheilding(PWD);
|
||||
|
||||
if (filename.find("/") != std::string::npos)
|
||||
{
|
||||
if (filename.at(filename.size() - 1) == '/') cmd = "mkdir -p " + std::string(PWD / filename);
|
||||
else cmd = "mkdir -p " + std::string(PWD / std::filesystem::path(filename).parent_path())
|
||||
+ " && touch " + std::string(PWD / filename);
|
||||
if (filename.at(filename.size() - 1) == '/') cmd = "mkdir -p " + std::string(pwd / filename);
|
||||
else cmd = "mkdir -p " + std::string(pwd / std::filesystem::path(filename).parent_path())
|
||||
+ " && touch " + std::string(pwd / filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = "touch " + std::string(PWD / filename);
|
||||
cmd = "touch " + std::string(pwd / filename);
|
||||
}
|
||||
|
||||
hack::utils::unix_cmd(cmd);
|
||||
@ -215,7 +217,7 @@ namespace rrr
|
||||
new_name = old_name.parent_path() / std::filesystem::path(new_name);
|
||||
}
|
||||
|
||||
hack::utils::unix_cmd("mv " + old_name.string() + " " + new_name.string());
|
||||
hack::utils::unix_cmd("mv " + func::sheilding(old_name).string() + " " + func::sheilding(new_name).string());
|
||||
nav.fill(PWD);
|
||||
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
||||
@ -245,7 +247,7 @@ namespace rrr
|
||||
}
|
||||
|
||||
std::string cmd = std::filesystem::is_directory(f) ? "cp -R " : "cp ";
|
||||
hack::utils::unix_cmd(cmd + f.string() + " " + target.string());
|
||||
hack::utils::unix_cmd(cmd + func::sheilding(f).string() + " " + func::sheilding(target).string());
|
||||
nav.fill(PWD);
|
||||
|
||||
check_cursor_position();
|
||||
@ -253,7 +255,7 @@ namespace rrr
|
||||
|
||||
void content::delete_file(file f)
|
||||
{
|
||||
std::string cmd = "delete " + f.path.string();
|
||||
std::string cmd = "delete " + func::sheilding(f.path).string();
|
||||
hack::utils::unix_cmd(cmd);
|
||||
nav.fill(PWD);
|
||||
increment_position(-1);
|
||||
@ -276,7 +278,7 @@ namespace rrr
|
||||
}
|
||||
|
||||
std::string cmd = "mv ";
|
||||
hack::utils::unix_cmd(cmd + f.string() + " " + target.string());
|
||||
hack::utils::unix_cmd(cmd + func::sheilding(f).string() + " " + func::sheilding(target).string());
|
||||
nav.fill(PWD);
|
||||
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
||||
|
@ -51,13 +51,12 @@ namespace rrr
|
||||
int navigation_cursor_position = 0;
|
||||
int preview_cursor_position = 0;
|
||||
int history_cursor_position = 0;
|
||||
file navigation_selected_file;
|
||||
|
||||
|
||||
private:
|
||||
void set_history_cursor_position();
|
||||
void set_preview_cursor_position();
|
||||
void check_cursor_position();
|
||||
|
||||
file navigation_selected_file;
|
||||
};
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace rrr::layers::gui
|
||||
TR_PUSH_FONT(SEMI_BOLD, 18);
|
||||
ImGui::TextUnformatted(">");
|
||||
ImGui::SameLine(22.f);
|
||||
current_position = it - data->begin();
|
||||
current_position = std::distance(it, data->begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace rrr::layers::gui
|
||||
|
||||
push_style(item);
|
||||
|
||||
if (selected_file.path == item.path)
|
||||
if (!selected_file.path.empty() && selected_file.path == item.path)
|
||||
{
|
||||
if (selected_file.is_hidden)
|
||||
TR_PUSH_FONT(SEMI_BOLD_ITALIC, 18);
|
||||
@ -283,9 +283,6 @@ namespace rrr::layers::gui
|
||||
set_scroll();
|
||||
}
|
||||
|
||||
// HERE начинаем тут
|
||||
// если дирректория пуста и туда заъодить, то происходит краш приложения
|
||||
// сотрим тут: void content::navigation_right()
|
||||
if (key.get_keycode() == try_engine::key::L)
|
||||
{
|
||||
cnt->navigation_right();
|
||||
@ -351,6 +348,7 @@ namespace rrr::layers::gui
|
||||
// помощь
|
||||
if (key.get_keycode() == try_engine::key::F1)
|
||||
{
|
||||
hack::log()("help");
|
||||
em->execute(types::event_type::SHOW_HELP_DIALOG, nullptr);
|
||||
freeze = true;
|
||||
}
|
||||
@ -418,6 +416,8 @@ namespace rrr::layers::gui
|
||||
|
||||
void navigation::set_scroll()
|
||||
{
|
||||
if (selected_file.path.empty()) return;
|
||||
|
||||
delta = 0;
|
||||
current_position = 0;
|
||||
cursor_position = 0;
|
||||
@ -460,6 +460,7 @@ namespace rrr::layers::gui
|
||||
|
||||
void navigation::detect_file()
|
||||
{
|
||||
if (selected_file.path.empty()) return;
|
||||
if (std::filesystem::is_directory(selected_file.path)) return;
|
||||
|
||||
if (selected_file.path.extension() == ".jpg" ||
|
||||
|
@ -75,7 +75,7 @@ namespace rrr::layers::gui
|
||||
TR_PUSH_FONT(SEMI_BOLD, 18);
|
||||
ImGui::TextUnformatted(">");
|
||||
ImGui::SameLine(22.f);
|
||||
current_position = it - data->begin();
|
||||
current_position = std::distance(it, data->begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -40,6 +40,8 @@ namespace rrr::layers::gui
|
||||
if (help_dialog)
|
||||
draw_help_dialog();
|
||||
|
||||
hack::log()("render dialog");
|
||||
|
||||
END_IMGUI_WIN();
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
@ -93,6 +95,7 @@ namespace rrr::layers::gui
|
||||
{
|
||||
show = true;
|
||||
help_dialog = true;
|
||||
hack::log()("SHOW_HELP_DIALOG", show, help_dialog);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -284,6 +287,7 @@ namespace rrr::layers::gui
|
||||
|
||||
void dialogs::draw_help_dialog()
|
||||
{
|
||||
hack::log()("draw_help_dialog");
|
||||
height = try_engine::application::get()->get_window()->height() / 2.5f;
|
||||
|
||||
TR_PUSH_FONT(MEDIUM, 16);
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace rrr::func
|
||||
{
|
||||
template<typename Color>
|
||||
@ -7,4 +9,24 @@ namespace rrr::func
|
||||
{
|
||||
return Color(r / 255.f, g / 255.f, b / 255.f, 1.f);
|
||||
}
|
||||
|
||||
// для экоранирования путей чтоб unix команды нормально выполнялись
|
||||
// правила тут вилимо будут добавлятся так что эт не конец:(
|
||||
inline std::filesystem::path sheilding(std::filesystem::path PWD)
|
||||
{
|
||||
std::string pwd_local;
|
||||
|
||||
for (char c : PWD.string()) {
|
||||
if (c == ' ')
|
||||
pwd_local += "\\ ";
|
||||
else if (c == '(')
|
||||
pwd_local += "\\(";
|
||||
else if (c == ')')
|
||||
pwd_local += "\\)";
|
||||
else
|
||||
pwd_local += c;
|
||||
}
|
||||
|
||||
return pwd_local;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user