Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows version always recurse into subdirectories #169

Open
Yutaka-Sawada opened this issue Feb 2, 2022 · 1 comment
Open

Windows version always recurse into subdirectories #169

Yutaka-Sawada opened this issue Feb 2, 2022 · 1 comment

Comments

@Yutaka-Sawada
Copy link

I found a strange behavior of Windows binary (par2.exe). It always enable recursive search, even when "-R" option isn't set.

In "diskfile.cpp", source code for GCC checks "recursive" flag like below;
if (S_ISDIR(st.st_mode) && recursive == true)

There is no checking in source code for Windows OS. To be same behavior between Linux/Unix and Windows, there should be a checker at line 400.

Original line without checking "recursive" flag is like below;
else if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)

I suggest to modify the line to be like below;
else if ( (0 != (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) && (recursive == true) )
or, simply replace second checking of FILE_ATTRIBUTE_DIRECTORY like below;
else if (recursive == true)

Also, there is a bug in the recursive search. It cannot search 2nd or more sub-directories, because it doesn't add found name to current path.

Source code for GCC add name to current path, and call FindFiles() with the new path like below;
string fn = path + name;
DiskFile::FindFiles(fn, nwwildcard, true)

At source code for Windows, it should add fd.cFileName to path in the same way.

@Rhialto
Copy link

Rhialto commented Feb 2, 2022

This would be a good opportunity to change the ugly recursive == true into just recursive.
And the weird if (0 == something) {...} else if (something) {...} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants