[mythtv] Programming help.

Devan Lippman devan.lippman at gmail.com
Fri May 20 23:21:02 UTC 2005


oops, 
for(int i = 1; i < match.length() && !result; i++) result = 
ismatch(filename, match.substr(1));
 should be 
for(int i = 0; i < filename.length()-match.length() && !result; i++) result 
= ismatch(filename.substr(i), match.substr(1));
 guess its friday...
 Devan
 On 5/20/05, Devan Lippman <devan.lippman at gmail.com> wrote: 
> 
> write a function ismatch() that will take two strings and compare them 
> recursivly with wildcard support. so for example a call could look like 
> this:
> ismatch("Giana 01.adf", "Giana*.adf")
> which would call itself 
> ismatch("iana 01.adf", "iana*.adf")
> ismatch("ana 01.adf", "ana*.adf")
> ...
> ismatch(" 01.adf", "*.adf")
> and then at the wildcard call
> ismatch(" 01.adf", ".adf")
> ismatch("01.adf", ".adf")
> ismatch("1.adf", ".adf")
> ismatch(".adf", ".adf")
> 
> something like this:
> bool ismatch(string filename, string match) 
> {
> bool result = false;
> if(match[0] == '*')
>  {
> for(int i = 1; i < match.length() && !result; i++) result = 
> ismatch(filename, match.substr(1));
> if(match.length() == 1) return true;
>  return result;
>  }
> if(match.length() == 1 && match == filename) return true;
>  return match[0] == filename[0] && ismatch(filename.substr(1), 
> match.substr(1));
> }
>  actually thats horrible, but it probably work it you convert it from my 
> made up language to C++.
>  Devan
>  
> 
> On 5/20/05, Jeff <jeff3140 at gmail.com> wrote:
> > On 5/20/05, Jochen Kühner <jochen.kuehner at gmx.de> wrote:
> > 
> > > QFileInfo Info(*it.current());
> > >
> > > {
> > >
> > > for (QStringList::Iterator i = rom_extensions.begin(); i !=
> > > rom_extensions.end(); 
> > >
> > > {
> > >
> > > if(Info.extension(false).lower() == *i)
> > >
> > > {
> > >
> > > GameName = Info.baseName(false);
> > >
> > > bRomFound = true;
> > >
> > > break;
> > >
> > > }
> > >
> > > } 
> > >
> > > }
> > >
> > >
> > > This procedure get all the amiga disk images. But the Problem is, that 
> I
> > > need only one if the File name is for Exampe: "Giana 01.adf" "Giana 
> 02.adf"
> > > "Giana 03.adf" or "Summer1.adf" "Summer2.adf".
> > >
> > >
> > >
> > > I need one filename (as best without the number) and a counter how 
> many 
> > > files ther are
> > >
> > > Like: fnm = "Giana 0" , counter = 3 Fnm="Summer" counter = 2
> > >
> > >
> > 
> > Here is a solution, its not difficult but its not easy. 
> > 
> > If all the files have names of the format
> > <game name><optional whitespace><numerics>.adf
> > Then you need to have a variable outside the loop which you initialize
> > to null that tracks the current <game name>. 
> > 
> > Inside the loop where you get a file name you scan it from the end
> > backwards starting with the character preceeding ".adf" until you find a
> > non-numeric, non-whitespace character. This is the end of the game name. 
> 
> > 
> > If the string you have matches the current game name then you increment
> > the count of the # of files for this game. If it doesn't then you know
> > you've found
> > all the files for the current game and you record it. 
> > 
> > Then you set the current game name to the new one, the file count to 1 
> and get
> > the next filename.
> > 
> > All of this could be embedded in a method which returns the next game 
> name
> > and the # of files it consists of. This would need to be in a class 
> > which contains
> > the file pointer and storage for the current game name field. The 
> current game
> > name field holds the next game name which will be processed when the 
> file
> > is read. This would be null for the 1st invocation after the file is 
> > opened. There
> > probably has to be an EOF indicator in the class as well.
> > _______________________________________________
> > mythtv-dev mailing list
> > mythtv-dev at mythtv.org
> > http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
> > 
> 
> 
> -- 
> Thanks,
> Devan Lippman < devan at lippman.net>
> 



-- 
Thanks,
Devan Lippman <devan at lippman.net>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20050520/f58e401c/attachment.htm


More information about the mythtv-dev mailing list