From: <he...@us...> - 2009-01-20 16:06:42
|
Revision: 22 http://simspark.svn.sourceforge.net/simspark/?rev=22&view=rev Author: hedayat Date: 2009-01-20 16:06:07 +0000 (Tue, 20 Jan 2009) Log Message: ----------- Add support for having many locations for resources. Some spell corrections A little fix in cmake for building release builds. Modified Paths: -------------- trunk/spark/CMakeLists.txt trunk/spark/ChangeLog trunk/spark/lib/salt/fileclasses.cpp trunk/spark/lib/salt/fileclasses.h trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp trunk/spark/lib/zeitgeist/fileserver/fileserver.h Property Changed: ---------------- trunk/spark/ Property changes on: trunk/spark ___________________________________________________________________ Modified: svn:ignore - .project .cproject autom4te.cache configure sparkconfig.h.in Makefile.in aclocal.m4 .cdtconfigure.Build (GNU) Makefile config.status stamp-h1 libtool sparkconfig.h + .project .cproject autom4te.cache configure sparkconfig.h.in Makefile.in aclocal.m4 .cdtconfigure.Build (GNU) Makefile config.status stamp-h1 libtool sparkconfig.h .settings Modified: trunk/spark/CMakeLists.txt =================================================================== --- trunk/spark/CMakeLists.txt 2009-01-14 14:38:57 UTC (rev 21) +++ trunk/spark/CMakeLists.txt 2009-01-20 16:06:07 UTC (rev 22) @@ -72,7 +72,7 @@ ########## add extra flags ########## -set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_BUILD_TYPE Debug CACHE STRING "Release or Debug build type") add_definitions(-DHAVE_CONFIG_H) include_directories(${CMAKE_BINARY_DIR}) if (UNIX) Modified: trunk/spark/ChangeLog =================================================================== --- trunk/spark/ChangeLog 2009-01-14 14:38:57 UTC (rev 21) +++ trunk/spark/ChangeLog 2009-01-20 16:06:07 UTC (rev 22) @@ -1,3 +1,20 @@ +2009-01-20 Hedayat Vatankhah <he...@gr...> + + * lib/zeitgeist/fileserver/fileserver.h: + * lib/zeitgeist/fileserver/fileserver.cpp: + - added new function: AddResourceLocation to support many resource + locations + - some spell corrections + +2009-01-19 Hedayat Vatankhah <he...@gr...> + + * CMakeLists.txt: + - fixed selecting build type from cmake command line + + * lib/salt/fileclasses.h: + * lib/salt/fileclasses.cpp: + - remove some warnings using const char* variables + 2008-12-19 Hedayat Vatankhah <he...@gr...> * lib/oxygen/agentaspect/effector.cpp: Modified: trunk/spark/lib/salt/fileclasses.cpp =================================================================== --- trunk/spark/lib/salt/fileclasses.cpp 2009-01-14 14:38:57 UTC (rev 21) +++ trunk/spark/lib/salt/fileclasses.cpp 2009-01-20 16:06:07 UTC (rev 22) @@ -90,7 +90,7 @@ // MemFile //------------------------------------------------------------------------------------------------ -MemFile::MemFile(const char *fn, char *mode) +MemFile::MemFile(const char *fn, const char *mode) { if(fn==NULL) { @@ -132,7 +132,7 @@ Destroy(); } -bool MemFile::Open(const char *fn, char *mode) +bool MemFile::Open(const char *fn, const char *mode) { if(fn==NULL) return false; @@ -280,7 +280,7 @@ mHandle=h; } -StdFile::StdFile(const char* fn,char* mode) +StdFile::StdFile(const char* fn,const char* mode) { mHandle=NULL; //open file @@ -308,7 +308,7 @@ mHandle = NULL; } -bool StdFile::Open(const char* fileName,char* mode) +bool StdFile::Open(const char* fileName,const char* mode) { //Open fn with mode mode if(fileName==NULL) Modified: trunk/spark/lib/salt/fileclasses.h =================================================================== --- trunk/spark/lib/salt/fileclasses.h 2009-01-14 14:38:57 UTC (rev 21) +++ trunk/spark/lib/salt/fileclasses.h 2009-01-20 16:06:07 UTC (rev 22) @@ -64,7 +64,7 @@ /** opens the file fn in the specified mode. The implementation of * the namespace and mode semantics ist up to derived classes */ - virtual bool Open(const char*fn=NULL, char*mode="rb") = 0; + virtual bool Open(const char* fn=NULL, const char* mode="rb") = 0; /** closes a previously opened file */ virtual void Close() = 0; @@ -181,12 +181,12 @@ class MemFile : public RFile { public: - MemFile(const char*fn=NULL, char*mode="rb"); + MemFile(const char*fn=NULL, const char*mode="rb"); MemFile(FILE*f); MemFile(RFile *f); ~MemFile(); - bool Open(const char*fn=NULL, char*mode="rb"); + bool Open(const char* fn=NULL, const char* mode="rb"); bool Open(void*buffer, long s); void Close(); void Destroy(); @@ -310,10 +310,10 @@ { public: StdFile(FILE*f); - StdFile(const char*fn=NULL, char*mode="rb"); + StdFile(const char* fn = NULL, const char* mode = "rb"); virtual ~StdFile(); - bool Open(const char*fn=NULL, char*mode="rb"); + bool Open(const char*fn=NULL, const char* mode="rb"); void Close(); void Destroy(); Modified: trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp =================================================================== --- trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp 2009-01-14 14:38:57 UTC (rev 21) +++ trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp 2009-01-20 16:06:07 UTC (rev 22) @@ -31,12 +31,18 @@ FileServer::FileServer() : Node(), mNextHandle(1) { + mResourceLocations.push_back(salt::RFile::BundlePath()); } FileServer::~FileServer() { } +void FileServer::AddResourceLocation(const std::string& path) +{ + mResourceLocations.push_back(path + salt::RFile::Sep()); +} + bool FileServer::LocateResource(const std::string& inName, std::string& outName) { if (Exist(inName)) @@ -45,16 +51,19 @@ return true; } - string fname = salt::RFile::BundlePath() + inName; + for (unsigned i = 0; i < mResourceLocations.size(); ++i) + { + string fname = mResourceLocations[i] + inName; - if (Exist(fname)) - { - GetLog()->Debug() << "(FileServer::LocateResource) expanded filename to '" - << fname << "'\n"; + if (Exist(fname)) + { + GetLog()->Debug() << "(FileServer::LocateResource) expanded filename to '" + << fname << "'\n"; - outName = fname; - return true; - } + outName = fname; + return true; + } + } GetLog()->Debug() << "FileServer::LocateResource) unable to locate resource '" Modified: trunk/spark/lib/zeitgeist/fileserver/fileserver.h =================================================================== --- trunk/spark/lib/zeitgeist/fileserver/fileserver.h 2009-01-14 14:38:57 UTC (rev 21) +++ trunk/spark/lib/zeitgeist/fileserver/fileserver.h 2009-01-20 16:06:07 UTC (rev 22) @@ -52,7 +52,7 @@ #ifndef ZEITGEIST_FILESERVER_H #define ZEITGEIST_FILESERVER_H -#include <list> +#include <vector> #include <zeitgeist/node.h> #include "filesystem.h" @@ -94,7 +94,12 @@ FileServer(); ~FileServer(); - /** tests for the existance of the given file at well known + /** + * adds a new location to the list of resource locations + */ + void AddResourceLocation(const std::string& path); + + /** tests for the existence of the given file at well known locations. On success the function returns true. In this case outName is set to the full path to the file. */ @@ -152,7 +157,7 @@ /** iterates through files. 'directory', 'name' and * 'extension' give directory, name and extension a file must - * match. directory,name and extension may be NULL, in wich + * match. directory,name and extension may be NULL, in which * case every directory,extension and/or name matches. For * each match the function callback is called with the name * of the matched file and the additional user parameter @@ -179,6 +184,9 @@ /** the next free handle */ THandle mNextHandle; + + /** list of resource locations */ + std::vector<std::string> mResourceLocations; }; DECLARE_CLASS(FileServer) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |