AW: [mythtv] Programming help.

Jochen Kühner jochen.kuehner at gmx.de
Sat May 21 18:56:03 UTC 2005


I Think that all gets to complicated!

What If I use on regex wich extracts my from a Filename the gamename without
the number

Like: Giana 01.adf Giana02.adf Giana3.adf this function always returns
Giana.

 

Then I Check how long this Function Retirns the same Filename and so long it
adds the files to a field in the database with a increasing field numer
like: fd0 = “giana 01.af” fd1=”gina02.adf”…

Because I need the names of all the disk images!

 

The Problem for me is only the regex and how I implement a RegEx in C

 

  _____  

Von: mythtv-dev-bounces at mythtv.org [mailto:mythtv-dev-bounces at mythtv.org] Im
Auftrag von Devan Lippman
Gesendet: Samstag, 21. Mai 2005 01:21
An: Jeff; Development of mythtv
Betreff: Re: [mythtv] Programming help.

 

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 < <mailto:devan at lippman.net>  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/20050521/a0416edc/attachment.htm


More information about the mythtv-dev mailing list