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.
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.
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.