summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-27 11:44:08 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-27 11:44:08 +0300
commit18249f6a5acc26c75005526c6dfebcf112b7141d (patch)
tree9f213149887e237e24cf5d85aacae861544d7c81 /src/mir_core
parent73c31a3f9ac9f323d6a17a910fb6a8a32416c7bb (diff)
fixes #3584 (Оффлайновые файлы: не открывать скачанный файл автоматически)
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/Windows/fileutil.cpp19
-rw-r--r--src/mir_core/src/mir_core.def2
-rw-r--r--src/mir_core/src/mir_core64.def2
3 files changed, 23 insertions, 0 deletions
diff --git a/src/mir_core/src/Windows/fileutil.cpp b/src/mir_core/src/Windows/fileutil.cpp
index a7494bc8b7..9bf0baced6 100644
--- a/src/mir_core/src/Windows/fileutil.cpp
+++ b/src/mir_core/src/Windows/fileutil.cpp
@@ -62,6 +62,25 @@ bool MFilePath::MFileIterator::isDir() const
/////////////////////////////////////////////////////////////////////////////////////////
+CMStringW MFilePath::getExtension() const
+{
+ int idx = ReverseFind('.');
+ return (idx == -1) ? L"" : Right(GetLength() - idx - 1);
+}
+
+bool MFilePath::isExecutable() const
+{
+ CMStringW wszExt = getExtension(), wszEnv;
+ wszExt.MakeUpper();
+ wszEnv.GetEnvironmentVariableW(L"PATHEXT");
+
+ for (auto *p = wcstok(wszEnv.GetBuffer(), L";"); p; p = wcstok(0, L";"))
+ if (wszExt == p + 1)
+ return true;
+
+ return false;
+}
+
bool MFilePath::isExist() const
{
return _waccess(c_str(), 0) == 0;
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index af4fbd0c30..ca83dabb82 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1558,3 +1558,5 @@ db_event_updateId @1772
??_7MShareable@@6B@ @1779 NONAME
?Acquire@MShareable@@QAEXXZ @1780 NONAME
?Release@MShareable@@QAEXXZ @1781 NONAME
+?getExtension@MFilePath@@QBE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1782 NONAME
+?isExecutable@MFilePath@@QBE_NXZ @1783 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index c071152ab3..da3b919a84 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1558,3 +1558,5 @@ db_event_updateId @1772
??_7MShareable@@6B@ @1779 NONAME
?Acquire@MShareable@@QEAAXXZ @1780 NONAME
?Release@MShareable@@QEAAXXZ @1781 NONAME
+?getExtension@MFilePath@@QEBA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1782 NONAME
+?isExecutable@MFilePath@@QEBA_NXZ @1783 NONAME