Anonymous avatar Anonymous committed 844aa4a

- small bug fixes for new OFS Feature (LINKS)
- Now if a file system link doesnt work somehow, it is logged as critical message and removed from File System Links

Comments (0)

Files changed (2)

Dependencies/OFS/source/ofs14.cpp

 
     OfsResult _Ofs::linkFileSystem(const char *filename, const char *directory)
     {
-        OfsEntryDesc *dirDesc = _getDirectoryDesc(directory);
+        std::string dest_dir = directory;
+        if(dest_dir[dest_dir.length() - 1] != '/')
+            dest_dir += "/";
+
+        OfsEntryDesc *dirDesc = _getDirectoryDesc(dest_dir.c_str());
 
         if(dirDesc == NULL)
             return OFS_INVALID_PATH;
             {
                 fileSystemName = name.substr(0, pos);
                 name.erase(0, pos + 2);
-                if(name[name.length() - 1] == '/')
-                    name.erase(name.length() - 1, 1);
+                if(name[name.length() - 1] != '/')
+                    name += "/";
             }
             else
                 name = "/";
                 dirDesc->Children.push_back( foreignDir->Children[i] );
             }
 
-            UuidDescMap::iterator it = _ofsptr->mUuidMap.begin();
-
-            while( it != _ofsptr->mUuidMap.end() )
+            UuidDescMap::iterator uit = _ofsptr->mUuidMap.begin();
+
+            while( uit != _ofsptr->mUuidMap.end() )
             {
-                if(mUuidMap.find(it->first) == mUuidMap.end())
-                    mUuidMap.insert( UuidDescMap::value_type(it->first, it->second) );
-
-                it++;
+                if(mUuidMap.find(uit->first) == mUuidMap.end())
+                    mUuidMap.insert( UuidDescMap::value_type(uit->first, uit->second) );
+
+                uit++;
             }
 
             dirDesc->Links.insert( NameOfsPtrMap::value_type( filename, _ofsptr ) );
             if( pos > -1 )
             {
                 name.erase(0, pos + 2);
-                if(name[name.length() - 1] == '/')
-                    name.erase(name.length() - 1, 1);
+                if(name[name.length() - 1] != '/')
+                    name += "/";
             }
             else
                 name = "/";
                 }
             }
 
-            UuidDescMap::iterator oit = (it->second)->mUuidMap.begin();
-
-            while( oit != (it->second)->mUuidMap.end() )
+            UuidDescMap::iterator uit = (it->second)->mUuidMap.begin();
+
+            while( uit != (it->second)->mUuidMap.end() )
             {
-                UuidDescMap::iterator bit = mUuidMap.find(oit->first);
+                UuidDescMap::iterator bit = mUuidMap.find(uit->first);
                 if( bit != mUuidMap.end())
                     mUuidMap.erase( bit );
 
-                it++;
+                uit++;
             }
 
             dirDesc->Links.erase( it );
 
         if(dirDesc->Parent != NULL)
         {
+            NameOfsPtrMap::iterator it = dirDesc->Links.begin();
+
+            while( it != dirDesc->Links.end() )
+            {
+                std::string name = it->first;
+
+                int pos = name.find("::");
+
+                if( pos > -1 )
+                {
+                    name.erase(0, pos + 2);
+                    if(name[name.length() - 1] == '/')
+                        name.erase(name.length() - 1, 1);
+                }
+                else
+                    name = "/";
+
+                OfsEntryDesc *foreignDir = (it->second)->_getDirectoryDesc(name.c_str());
+
+                for( unsigned int i = 0; i < foreignDir->Children.size(); i++ )
+                {
+                    for( unsigned int k = 0; k < dirDesc->Children.size(); k++ )
+                    {
+                        if( dirDesc->Children[k] == foreignDir->Children[i] )
+                        {
+                            dirDesc->Children.erase( dirDesc->Children.begin() + k );
+                            break;
+                        }
+                    }
+                }
+
+                UuidDescMap::iterator uit = (it->second)->mUuidMap.begin();
+
+                while( uit != (it->second)->mUuidMap.end() )
+                {
+                    UuidDescMap::iterator bit = mUuidMap.find(uit->first);
+                    if( bit != mUuidMap.end())
+                        mUuidMap.erase( bit );
+
+                    uit++;
+                }
+
+                it++;
+            }
+
             OfsResult ret = _deleteDirectory(dirDesc);
 
             mStream.flush();

Ogitor/src/OgitorsRoot.cpp

         data.FileSystem = ValidAttr(element->Attribute("filesystem"));
         data.Directory = ValidAttr(element->Attribute("directory"));
         
-        mProjectOptions.FileSystemLinks.push_back(data);
+        if( (*mProjectFile)->linkFileSystem(data.FileSystem.c_str(), data.Directory.c_str()) == OFS::OFS_OK)
+            mProjectOptions.FileSystemLinks.push_back(data);
+        else
+        {
+            Ogre::String msg = "Could not link File System \"";
+            msg += data.FileSystem;
+            msg += "\" to directory \"";
+            msg += data.Directory;
+            msg += "\"";
 
-        (*mProjectFile)->linkFileSystem(data.FileSystem.c_str(), data.Directory.c_str());
+            Ogre::LogManager::getSingletonPtr()->logMessage( Ogre::LML_CRITICAL, msg );
+        }
+
     } while(element = element->NextSiblingElement());
     
     return true;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.