]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/file-name.cc
Merge branch 'master' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / flower / file-name.cc
index e5736e06b0834ed6c26e15e01f32d25d91682067..0f0bb61270beee42468ec305e31fb0b4106e06fa 100644 (file)
@@ -177,3 +177,26 @@ File_name::is_absolute () const
   return (dir_.length () && dir_[0] == DIRSEP) || root_.length ();
 }
 
+
+
+File_name
+File_name::canonicalized () const
+{
+  File_name c = *this;
+
+  replace_all (c.dir_, string ("//"), string ("/"));
+
+  vector<string> components =  string_split (c.dir_, '/');
+  vector<string> new_components;
+
+  for (vsize i = 0; i < components.size (); i++)
+    {
+      if (components[i] == "..")
+       new_components.pop_back ();
+      else
+       new_components.push_back (components[i]);
+    }
+
+  c.dir_ = string_join (new_components,  "/");
+  return c;  
+}