David Rose 25 лет назад
Родитель
Сommit
88bbace622
2 измененных файлов с 32 добавлено и 0 удалено
  1. 30 0
      dtool/src/dtoolutil/dSearchPath.cxx
  2. 2 0
      dtool/src/dtoolutil/dSearchPath.h

+ 30 - 0
dtool/src/dtoolutil/dSearchPath.cxx

@@ -6,6 +6,8 @@
 #include "dSearchPath.h"
 #include "filename.h"
 
+#include <algorithm>
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DSearchPath::Results::Constructor
 //       Access: Public
@@ -177,6 +179,34 @@ append_path(const string &path, const string &delimiters) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DSearchPath::append_path
+//       Access: Public
+//  Description: Adds all of the directories listed in the search path
+//               to the end of the search list.
+////////////////////////////////////////////////////////////////////
+void DSearchPath::
+append_path(const DSearchPath &path) {
+  copy(path._directories.begin(), path._directories.end(),
+       back_inserter(_directories));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DSearchPath::prepend_path
+//       Access: Public
+//  Description: Adds all of the directories listed in the search path
+//               to the beginning of the search list.
+////////////////////////////////////////////////////////////////////
+void DSearchPath::
+prepend_path(const DSearchPath &path) {
+  if (!path._directories.empty()) {
+    Directories new_directories = path._directories;
+    copy(_directories.begin(), _directories.end(),
+	 back_inserter(new_directories));
+    _directories.swap(new_directories);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DSearchPath::is_empty
 //       Access: Public

+ 2 - 0
dtool/src/dtoolutil/dSearchPath.h

@@ -52,6 +52,8 @@ PUBLISHED:
   void prepend_directory(const Filename &directory);
   void append_path(const string &path,
 		   const string &delimiters = ": \t\n");
+  void append_path(const DSearchPath &path);
+  void prepend_path(const DSearchPath &path);
 
   bool is_empty() const;
   int get_num_directories() const;