Browse Source

add expand_from()

David Rose 23 years ago
parent
commit
0821c7c48a
2 changed files with 15 additions and 0 deletions
  1. 13 0
      dtool/src/dtoolutil/filename.cxx
  2. 2 0
      dtool/src/dtoolutil/filename.h

+ 13 - 0
dtool/src/dtoolutil/filename.cxx

@@ -313,6 +313,19 @@ from_os_specific(const string &os_specific, Filename::Type type) {
 #endif  // WIN32
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: Filename::expand_from
+//       Access: Public, Static
+//  Description: Returns the same thing as from_os_specific(), but
+//               embedded environment variable references
+//               (e.g. "$DMODELS/foo.txt") are expanded out.
+////////////////////////////////////////////////////////////////////
+Filename Filename::
+expand_from(const string &os_specific, Filename::Type type) {
+  return from_os_specific(ExecutionEnvironment::expand_string(os_specific),
+                          type);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: Filename::temporary
 //       Access: Public

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

@@ -77,6 +77,8 @@ PUBLISHED:
 
   static Filename from_os_specific(const string &os_specific,
                                    Type type = T_general);
+  static Filename expand_from(const string &user_string, 
+                              Type type = T_general);
   static Filename temporary(const string &dirname, const string &prefix,
                             Type type = T_general);