From 515d8e78da00291489a8a4ce3bc0943306aa10b0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 14 Jul 2020 17:23:52 +0400 Subject: [PATCH] Show 'Open With' for files without extension. --- Telegram/SourceFiles/data/data_document.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 4491dd8b6..5b0092d2a 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -29,6 +29,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/file_download_mtproto.h" #include "storage/file_download_web.h" #include "platform/platform_specific.h" +#include "platform/platform_file_utilities.h" +#include "base/platform/base_platform_info.h" #include "history/history.h" #include "history/history_item.h" #include "history/view/media/history_view_gif.h" @@ -80,11 +82,21 @@ void LaunchWithWarning( } return true; }(); - if (!warn) { + const auto extension = '.' + Data::FileExtension(name); + if (Platform::IsWindows() && extension == u"."_q) { + // If you launch a file without extension, like "test", in case + // there is an executable file with the same name in this folder, + // like "test.bat", the executable file will be launched. + // + // Now we always force an Open With dialog box for such files. + crl::on_main([=] { + Platform::File::UnsafeShowOpenWith(name); + }); + return; + } else if (!warn) { File::Launch(name); return; } - const auto extension = '.' + Data::FileExtension(name); const auto callback = [=](bool checked) { if (checked) { Core::App().settings().setExeLaunchWarning(false);