The PLIB general Utility Library.
By Steve Baker
Introduction.
The 'UL' utility library is primarily targetted towards hiding common
operating system functions behind a thin layer that makes them portable.
For example, if you need to 'sleep' for 3 seconds, then under Linux/UNIX,
you'd need to call:
sleep ( 3 ) ;
But under MS-Windows, you have to say:
Sleep ( 3000 ) ;
In order to avoid writing non-portable code, you can instead call:
ulSleep ( 3 ) ;
...or...
ulMilliSecondSleep ( 3000 ) ;
...under either operating system.
One ultility function is:
void ulFindFile( char *filenameOutput, const char *path,
const char * tfnameInput, const char *sAPOM )
Basically, it adds tfnameInput to the path and puts this into the buffer filenameOutput.
It handles special chars in path.
sAPOM
is used iff path contains "$(APOM)"
These are the special chars:
";;" is replaced by ";"
"$$" is replaced by "$"
"$(APOM)" is replaced by sAPOM
If there are ";" in path, the path-variable is interpreted as several paths "segments",
delimited by ";". The first file found by this function is returned.
It looks from left to right.
A segment may end in $(...). ulFindFile will then look in in this path and recursively in all the sub-paths
Some examples:
To load *.MDl-models, it is very nice to set the texture path to
$(APOM);$(APOM)/texture;$(APOM)/../texture
This contains of three segments and tells ulFindFile to look in the
path of the model, in a subpath texture and in a path texture "besides" the path of the model
Some *.mdl-models are shipped in a directory which conatins a "texture"-directory, a
"Model"-directory and others. In this case you find the texture in $(APOM)/../texture
Another example: You have all your textures in a driectory-structure under /raumplan:
textures --+-- Wallpapers
|
+-- Wood --+-- Oak
| |
| +-- pine
...
Then you should simply use the following texture path:
"/raumplan/$(...)"
If you dont want all of the bells and whistles, just call:
_ssgMakePath ( filenameOutput, path, tfnameInput ) ;
instead.
UL is a part of PLIB.
Steve J. Baker.
<sjbaker1@airmail.net>