diff liboctave/oct-env.cc @ 6838:5e3350bdd91d

[project @ 2007-08-28 02:59:58 by jwe]
author jwe
date Tue, 28 Aug 2007 02:59:59 +0000
parents e96d66e0d634
children 93c65f2a5668
line wrap: on
line diff
--- a/liboctave/oct-env.cc
+++ b/liboctave/oct-env.cc
@@ -110,6 +110,13 @@
     ? instance->do_absolute_pathname (s) : false;
 }
 
+bool
+octave_env::rooted_relative_pathname (const std::string& s)
+{
+  return (instance_ok ())
+    ? instance->do_rooted_relative_pathname (s) : false;
+}
+
 std::string
 octave_env::base_pathname (const std::string& s)
 {
@@ -261,6 +268,29 @@
   return false;
 }
 
+bool
+octave_env::do_rooted_relative_pathname (const std::string& s) const
+{
+  size_t len = s.length ();
+
+  if (len == 0)
+    return false;
+
+  if (len == 1 && s[0] == '.')
+    return true;
+
+  if (len > 1 && s[0] == '.' && file_ops::is_dir_sep (s[1]))
+    return true;
+
+  if (len == 2 && s[0] == '.' && s[1] == '.')
+    return true;
+
+  if (len > 2 && s[0] == '.' && s[1] == '.' && file_ops::is_dir_sep (s[2]))
+    return true;
+
+  return false;
+}
+
 // Return the `basename' of the pathname in STRING (the stuff after
 // the last directory separator).  If STRING is not a full pathname,
 // simply return it.