Skip to content

Commit

Permalink
Correction of 5776
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed May 16, 2021
1 parent f7386f2 commit bc97881
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion far/findfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion far/plugapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 28 additions & 3 deletions far/scantree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};


Expand All @@ -88,11 +90,12 @@ class ScanTree::scantree_item
std::unordered_set<string> 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;
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion far/scantree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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-й параметр - флаги из старшего слова
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5798
5799

0 comments on commit bc97881

Please sign in to comment.