Revision: 7512
http://playerstage.svn.sourceforge.net/playerstage/?rev=7512&view=rev
Author: hsujohnhsu
Date: 2009-03-17 01:25:57 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
update XML config to get search include files from relative path automatically.
Modified Paths:
--------------
code/gazebo/branches/ogre-1.4.9/server/XMLConfig.cc
Modified: code/gazebo/branches/ogre-1.4.9/server/XMLConfig.cc
===================================================================
--- code/gazebo/branches/ogre-1.4.9/server/XMLConfig.cc 2009-03-17 01:23:21 UTC
(rev 7511)
+++ code/gazebo/branches/ogre-1.4.9/server/XMLConfig.cc 2009-03-17 01:25:57 UTC
(rev 7512)
@@ -513,29 +513,59 @@
///////////////////////////////////////////////////////////////////////////
// Get a file name. Always returns an absolute path. If the filename
// is entered as a relative path, we prepend the world file path.
+// std::string XMLConfigNode::GetFilename( const std::string &key, const
std::string &def, int require) const
+// {
+// std::string filename = this->GetString( key, def, require );
+//
+// if (filename.empty())
+// return "";
+//
+// if (filename[0] == '/' || filename[0] == '~')
+// return filename;
+// else
+// {
+// std::string result;
+//
+// if (this->config->filename[0] != '/' && this->config->filename[0] !=
'~')
+// result = "/";
+//
+// unsigned int last = this->config->filename.rfind("/");
+// if (last==0 || last+1 != this->config->filename.size())
+// result += this->config->filename + "/" + filename;
+// else
+// result += this->config->filename.substr(0,last) + "/" + filename;
+//
+// return result;
+// }
+// }
+///////////////////////////////////////////////////////////////////////////
+// Get a file name. Always returns an absolute path. If the filename
+// is entered as a relative path, we prepend the world file path.
+//
+// patch by stu to do relative path. FIXME: what was the original
implementation that's broken?
+// sglaser: Was completely broken. Now returns a path relative to the
+// (original) working directory.
std::string XMLConfigNode::GetFilename( const std::string &key, const
std::string &def, int require) const
{
std::string filename = this->GetString( key, def, require );
- if (filename.empty())
- return "";
+ if (filename.empty() && require)
+ {
+ gzthrow("unable to find required filename attribute[" << key << "] in
world file node["
+ << this->GetName() << "]");
+ }
+ else if (filename.empty())
+ return def;
- if (filename[0] == '/' || filename[0] == '~')
+ if (filename[0] == '/')
return filename;
else
{
- std::string result;
-
- if (this->config->filename[0] != '/' && this->config->filename[0] != '~')
- result = "/";
-
- unsigned int last = this->config->filename.rfind("/");
- if (last==0 || last+1 != this->config->filename.size())
- result += this->config->filename + "/" + filename;
+ int last_slash = this->config->filename.rfind("/");
+ if (last_slash < 0)
+ return filename;
else
- result += this->config->filename.substr(0,last) + "/" + filename;
-
- return result;
+ return this->config->filename.substr(0,last_slash) + "/" + filename;
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit