diff --git a/far/changelog b/far/changelog index 6a231d497b..645b78bdac 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,8 @@ +-------------------------------------------------------------------------------- +drkns 16.05.2021 15:31:41 +0100 - build 5799 + +1. Correction of 5776. + -------------------------------------------------------------------------------- drkns 11.05.2021 02:02:02 +0100 - build 5798 diff --git a/far/findfile.cpp b/far/findfile.cpp index 6585ce94a0..d54c7ec45f 100644 --- a/far/findfile.cpp +++ b/far/findfile.cpp @@ -2294,7 +2294,8 @@ void background_searcher::DoScanTree(string_view const strRoot) ScanTree ScTree( false, !(SearchMode==FINDAREA_CURRENT_ONLY||SearchMode==FINDAREA_INPATH), - Global->Opt->FindOpt.FindSymLinks + Global->Opt->FindOpt.FindSymLinks, + true ); if (SearchMode==FINDAREA_SELECTED) diff --git a/far/plugapi.cpp b/far/plugapi.cpp index 33cc6f8098..06a3997cb7 100644 --- a/far/plugapi.cpp +++ b/far/plugapi.cpp @@ -2959,7 +2959,7 @@ void WINAPI apiRecursiveSearch(const wchar_t *InitDir, const wchar_t *Mask, FRSU if (!FMask.assign(Mask, FMF_SILENT)) return; Flags=Flags&0x000000FF; // только младший байт! - ScanTree ScTree((Flags & FRS_RETUPDIR)!=0, (Flags & FRS_RECUR)!=0, (Flags & FRS_SCANSYMLINK)!=0); + ScanTree ScTree((Flags & FRS_RETUPDIR)!=0, (Flags & FRS_RECUR)!=0, (Flags & FRS_SCANSYMLINK)!=0, true); os::fs::find_data FindData; string strFullName; ScTree.SetFindPath(InitDir, L"*"sv); diff --git a/far/scantree.cpp b/far/scantree.cpp index fb823911ae..fc577d4962 100644 --- a/far/scantree.cpp +++ b/far/scantree.cpp @@ -64,12 +64,14 @@ enum tree_flags TREE_RETUPDIR = 0_bit, // = FRS_RETUPDIR TREE_RECUR = 1_bit, // = FRS_RECUR TREE_SCANSYMLINK = 2_bit, // = FRS_SCANSYMLINK - TREE_SECONDDIRNAME = 3_bit, // set when FSCANTREE_RETUPDIR is enabled and directory scan is finished + TREE_FILESFIRST = 3_bit, // Сканирование каталога за два прохода. Сначала файлы, затем каталоги + TREE_SECONDDIRNAME = 4_bit, // set when FSCANTREE_RETUPDIR is enabled and directory scan is finished }; enum tree_item_flags { - TREE_ITEM_INSIDE_REPARSE_POINT = 0_bit, // For Copy: we don't want to delete anything from any reparse points + TREE_ITEM_SECONDPASS = 0_bit, // то, что раньше было было SecondPass[] + TREE_ITEM_INSIDE_REPARSE_POINT = 1_bit, // For Copy: we don't want to delete anything from any reparse points }; @@ -88,11 +90,12 @@ class ScanTree::scantree_item std::unordered_set ActiveDirectories; }; -ScanTree::ScanTree(bool RetUpDir, bool Recurse, int ScanJunction) +ScanTree::ScanTree(bool RetUpDir, bool Recurse, int ScanJunction, bool FilesFirst) { Flags.Change(TREE_RETUPDIR, RetUpDir); Flags.Change(TREE_RECUR, Recurse); Flags.Change(TREE_SCANSYMLINK, ScanJunction == -1? Global->Opt->ScanJunction.Get() : ScanJunction != 0); + Flags.Change(TREE_FILESFIRST, FilesFirst); } ScanTree::~ScanTree() = default; @@ -158,6 +161,27 @@ bool ScanTree::GetNextName(os::fs::find_data& fdata,string &strFullName) fdata = *ScanItems.back().Iterator; } + if (Flags.Check(TREE_FILESFIRST)) + { + if (LastItem.Flags.Check(TREE_ITEM_SECONDPASS)) + { + if (!Done && !(fdata.Attributes & FILE_ATTRIBUTE_DIRECTORY)) + continue; + } + else + { + if (!Done && (fdata.Attributes & FILE_ATTRIBUTE_DIRECTORY)) + continue; + + if (Done) + { + LastItem.Find.reset(); + LastItem.Flags.Set(TREE_ITEM_SECONDPASS); + continue; + } + } + } + break; } } @@ -220,6 +244,7 @@ bool ScanTree::GetNextName(os::fs::find_data& fdata,string &strFullName) scantree_item Data; Data.Flags = ScanItems.back().Flags; // наследуем флаг + Data.Flags.Clear(TREE_ITEM_SECONDPASS); Data.RealPath = RealPath; Data.ActiveDirectories = ScanItems.back().ActiveDirectories; if (Flags.Check(TREE_SCANSYMLINK)) diff --git a/far/scantree.hpp b/far/scantree.hpp index 7475b36040..684de76f4f 100644 --- a/far/scantree.hpp +++ b/far/scantree.hpp @@ -53,7 +53,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class ScanTree: noncopyable { public: - explicit ScanTree(bool RetUpDir, bool Recurse=true, int ScanJunction=-1); + explicit ScanTree(bool RetUpDir, bool Recurse=true, int ScanJunction=-1, bool FilesFirst = false); ~ScanTree(); // 3-й параметр - флаги из старшего слова diff --git a/far/vbuild.m4 b/far/vbuild.m4 index ac99f6ce97..1c685ffe3b 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -5798 +5799