summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/util.cpp
authorandyq <andyq>2003-01-21 20:37:00 (UTC)
committer andyq <andyq>2003-01-21 20:37:00 (UTC)
commit0a6563fcc2f49857c581d9def24407a3a4ef526c (patch) (side-by-side diff)
treef1b82a4bd7582ef2cb722cffb87eecff1e1f96e6 /noncore/games/sfcave-sdl/util.cpp
parent50b5915b48fc5cbacf23e4d2b75d7a266f141a4a (diff)
downloadopie-0a6563fcc2f49857c581d9def24407a3a4ef526c.zip
opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.gz
opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.bz2
Clean up of code - fixed memory leaks (most of them) and added new custom config menu
Diffstat (limited to 'noncore/games/sfcave-sdl/util.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/util.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/noncore/games/sfcave-sdl/util.cpp b/noncore/games/sfcave-sdl/util.cpp
index 86738ad..f73e256 100644
--- a/noncore/games/sfcave-sdl/util.cpp
+++ b/noncore/games/sfcave-sdl/util.cpp
@@ -35,7 +35,7 @@ Uint32 getpixel(SDL_Surface *surface, int x, int y)
}
}
-const char *chooseRandomFile( string path, string fileType )
+string chooseRandomFile( string path, string fileType )
{
vector<string> files;
DIR *d = opendir( path.c_str() );
@@ -50,15 +50,26 @@ const char *chooseRandomFile( string path, string fileType )
// Rip extension from file
int pos = file.find( ".", 1 ) + 1;
string tmp = file.substr( pos );
- printf( "pos = %d, tmp =%s\n", pos, tmp.c_str() );
if ( tmp.size() > 0 && fileType.find( tmp ) != -1 )
{
- printf( "Matching <%s> - %s with <%s>\n", file.substr( pos ).c_str(), file.c_str(), fileType.c_str() );
files.push_back( file );
}
item = readdir( d );
}
closedir( d );
- return files[nextInt( files.size() )].c_str();
+ return files[nextInt( files.size() )];
+}
+
+
+string getHomeDir()
+{
+ string home;
+#ifdef QWS
+ home = getenv( "HOME" );
+#else
+ home = ".";
+#endif
+
+ return home;
}