[mythtv] Programming help.
Jeff
jeff3140 at gmail.com
Fri May 20 20:38:17 UTC 2005
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.
More information about the mythtv-dev
mailing list