From f87065ff96ed25868128d25802296cd3b4e29264 Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Mon, 23 Oct 2017 20:39:55 +0100 Subject: [PATCH] Elevation wasn't working during symlinks copying & few minor things --- far/FarEng.hlf.m4 | 4 ++-- far/FarRus.hlf.m4 | 2 +- far/changelog | 6 ++++++ far/common/string_utils.hpp | 20 ++++++++++---------- far/copy.cpp | 4 ++-- far/copy_progress.cpp | 2 +- far/main.cpp | 7 ------- far/platform.chrono.hpp | 2 +- far/platform.fs.cpp | 10 +++++++++- far/vbuild.m4 | 2 +- 10 files changed, 33 insertions(+), 26 deletions(-) diff --git a/far/FarEng.hlf.m4 b/far/FarEng.hlf.m4 index b0a2191a69..44db91f97d 100644 --- a/far/FarEng.hlf.m4 +++ b/far/FarEng.hlf.m4 @@ -3572,8 +3572,8 @@ will not be analyzed, and only file attributes will be taken into account. - it has none of the excluded attributes. - The Compressed, Encrypted, Not indexed, Sparse, Temporary attributes and -Symbolic links are valid for NTFS drives only. The #Integrity stream# and + The Compressed, Encrypted, Not indexed, Sparse, Temporary and Reparse point +attributes are valid for NTFS drives only. The #Integrity stream# and #No scrub data# attributes only supported on ReFS voumes starting from Windows Server 2012. diff --git a/far/FarRus.hlf.m4 b/far/FarRus.hlf.m4 index 208c779da5..109fb05534 100644 --- a/far/FarRus.hlf.m4 +++ b/far/FarRus.hlf.m4 @@ -3645,7 +3645,7 @@ $ #Раскраска файлов и группы сортировки: ред - он не имеет атрибутов исключения. Атрибуты "Сжатый", "Зашифрованный", "Неиндексируемый", "Разрежённый", -"Временный", "Символическая ссылка", "Автономный" и "Виртуальный" используются +"Временный", "Точка повторной обработки", "Автономный" и "Виртуальный" используются только на дисках с файловой системой NTFS. Атрибут "Виртуальный" не используется в Windows 2000/XP/2003. Атрибуты #Поток целостности# и #Нет данных очистки# поддерживаются только на ReFS томах, начиная с Windows Server 2012. diff --git a/far/changelog b/far/changelog index 490c2dc7a3..9f088cf550 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,9 @@ +drkns 23.10.2017 20:20:30 +0100 - build 5070 + +1. Не работал запрос прав при копировании симлинков. + +2. Пара мелочей. + zg 20.10.2017 17:09:22 +0300 - build 5069 1. с форума: Ошибка перерисовки диалога в Просмотрщике. diff --git a/far/common/string_utils.hpp b/far/common/string_utils.hpp index edcaa7fdd5..6890c622dd 100644 --- a/far/common/string_utils.hpp +++ b/far/common/string_utils.hpp @@ -33,23 +33,22 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "preprocessor.hpp" +#include "placement.hpp" /* Helper class to safely pass string_view to low level C or platform API. Builds a compatible null-terminated std::basic_string if the given view is not null-terminated, otherwise uses the same data. */ - -#include "placement.hpp" +template +class null_terminated_t +{ +public: WARNING_PUSH() WARNING_DISABLE_MSC(4582) // no page '%$S': constructor is not implicitly called WARNING_DISABLE_MSC(4583) // no page '%$S': destructor is not implicitly called -template -class null_terminated_t -{ -public: explicit null_terminated_t(const basic_string_view& Str): m_Terminated(!Str.raw_data()[Str.size()]) { @@ -67,6 +66,8 @@ class null_terminated_t placement::destruct(m_Str); } +WARNING_POP() + auto data() const { return m_Terminated? m_View.raw_data() : m_Str.data(); @@ -86,10 +87,9 @@ class null_terminated_t bool m_Terminated; }; -WARNING_POP() - using null_terminated = null_terminated_t; + namespace detail { inline void append_one(string& Str, wchar_t Arg, size_t) { Str += Arg; } @@ -284,12 +284,12 @@ inline bool equal(const string_view& Str1, const string_view& Str2) inline bool starts_with(const string_view& Str, const string_view& Prefix) { - return Str.size() >= Prefix.size() && equal({ Str.raw_data(), Prefix.size() }, Prefix); + return Str.size() >= Prefix.size() && Str.substr(0, Prefix.size()) == Prefix; } inline bool ends_with(const string_view& Str, const string_view& Suffix) { - return Str.size() >= Suffix.size() && equal({ Str.raw_data() + Str.size() - Suffix.size(), Suffix.size() }, Suffix); + return Str.size() >= Suffix.size() && Str.substr(Str.size() - Suffix.size()) == Suffix; } inline bool contains(const string_view& Str, const string_view& Token) diff --git a/far/copy.cpp b/far/copy.cpp index 2d0f3d3721..ae08afcf8d 100644 --- a/far/copy.cpp +++ b/far/copy.cpp @@ -1828,7 +1828,7 @@ COPY_CODES ShellCopy::ShellCopyOneFile( if (Rename) { - CmpCode = equal(PointToName(Src), PointToName(strDestPath)); + CmpCode = PointToName(Src) == PointToName(strDestPath); } if (CmpCode==1) @@ -2204,7 +2204,7 @@ COPY_CODES ShellCopy::ShellCopyOneFile( if (Rename) { - CmpCode = equal(PointToName(Src), PointToName(strDestPath)); + CmpCode = PointToName(Src) == PointToName(strDestPath); } if (CmpCode==1 && !Rename) diff --git a/far/copy_progress.cpp b/far/copy_progress.cpp index c22aa2c350..edc82a7786 100644 --- a/far/copy_progress.cpp +++ b/far/copy_progress.cpp @@ -1,4 +1,4 @@ -/* +/* copy_progress.cpp */ /* diff --git a/far/main.cpp b/far/main.cpp index d0b017d5b1..fe13581781 100644 --- a/far/main.cpp +++ b/far/main.cpp @@ -810,13 +810,6 @@ static int mainImpl(const range& Args) static int wmain_seh(int Argc, wchar_t *Argv[]) { - FILETIME f; - GetSystemTimeAsFileTime(&f); - SYSTEMTIME s; - FileTimeToSystemTime(&f, &s); - FILETIME f2; - SystemTimeToFileTime(&s, &f2); - #if defined(SYSLOG) atexit(PrintSysLogStat); #endif diff --git a/far/platform.chrono.hpp b/far/platform.chrono.hpp index cf799adbd6..7df65376a5 100644 --- a/far/platform.chrono.hpp +++ b/far/platform.chrono.hpp @@ -3,7 +3,7 @@ #pragma once /* -chrono.hpp +platform.chrono.hpp */ /* diff --git a/far/platform.fs.cpp b/far/platform.fs.cpp index c4aabe303e..f7640e194d 100644 --- a/far/platform.fs.cpp +++ b/far/platform.fs.cpp @@ -1376,6 +1376,14 @@ namespace os::fs FlagsAndAttributes |= FILE_FLAG_POSIX_SEMANTICS; } + const auto& create_elevated = [&] + { + return handle(elevation::instance().create_file(strObject, DesiredAccess, ShareMode, SecurityAttributes, CreationDistribution, FlagsAndAttributes, TemplateFile)); + }; + + if (ForceElevation) + return create_elevated(); + if (auto Handle = handle(low::create_file(strObject.data(), DesiredAccess, ShareMode, SecurityAttributes, CreationDistribution, FlagsAndAttributes, TemplateFile))) return Handle; @@ -1395,7 +1403,7 @@ namespace os::fs } if (ElevationRequired(DesiredAccess & (GENERIC_ALL | GENERIC_WRITE | WRITE_OWNER | WRITE_DAC | DELETE | FILE_WRITE_DATA | FILE_ADD_FILE | FILE_APPEND_DATA | FILE_ADD_SUBDIRECTORY | FILE_CREATE_PIPE_INSTANCE | FILE_WRITE_EA | FILE_DELETE_CHILD | FILE_WRITE_ATTRIBUTES)? ELEVATION_MODIFY_REQUEST : ELEVATION_READ_REQUEST) || ForceElevation) - return handle(elevation::instance().create_file(strObject, DesiredAccess, ShareMode, SecurityAttributes, CreationDistribution, FlagsAndAttributes, TemplateFile)); + return create_elevated(); return nullptr; } diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 8e19e428f3..8f840421cb 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,5069)m4_dnl +m4_define(BUILD,5070)m4_dnl