aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-10 13:31:24 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-10 14:07:31 +0200
commit6eb8d7fbcbc64bcb89083ab46d591d9f9ed5b388 (patch)
treeacfd12e231bc1a8fd9905b4035cf58d089f88343 /src/QuickMedia.cpp
parentb88c367c48da452f0100bd8cffaba5d76cd83f0d (diff)
Convert file-manager --dir to absolute path
Fixes parent navigation when using relative path for --dir. Submit should not be async for peertube. Fixes peertube video length.
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 32696b6..aef1073 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -46,6 +46,7 @@
#include <malloc.h>
#include <unistd.h>
#include <libgen.h>
+#include <limits.h>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Window/Clipboard.hpp>
@@ -314,6 +315,15 @@ namespace QuickMedia {
return body_item;
}
+ static bool convert_to_absolute_path(std::filesystem::path &path) {
+ char resolved[PATH_MAX];
+ if(!realpath(path.c_str(), resolved))
+ return false;
+
+ path = resolved;
+ return true;
+ }
+
int Program::run(int argc, char **argv) {
if(argc < 1) {
usage();
@@ -456,8 +466,12 @@ namespace QuickMedia {
}
std::filesystem::path home_path = get_home_dir().data;
- if(file_manager_start_dir.empty())
+ if(file_manager_start_dir.empty()) {
file_manager_start_dir = home_path;
+ } else {
+ if(!convert_to_absolute_path(file_manager_start_dir))
+ fprintf(stderr, "Warning: failed to get absolute path for path: %s\n", file_manager_start_dir.c_str());
+ }
int start_tab_index = 0;
FileManagerMimeType fm_mine_type = FILE_MANAGER_MIME_TYPE_ALL;