Browse Source

Make resource dirs absolute when added to ResourceCache. Sanitate away /./ construct from the runtime program dir and resource dirs. Closes #64

Lasse Öörni 12 years ago
parent
commit
7d83a44d13
2 changed files with 9 additions and 0 deletions
  1. 3 0
      Source/Engine/IO/FileSystem.cpp
  2. 6 0
      Source/Engine/Resource/ResourceCache.cpp

+ 3 - 0
Source/Engine/IO/FileSystem.cpp

@@ -478,6 +478,9 @@ String FileSystem::GetProgramDir() const
         DirExists(currentDir + "Data")))
         DirExists(currentDir + "Data")))
         programDir_ = currentDir;
         programDir_ = currentDir;
     
     
+    // Sanitate /./ construct away
+    programDir_.Replace("/./", "/");
+    
     return programDir_;
     return programDir_;
 }
 }
 
 

+ 6 - 0
Source/Engine/Resource/ResourceCache.cpp

@@ -79,7 +79,13 @@ bool ResourceCache::AddResourceDir(const String& pathName)
         return false;
         return false;
     }
     }
     
     
+    // Convert path to absolute
     String fixedPath = AddTrailingSlash(pathName);
     String fixedPath = AddTrailingSlash(pathName);
+    if (!IsAbsolutePath(fixedPath))
+        fixedPath = fileSystem->GetCurrentDir() + fixedPath;
+    
+    // Sanitate away /./ construct
+    fixedPath.Replace("/./", "/");
     
     
     // Check that the same path does not already exist
     // Check that the same path does not already exist
     for (unsigned i = 0; i < resourceDirs_.Size(); ++i)
     for (unsigned i = 0; i < resourceDirs_.Size(); ++i)