1. Andrew Cook
  2. Ogitor

Commits

stealth977  committed 268b3d3

- While linking an external OFS file to a directory, now directory's contents are checked against external contents and only non-matching files/directories are linked (destination files/directories overrides source files/directories)
fixes #906

  • Participants
  • Parent commits 44eb57a
  • Branches default

Comments (0)

Files changed (2)

File Dependencies/OFS/include/ofs14.h

View file
  • Ignore whitespace
         OfsEntryDesc* _getDirectoryDesc(const char *filename);
         /* Retrieves file descriptor of a given file in a given directory, null if not found */
         OfsEntryDesc* _getFileDesc(OfsEntryDesc *dir_desc, std::string filename);
+        /* Retrieves file descriptor of a given child in a given directory, null if not found */
+        OfsEntryDesc* _findChild(OfsEntryDesc *dir_desc, std::string child_name);
         /* Retrieves filename from a given path */
         std::string   _extractFileName(const char *filename);
         /* Internal createDirectory implementation */

File Dependencies/OFS/source/ofs14.cpp

View file
  • Ignore whitespace
                 return OFS_INVALID_PATH;
             }
 
+            std::vector<OfsEntryDesc*> add_list;
+
             for( unsigned int i = 0; i < foreignDir->Children.size(); i++ )
             {
-                dirDesc->Children.push_back( foreignDir->Children[i] );
+                if(_findChild(dirDesc, foreignDir->Children[i]->Name ) == NULL )
+                    add_list.push_back( foreignDir->Children[i] );
             }
 
+            dirDesc->Children.insert( dirDesc->Children.end(), add_list.begin(), add_list.end() );
+
             dirDesc->Links.insert( NameOfsPtrMap::value_type( filename, _ofsptr ) );
         }
 
 
 //------------------------------------------------------------------------------
     
+    _Ofs::OfsEntryDesc* _Ofs::_findChild(OfsEntryDesc *dir_desc, std::string child_name)
+    {
+        for(unsigned int i = 0;i < dir_desc->Children.size();i++)
+        {
+            if(dir_desc->Children[i]->Name == child_name)
+            {
+                return dir_desc->Children[i];
+            }
+        }
+        return NULL;
+    }
+
+//------------------------------------------------------------------------------
+
     std::string   _Ofs::_extractFileName(const char *filename)
     {
         const char *pos = filename;