Closed eku closed 3 years ago
i am not familiar with end_with()
is it case sensitive?
and IsFileSupported(const char *File, const vector
is it case sensitive?
Yes it is. The updated implementation has been tested for case insensitivity and GC compatibility.
You may verify the function with the following test program
#include <iostream>
#include <string>
static inline bool IsFileSupported(const char *File, const char *FileType)
{
auto fileName = std::string(File);
auto fileType = std::string(FileType);
if (fileName.length() >= fileType.length())
{
return std::equal(fileName.end() - fileType.length(),
fileName.end(),
fileType.begin(),
[](const char & c1, const char & c2)
{
return (c1 == c2 ||
std::toupper(c1) ==
std::toupper(c2));
});
}
return false;
}
int main(int argc, char *argv[])
{
if (argc < 3)
{
std::cerr << "usage: " << argv[0] << " filename filetype\n";
return 1;
}
auto match = IsFileSupported(argv[1], argv[2]);
if (match)
std::cout << argv[1] << " ends with " << argv[2] << "\n";
else
std::cout << argv[1] << " ends not with " << argv[2] << "\n";
return 0;
}
Is there anything I can do to get the PR accepted?
i thought you said you were going to do it wiimpathy's way using regex?
i thought you said you were going to do it wiimpathy's way using regex?
Yes and no. I am preparing a PR for sorting out files via regex.
The change here does not have to be used for sorting out. In principle, this PR eliminates a restriction of file types to the dot three_character
known from DOS times.
Thanks for merging.
With this change WiiFlow accepts any string in
filetypes
as a file type. The file extension no longer has to contain a dot (and not more). Any text is allowed.If you do not change your configuration of
filetypes
, you will not notice any change in behaviour. However, those who make use of this can solve the problem from #274 as follows.Let's imagine we have PS1 games that are typically named like this:
Then you would write either
(Disc 1) (Track 1).bin
infiletypes
to select exactly the firstbin
of the first disc, or(Disc 1).cue
to select thecue
. For games that do not consist of multiple tracks per disc, you would write(Disc 1).bin
infiletype
. Combined, this givesfiletypes=(Disc 1) (Track 1).bin|(Disc 1).bin
.The downside of the solution is that single-disc games must also follow the naming scheme.
Never mind, you don't have to use it. With the change, everything works as before, without changes to the configuration.