-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
[Feature Request]: case insensitive path comparison option for Windows #228
Comments
Currently I am implementing a workaround like: BitArchiveReader reader = BitArchiveReader{ lib, archivePath, archiveFormat };
for each (auto entry in reader)
{
auto entryInArchive = entry.path();
bool isEqual = lstrcmpi(entryInArchive.c_str(), entryToSearch.c_str()) == 0;
if (isEqual)
{
return true;
}
}
return false; I have used lstrmpi for comparing strings. |
Hi!
I think it is a useful feature, I'll definitely add it, possibly in the next v4.1. My only doubt is whether to make it build-time option (e.g., like
This is probably a bit trickier than But I'll try to find a workaround. Anyway, thank you for the feature request! |
I also discovered that |
Yeah, this is the expected behavior, as the wildcard matching is performed treating paths as strings rather than filesystem paths (and by default, string/char comparisons are case-sensitive). But it should be possible to allow case-insensitive matching, of course. Actually, there are also some private functions called This latter change might be available already in the next v4.0.8, the other changes might require more time.
For the time being, you should be able to extract it by index, e.g.: BitArchiveReader reader = BitArchiveReader{ lib, archivePath, archiveFormat };
for (const auto& entry : reader)
{
auto entryInArchive = entry.path();
bool isEqual = lstrcmpi(entryInArchive.c_str(), entryToSearch.c_str()) == 0;
if (isEqual)
{
// extractTo takes an array of indices of the items to be extracted
reader.extractTo( "<outPath>", { entry.index() } );
break;
}
} |
Thanks! I'll try that. |
It worked! Thanks. // subTreeRoot is a directory inside the archive
tstring wildcardedSubTreeRoot = subTreeRoot + BIT7Z_STRING("\\*");
for (const auto& entry : extractor)
{
auto entryInArchive = entry.path();
BOOL matches = PathMatchSpec(entryInArchive.c_str(), subTreeRoot.c_str());
if (!matches)
{
matches = PathMatchSpec(entryInArchive.c_str(), wildcardedSubTreeRoot.c_str());
}
if (matches)
{
indices.push_back(entry.index());
}
} |
Feature description
BitInputArchive contains() and find() should have an ignoreCase option.
currently the
contains()
andfind()
of the BitInputArchive class do case-sensitive comparison.e.g. if to_search is
ABC\xyz.txt
and archive containsAbc\Xyz.txt
, it won't find it.BitFileCompressor.compressFiles() too, fails if the
in_dir
differs in case with the actual path on the disk.e.g.
in_dir
argument isC:\Temp\MYFOLDER
whereas the actual path on the disk isC:\TEMP\MyFolder
, the archive creation fails with 'path not found' :-oOn Windows this poses a problem where the clients can specify the file name (
path
param) in any case (lower, upper, camel, whatever) and the underlying api must work.There might be other places where the path comparison is done case sensitively.
Requesting you to please find a way so that users don't have to worry about the case-sensitivity during any operation/comparison related to paths / file names e.g. a platform specific
#define
or something.Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: