Index: /OpenSceneGraph/trunk/include/osgDB/FileUtils
===================================================================
--- /OpenSceneGraph/trunk/include/osgDB/FileUtils (revision 10171)
+++ /OpenSceneGraph/trunk/include/osgDB/FileUtils (revision 10818)
@@ -41,4 +41,10 @@
 extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath );
     
+// Get current working directory.
+extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void );
+
+// Set current working directory.
+extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory );
+
 
 /** return true if a file exists. */
@@ -91,5 +97,5 @@
 extern OSGDB_EXPORT std::string findLibraryFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
 
-/** convert a string containing a list of paths  delimited either with ';' (Windows) or ':' (All other platforms) into FilePath representation.*/
+/** convert a string containing a list of paths delimited either with ';' (Windows) or ':' (All other platforms) into FilePath representation.*/
 extern OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath);
 
Index: /OpenSceneGraph/trunk/src/osgDB/FileUtils.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgDB/FileUtils.cpp (revision 10171)
+++ /OpenSceneGraph/trunk/src/osgDB/FileUtils.cpp (revision 10818)
@@ -11,4 +11,13 @@
  * OpenSceneGraph Public License for more details.
 */
+
+// handle TCHAR type on various platforms
+// #ifndef is inspired by https://svn.apache.org/repos/asf/logging/log4cxx/tags/v0_9_4/include/log4cxx/helpers/tchar.h
+// defining type as plain char is from unzip.h, line 64
+
+#ifndef TCHAR
+typedef char TCHAR;
+#endif
+
 
 // currently this impl is for _all_ platforms, except as defined.
@@ -194,4 +203,40 @@
     return makeDirectory( getFilePath( path ));
 }
+
+
+std::string osgDB::getCurrentWorkingDirectory( void )
+{
+    // MAX_PATH/cwd inspired by unzip.cpp
+#ifndef MAX_PATH
+    #define MAX_PATH 1024
+#endif
+    TCHAR rootdir[MAX_PATH];
+    if(getcwd(rootdir,MAX_PATH-1))
+    {
+        return(rootdir);
+    }
+    return("");
+}// osgDB::getCurrentWorkingDirectory
+
+
+
+bool osgDB::setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory )
+{
+    if (newCurrentWorkingDirectory.empty())
+    {
+        osg::notify(osg::DEBUG_INFO) << "osgDB::setCurrentWorkingDirectory(): called with empty string." << std::endl;
+        return false;
+    }
+    
+#ifdef OSG_USE_UTF8_FILENAME
+    return _wchdir( OSGDB_STRING_TO_FILENAME(newCurrentWorkingDirectory).c_str()) == 0;
+#else
+    return chdir( newCurrentWorkingDirectory.c_str()) == 0;
+#endif
+
+    return true;
+} // osgDB::setCurrentWorkingDirectory
+
+
 
 void osgDB::convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath)
Index: /OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp (revision 9884)
+++ /OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp (revision 10818)
@@ -251,4 +251,8 @@
 #endif
 
+    if(left.empty())
+    {
+        return(right);
+    }
     char lastChar = left[left.size() - 1];
 
