Filename Checker / Changer searched for Porting Windows Game to SDL

Hello !

I am working on porting a game from Windows to SDL and
going crazy about LOTS of wrong filenames in the source.

Windows ist not case sensitive, so the original coder had no
problems.

As there are some big porters here, is there any ready
to use shell script to do this work, searching a list of filenames
in a number of .c/.cpp/*.h and chaning them to the correct one ?

CU

Torsten Giebl wrote:

I am working on porting a game from Windows to SDL and
going crazy about LOTS of wrong filenames in the source.

As there are some big porters here, is there any ready
to use shell script to do this work, searching a list of filenames
in a number of .c/.cpp/*.h and chaning them to the correct one ?

I usually have more problems with the slashes and backslashes than the case
sensitivity in filenames when porting. If I need to check for filenames,
I’ll just use grep and do a few regular expression searches for slashes,
backslashes, etc. usually within quotes or single quotes. You could
automate replacing using sed, perl or gsar. I usually want to look at the
code and replace it by hand to make sure it’s doing what I want it to do.
If you like a GUI for search, you could check out Searchmonkey.

Sincerely,
Laura
http://www.distasis.com/cpp/patches.htm

I don’t get how file names are a big deal. A port takes a replacement of
the basis of how all graphics, sound, and input get asked for and output.
The other stuff is all golden right? So like If I wanted a bmp of a smiley
face to be on the screen I would get it with an sdl function, store it in
an sdl, container, and use sdl to blit that image to the screen. The
filename that would change would be that I add the sdl include stuff and
remove all non cross platform stuff right?On Tue, Feb 14, 2012 at 2:27 PM, LM wrote:

Torsten Giebl wrote:

I am working on porting a game from Windows to SDL and
going crazy about LOTS of wrong filenames in the source.

As there are some big porters here, is there any ready
to use shell script to do this work, searching a list of filenames
in a number of .c/.cpp/*.h and chaning them to the correct one ?

I usually have more problems with the slashes and backslashes than the
case sensitivity in filenames when porting. If I need to check for
filenames, I’ll just use grep and do a few regular expression searches for
slashes, backslashes, etc. usually within quotes or single quotes. You
could automate replacing using sed, perl or gsar. I usually want to look
at the code and replace it by hand to make sure it’s doing what I want it
to do. If you like a GUI for search, you could check out Searchmonkey.

Sincerely,
Laura
http://www.distasis.com/cpp/patches.htm


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It is a big deal sometimes. It’s a common result of ignorant (of
crossplatform filesystem restrictions) programming. #include directives
are affected in addition to string file names.

I do a project-wide find with #include first. A quote search might turn up
file name strings. That’s the best I have. Anyhow, Torsten is probably
already done with this phase of the port.

Jonny DOn Mon, Feb 27, 2012 at 1:20 AM, R Manard wrote:

I don’t get how file names are a big deal. A port takes a replacement of
the basis of how all graphics, sound, and input get asked for and output.
The other stuff is all golden right? So like If I wanted a bmp of a smiley
face to be on the screen I would get it with an sdl function, store it in
an sdl, container, and use sdl to blit that image to the screen. The
filename that would change would be that I add the sdl include stuff and
remove all non cross platform stuff right?

On Tue, Feb 14, 2012 at 2:27 PM, LM wrote:

Torsten Giebl wrote:

I am working on porting a game from Windows to SDL and
going crazy about LOTS of wrong filenames in the source.

As there are some big porters here, is there any ready
to use shell script to do this work, searching a list of filenames
in a number of .c/.cpp/*.h and chaning them to the correct one ?

I usually have more problems with the slashes and backslashes than the
case sensitivity in filenames when porting. If I need to check for
filenames, I’ll just use grep and do a few regular expression searches for
slashes, backslashes, etc. usually within quotes or single quotes. You
could automate replacing using sed, perl or gsar. I usually want to look
at the code and replace it by hand to make sure it’s doing what I want it
to do. If you like a GUI for search, you could check out Searchmonkey.

Sincerely,
Laura
http://www.distasis.com/cpp/patches.htm


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello !

I don’t get how file names are a big deal. A port takes a replacement of
the basis of how all graphics, sound, and input get asked for and output.
The other stuff is all golden right? So like If I wanted a bmp of a smiley
face to be on the screen I would get it with an sdl function, store it in
an sdl, container, and use sdl to blit that image to the screen. The
filename that would change would be that I add the sdl include stuff and
remove all non cross platform stuff right?

The problem comes, when writing a game or an app for a none file case sensitive OS like Windows,
without having porting to other OSes in mind.

In a Windows source it makes no difference if you write #include “SDL.h” or #include “sdl.h” or #include “myown.h” or
#include “MyOwn.h”. As the Windows Filesystem is not case sensitive it just works, but on Linux and Mac OSX it fails badly.
The same is true for game data files, like Bitmaps, Sounds, …

Thanks to Linux and OSX, you have great scripting possibilities there, so you can write shell scripts to help you out.

In my case, the real filename was for example Trigger_Tube.h, but some .h files had an #include “trigger_tube.h”, some
had an #include “Trigger_tube.h”. My way then was to rename the files, using a scheme like, Trigger_Tube.h
and then generating a list of all the *.h files and searching none case sensitive
with awk automatically in every .h/.cpp for lines with those names and replacing those parts with the filename from the
list.

I was just asking the question on this list, because here are some great porters like Ryan Gordon who do this for living
and i was interested, if they had an elegant solution or already built tool/script.

CU

This kind of strikes me as a one-time cost that is so small that the time
it takes to just go and make the changes manually/roll your own script
would be so much less than waiting a couple of days on a mailing list for a
useful script.On Mon, Feb 27, 2012 at 6:04 PM, Torsten Giebl wrote:

Hello !

I don’t get how file names are a big deal. A port takes a replacement of
the basis of how all graphics, sound, and input get asked for and output.
The other stuff is all golden right? So like If I wanted a bmp of a
smiley
face to be on the screen I would get it with an sdl function, store it in
an sdl, container, and use sdl to blit that image to the screen. The
filename that would change would be that I add the sdl include stuff and
remove all non cross platform stuff right?

The problem comes, when writing a game or an app for a none file case
sensitive OS like Windows,
without having porting to other OSes in mind.

In a Windows source it makes no difference if you write #include "SDL.h"
or #include “sdl.h” or #include “myown.h” or
#include “MyOwn.h”. As the Windows Filesystem is not case sensitive it
just works, but on Linux and Mac OSX it fails badly.
The same is true for game data files, like Bitmaps, Sounds, …

Thanks to Linux and OSX, you have great scripting possibilities there, so
you can write shell scripts to help you out.

In my case, the real filename was for example Trigger_Tube.h, but some .h
files had an #include “trigger_tube.h”, some
had an #include “Trigger_tube.h”. My way then was to rename the files,
using a scheme like, Trigger_Tube.h
and then generating a list of all the *.h files and searching none case
sensitive
with awk automatically in every .h/.cpp for lines with those names and
replacing those parts with the filename from the
list.

I was just asking the question on this list, because here are some great
porters like Ryan Gordon who do this for living
and i was interested, if they had an elegant solution or already built
tool/script.

CU


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello !

This kind of strikes me as a one-time cost that is so small that the time
it takes to just go and make the changes manually

Even in the small project i was working on, it would be horrible to do it manually.
Counting includes + data filenames.

roll your own script

But not everybody is able to write his own scripts to do it.
This is some kind of infrastructure question like bugtrackers,
sourcecode revision control, …

would be so much less than waiting a couple of days on a mailing list for a
useful script.

Personally with my project, i am done, but i would be still interested in some utility,
perl script, shell script, that checks all text files in a given directory + recursive directorys.

I solved it with some easy tuned script for my purpose, but a shellscript god could do something much better
for general usage.

Web Designers may have the same problem, when a project is coming from a windows web developer.

CU

I see. Since I’m alllll about spending the time to make code that does
stuff that would otherwise take ten seconds, I think I understand. I would
make a program that reads all of the filenames and then uses each to open
the file and parse the contents. I would read non case sensitive and I’d
lowercase all file names in every instance inside the files. If you’re not
sure where to start this might get you started in windows:
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
printf (“Target file is C:\code\minion_client \n”);
hFind = FindFirstFile(“C:\code\minion_client\*”, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{printf (“Invalid File Handle. GetLastError reports %d\n”, GetLastError
());}
else
{
printf (“The first file found is %s\n”, FindFileData.cFileName);
// List all the other files in the directory.
while (FindNextFile(hFind, &FindFileData) != 0)
{printf (TEXT(“Next file name is: %s\n”), FindFileData.cFileName);}
FindClose(hFind);
}
And the normal C++ string stuff from google can fill in the gaps on how to
parse. Lot’s of people do this sort of parse so it may be that (if you want
to ruin the fun and learning) you can just use their finished code that
does exactly what you want.On Mon, Feb 27, 2012 at 7:49 AM, Jonathan Dearborn wrote:

It is a big deal sometimes. It’s a common result of ignorant (of
crossplatform filesystem restrictions) programming. #include directives
are affected in addition to string file names.

I do a project-wide find with #include first. A quote search might turn
up file name strings. That’s the best I have. Anyhow, Torsten is probably
already done with this phase of the port.

Jonny D

On Mon, Feb 27, 2012 at 1:20 AM, R Manard <@R_Manard> wrote:

I don’t get how file names are a big deal. A port takes a replacement of
the basis of how all graphics, sound, and input get asked for and output.
The other stuff is all golden right? So like If I wanted a bmp of a smiley
face to be on the screen I would get it with an sdl function, store it in
an sdl, container, and use sdl to blit that image to the screen. The
filename that would change would be that I add the sdl include stuff and
remove all non cross platform stuff right?

On Tue, Feb 14, 2012 at 2:27 PM, LM wrote:

Torsten Giebl wrote:

I am working on porting a game from Windows to SDL and
going crazy about LOTS of wrong filenames in the source.

As there are some big porters here, is there any ready
to use shell script to do this work, searching a list of filenames
in a number of .c/.cpp/*.h and chaning them to the correct one ?

I usually have more problems with the slashes and backslashes than the
case sensitivity in filenames when porting. If I need to check for
filenames, I’ll just use grep and do a few regular expression searches for
slashes, backslashes, etc. usually within quotes or single quotes. You
could automate replacing using sed, perl or gsar. I usually want to look
at the code and replace it by hand to make sure it’s doing what I want it
to do. If you like a GUI for search, you could check out Searchmonkey.

Sincerely,
Laura
http://www.distasis.com/cpp/patches.htm


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Cave Story and one other game (can’t remember its name) that
were part of the Humble Indie Bundles and were ported to Linux using SDL
would crash in the middle or towards the end of the game because of
Linux
having a case sensitive file system and a misspelled data file. True
story.

But that’s just because obviously nobody bothered to playtest the Linux
ports from beginning to end. A single testing session would reveal all
filename bugs within an application – and a port should be tested
thoroughly
anyways so I don’t really see a necessity for such a script.

But hey, if I was porting shit from Windows on a regular basis, I’d
probably write one.

Atis> ----- Original Message -----

From: wizard@syntheticsw.com (Torsten Giebl)
To: SDL Development List
Sent: Tue, 28 Feb 2012 3:46
Subject: Re: [SDL] Filename Checker / Changer searched for Porting
Windows Game to SDL

Hello !

This kind of strikes me as a one-time cost that is so small that the
time
it takes to just go and make the changes manually

Even in the small project i was working on, it would be horrible to do
it
manually.
Counting includes + data filenames.

roll your own script

But not everybody is able to write his own scripts to do it.
This is some kind of infrastructure question like bugtrackers,
sourcecode revision control, …

would be so much less than waiting a couple of days on a mailing list
for a
useful script.

Personally with my project, i am done, but i would be still interested
in some
utility,
perl script, shell script, that checks all text files in a given
directory +
recursive directorys.

I solved it with some easy tuned script for my purpose, but a
shellscript god
could do something much better
for general usage.

Web Designers may have the same problem, when a project is coming from
a windows
web developer.

CU


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It’s a question: Is a quick solution out there for me? If not, then the
community would be well-served by one if anybody is so inclined to write
it. I expect that the OP knows how long doing it by hand takes and would
prefer not to, if possible. So it’s not really helpful to imply that it
takes a trivial effort.

The necessity for the script is for reducing the mind-numbing part of
porting, which I’m all for. Play-testing does not fix compiler errors on
missing headers and a play-through of Cave Story that crashes on each
incorrect file name would take a very long time. There are better ways…
such as automating it.

Jonny D